Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/rustc_resolve/src/check_unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
14 changes: 14 additions & 0 deletions src/bootstrap/src/core/build_steps/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down
2 changes: 0 additions & 2 deletions src/ci/github-actions/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/tools/cargo
15 changes: 15 additions & 0 deletions tests/ui/imports/auxiliary/dummy-import-ice-macro.rs
Original file line number Diff line number Diff line change
@@ -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()
}
20 changes: 20 additions & 0 deletions tests/ui/imports/dummy-import-ice.rs
Original file line number Diff line number Diff line change
@@ -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() {}
2 changes: 1 addition & 1 deletion tests/ui/imports/issue-56125.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
19 changes: 18 additions & 1 deletion tests/ui/imports/issue-56125.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
2 changes: 2 additions & 0 deletions tests/ui/imports/shadow-glob-module-resolution-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() { }
16 changes: 15 additions & 1 deletion tests/ui/imports/shadow-glob-module-resolution-2.stderr
Original file line number Diff line number Diff line change
@@ -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
|
Expand All @@ -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`.
2 changes: 2 additions & 0 deletions tests/ui/imports/shadow-glob-module-resolution-4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

Expand Down
16 changes: 15 additions & 1 deletion tests/ui/imports/shadow-glob-module-resolution-4.stderr
Original file line number Diff line number Diff line change
@@ -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`.
19 changes: 19 additions & 0 deletions tests/ui/imports/unused-import-issue-157420.rs
Original file line number Diff line number Diff line change
@@ -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;
Loading