diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-03-04 22:58:35 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-04 22:58:35 +0100 |
| commit | f27466d7e21d346811c8ef8627937d9fb19cae09 (patch) | |
| tree | 41d9d17906e742c0c3fcd459db39169b892a8df8 | |
| parent | 18a07a78a52d9678c3b00ff675c94865a835d8cb (diff) | |
| parent | 068a233d4d363333237c721e218f48c98694afce (diff) | |
Rollup merge of #94595 - TaKO8Ki:fix-invalid-unresolved-imports-errors-for-asterisk-wildcard-syntax, r=estebank
Fix invalid `unresolved imports` errors for a single-segment import closes #90248
5 files changed, 31 insertions, 1 deletions
diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index bf570fb0f80..70ade7a5600 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -720,7 +720,9 @@ impl<'a, 'b> ImportResolver<'a, 'b> { note: Vec::new(), suggestion: None, }; - errors.push((path, err)); + if path.contains("::") { + errors.push((path, err)) + } } } diff --git a/src/test/ui/rust-2018/unresolved-asterisk-imports.rs b/src/test/ui/rust-2018/unresolved-asterisk-imports.rs new file mode 100644 index 00000000000..ad1064570c7 --- /dev/null +++ b/src/test/ui/rust-2018/unresolved-asterisk-imports.rs @@ -0,0 +1,6 @@ +// edition:2018 + +use not_existing_crate::*; //~ ERROR unresolved import `not_existing_crate +use std as foo; + +fn main() {} diff --git a/src/test/ui/rust-2018/unresolved-asterisk-imports.stderr b/src/test/ui/rust-2018/unresolved-asterisk-imports.stderr new file mode 100644 index 00000000000..09e9edc638d --- /dev/null +++ b/src/test/ui/rust-2018/unresolved-asterisk-imports.stderr @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `not_existing_crate` + --> $DIR/unresolved-asterisk-imports.rs:3:5 + | +LL | use not_existing_crate::*; + | ^^^^^^^^^^^^^^^^^^ use of undeclared crate or module `not_existing_crate` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/src/test/ui/unresolved/unresolved-asterisk-imports.rs b/src/test/ui/unresolved/unresolved-asterisk-imports.rs new file mode 100644 index 00000000000..2d853a66c8d --- /dev/null +++ b/src/test/ui/unresolved/unresolved-asterisk-imports.rs @@ -0,0 +1,4 @@ +use not_existing_crate::*; //~ ERROR unresolved import `not_existing_crate +use std as foo; + +fn main() {} diff --git a/src/test/ui/unresolved/unresolved-asterisk-imports.stderr b/src/test/ui/unresolved/unresolved-asterisk-imports.stderr new file mode 100644 index 00000000000..a789179db65 --- /dev/null +++ b/src/test/ui/unresolved/unresolved-asterisk-imports.stderr @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `not_existing_crate` + --> $DIR/unresolved-asterisk-imports.rs:1:5 + | +LL | use not_existing_crate::*; + | ^^^^^^^^^^^^^^^^^^ maybe a missing crate `not_existing_crate`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. |
