diff --git a/compiler/rustc_resolve/src/check_unused.rs b/compiler/rustc_resolve/src/check_unused.rs index 84221cb8c2d5e..30d4458369999 100644 --- a/compiler/rustc_resolve/src/check_unused.rs +++ b/compiler/rustc_resolve/src/check_unused.rs @@ -105,6 +105,7 @@ impl<'a, 'ra, 'tcx> UnusedImportCheckVisitor<'a, 'ra, 'tcx> { let def_id = self.r.owner_def_id(id); if self.r.effective_visibilities.is_exported(def_id) { self.check_import_as_underscore(use_tree, id); + self.r.maybe_unused_trait_imports.swap_remove(&def_id); return; } diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index c49e0fce630d4..2f734e6632e41 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -568,6 +568,15 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { orig_ident_span, warn_ambiguity, |this, resolution| { + if res == Res::Err + && let Some(old_decl) = resolution.best_decl() + && old_decl.res() != Res::Err + { + // Do not override real declarations with `Res::Err`s from error recovery. + // FIXME: this special case shouldn't be necessary, but removing it triggers an ICE + // due to some other issues (#157406, tests/ui/imports/dummy-import-ice.rs). + return Ok(()); + } if decl.is_glob_import() { resolution.glob_decl = Some(match resolution.glob_decl { Some(old_decl) => this.select_glob_decl( diff --git a/src/bootstrap/src/core/build_steps/vendor.rs b/src/bootstrap/src/core/build_steps/vendor.rs index 246598550553a..17bee20a525b6 100644 --- a/src/bootstrap/src/core/build_steps/vendor.rs +++ b/src/bootstrap/src/core/build_steps/vendor.rs @@ -114,6 +114,13 @@ impl Step for Vendor { cmd.arg("--sync").arg(sync_arg); } + // Reuse vendored dependencies when building source tarball for offline support. + if builder.config.vendor { + cmd.arg("--respect-source-config") + .arg("--config") + .arg(builder.src.join(".cargo").join("config.toml")); + } + // Will read the libstd Cargo.toml // which uses the unstable `public-dependency` feature. cmd.env("RUSTC_BOOTSTRAP", "1"); @@ -135,6 +142,13 @@ impl Step for Vendor { cmd.arg("--versioned-dirs"); } + // Reuse vendored dependencies when building source tarball for offline support. + if builder.config.vendor { + cmd.arg("--respect-source-config") + .arg("--config") + .arg(builder.src.join("library").join(".cargo").join("config.toml")); + } + // Will read the libstd Cargo.toml // which uses the unstable `public-dependency` feature. cmd.env("RUSTC_BOOTSTRAP", "1"); diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index 448a2c927b394..45eeff9032223 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -722,7 +722,6 @@ auto: --target=aarch64-pc-windows-gnullvm,i686-pc-windows-gnullvm --enable-full-tools --enable-profiler - --enable-llvm-link-shared DIST_REQUIRE_ALL_TOOLS: 1 CODEGEN_BACKENDS: llvm,cranelift CC_i686_pc_windows_gnullvm: i686-w64-mingw32-clang @@ -735,7 +734,6 @@ auto: --build=x86_64-pc-windows-gnullvm --enable-full-tools --enable-profiler - --enable-llvm-link-shared DIST_REQUIRE_ALL_TOOLS: 1 CODEGEN_BACKENDS: llvm,cranelift <<: *job-windows diff --git a/src/tools/cargo b/src/tools/cargo index 31bcf52c870d0..910306f2a7b88 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 31bcf52c870d00e7b993ec65fdb888ea12bc2052 +Subproject commit 910306f2a7b889a7ff58fd4a451d3daf356a4cbb diff --git a/tests/ui/imports/auxiliary/dummy-import-ice-macro.rs b/tests/ui/imports/auxiliary/dummy-import-ice-macro.rs new file mode 100644 index 0000000000000..b5bc9c72575c5 --- /dev/null +++ b/tests/ui/imports/auxiliary/dummy-import-ice-macro.rs @@ -0,0 +1,15 @@ +extern crate proc_macro; +use proc_macro::TokenStream; + +#[proc_macro] +pub fn my_macro(_: proc_macro::TokenStream) -> proc_macro::TokenStream { + r" + use own::*; + mod own { + pub use super::submodule::*; + pub use super::ambiguous; + } + " + .parse() + .unwrap() +} diff --git a/tests/ui/imports/dummy-import-ice.rs b/tests/ui/imports/dummy-import-ice.rs new file mode 100644 index 0000000000000..e1e82db9d9f80 --- /dev/null +++ b/tests/ui/imports/dummy-import-ice.rs @@ -0,0 +1,20 @@ +// Regression test for issue #157406. + +//@ check-pass +//@ proc-macro: dummy-import-ice-macro.rs + +extern crate dummy_import_ice_macro; + +pub fn foo() { + ambiguous(); +} + +mod submodule { + pub fn ambiguous() {} +} + +pub mod ambiguous {} + +dummy_import_ice_macro::my_macro!(); + +fn main() {} diff --git a/tests/ui/imports/issue-56125.rs b/tests/ui/imports/issue-56125.rs index a30ac36473bdd..4e7e7ac67c572 100644 --- a/tests/ui/imports/issue-56125.rs +++ b/tests/ui/imports/issue-56125.rs @@ -15,7 +15,7 @@ mod m2 { mod m3 { mod empty {} use empty::issue_56125; //~ ERROR unresolved import `empty::issue_56125` - use issue_56125::*; + use issue_56125::*; //~ ERROR `issue_56125` is ambiguous } fn main() {} diff --git a/tests/ui/imports/issue-56125.stderr b/tests/ui/imports/issue-56125.stderr index f9a169b17a2f9..371130facf9d3 100644 --- a/tests/ui/imports/issue-56125.stderr +++ b/tests/ui/imports/issue-56125.stderr @@ -54,7 +54,24 @@ LL | use issue_56125::non_last_segment::non_last_segment::*; = help: consider adding an explicit import of `issue_56125` to disambiguate = help: or use `self::issue_56125` to refer to this module unambiguously -error: aborting due to 3 previous errors +error[E0659]: `issue_56125` is ambiguous + --> $DIR/issue-56125.rs:18:9 + | +LL | use issue_56125::*; + | ^^^^^^^^^^^ ambiguous name + | + = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution + = note: `issue_56125` could refer to a crate passed with `--extern` + = help: use `::issue_56125` to refer to this crate unambiguously +note: `issue_56125` could also refer to the module imported here + --> $DIR/issue-56125.rs:18:9 + | +LL | use issue_56125::*; + | ^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `issue_56125` to disambiguate + = help: or use `self::issue_56125` to refer to this module unambiguously + +error: aborting due to 4 previous errors Some errors have detailed explanations: E0432, E0659. For more information about an error, try `rustc --explain E0432`. diff --git a/tests/ui/imports/shadow-glob-module-resolution-2.rs b/tests/ui/imports/shadow-glob-module-resolution-2.rs index ac2901eb35290..c3abd1f75542c 100644 --- a/tests/ui/imports/shadow-glob-module-resolution-2.rs +++ b/tests/ui/imports/shadow-glob-module-resolution-2.rs @@ -14,5 +14,7 @@ use a::*; use e as b; //~^ ERROR: unresolved import `e` use b::c::D as e; +//~^ ERROR: cannot determine resolution for the import +//~| ERROR: cannot determine resolution for the import fn main() { } diff --git a/tests/ui/imports/shadow-glob-module-resolution-2.stderr b/tests/ui/imports/shadow-glob-module-resolution-2.stderr index ba8a2ce2d29f8..26745384dee34 100644 --- a/tests/ui/imports/shadow-glob-module-resolution-2.stderr +++ b/tests/ui/imports/shadow-glob-module-resolution-2.stderr @@ -1,3 +1,17 @@ +error: cannot determine resolution for the import + --> $DIR/shadow-glob-module-resolution-2.rs:16:5 + | +LL | use b::c::D as e; + | ^^^^^^^^^^^^ + +error: cannot determine resolution for the import + --> $DIR/shadow-glob-module-resolution-2.rs:16:5 + | +LL | use b::c::D as e; + | ^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0432]: unresolved import `e` --> $DIR/shadow-glob-module-resolution-2.rs:14:5 | @@ -10,6 +24,6 @@ LL - use e as b; LL + use a as b; | -error: aborting due to 1 previous error +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/imports/shadow-glob-module-resolution-4.rs b/tests/ui/imports/shadow-glob-module-resolution-4.rs index 38fe7d17a367f..581cdc185d3f3 100644 --- a/tests/ui/imports/shadow-glob-module-resolution-4.rs +++ b/tests/ui/imports/shadow-glob-module-resolution-4.rs @@ -12,6 +12,8 @@ use e as b; use b::C as e; //~^ ERROR: unresolved import `b::C` +//~| ERROR: cannot determine resolution for the import +//~| ERROR: cannot determine resolution for the import fn e() {} diff --git a/tests/ui/imports/shadow-glob-module-resolution-4.stderr b/tests/ui/imports/shadow-glob-module-resolution-4.stderr index d94a59347a5b8..063beb612b132 100644 --- a/tests/ui/imports/shadow-glob-module-resolution-4.stderr +++ b/tests/ui/imports/shadow-glob-module-resolution-4.stderr @@ -1,9 +1,23 @@ +error: cannot determine resolution for the import + --> $DIR/shadow-glob-module-resolution-4.rs:13:5 + | +LL | use b::C as e; + | ^^^^^^^^^ + +error: cannot determine resolution for the import + --> $DIR/shadow-glob-module-resolution-4.rs:13:5 + | +LL | use b::C as e; + | ^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0432]: unresolved import `b::C` --> $DIR/shadow-glob-module-resolution-4.rs:13:5 | LL | use b::C as e; | ^^^^^^^^^ -error: aborting due to 1 previous error +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/imports/unused-import-issue-157420.rs b/tests/ui/imports/unused-import-issue-157420.rs new file mode 100644 index 0000000000000..550c455f5bbb3 --- /dev/null +++ b/tests/ui/imports/unused-import-issue-157420.rs @@ -0,0 +1,19 @@ +//@ check-pass +//@ edition: 2018.. + +#![crate_type = "lib"] // needed to enable doc link collection +#![warn(unused_imports)] + +pub use inner::*; +use crate::outer::*; + +mod outer { + pub mod inner { + pub trait Trait {} // must be a trait + } + + pub use inner::*; +} + +/// [A::assoc] // needed to force collection of traits in scope, without filter on assoc item name +pub struct A;