Skip to content

Fix invalid unresolved imports errors for a single-segment import #94595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
4 changes: 3 additions & 1 deletion compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/test/ui/rust-2018/unresolved-asterisk-imports.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// edition:2018

use not_existing_crate::*; //~ ERROR unresolved import `not_existing_crate
use std as foo;

fn main() {}
9 changes: 9 additions & 0 deletions src/test/ui/rust-2018/unresolved-asterisk-imports.stderr
Original file line number Diff line number Diff line change
@@ -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`.
4 changes: 4 additions & 0 deletions src/test/ui/unresolved/unresolved-asterisk-imports.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
use not_existing_crate::*; //~ ERROR unresolved import `not_existing_crate
use std as foo;

fn main() {}
9 changes: 9 additions & 0 deletions src/test/ui/unresolved/unresolved-asterisk-imports.stderr
Original file line number Diff line number Diff line change
@@ -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`.