Skip to content

Commit

Permalink
Rollup merge of #83336 - camelid:tool-mod-ice, r=petrochenkov
Browse files Browse the repository at this point in the history
Fix ICE with `use clippy::a::b;`

Fixes #83317.
  • Loading branch information
Dylan-DPC committed Mar 22, 2021
2 parents 85f16fb + bfae41d commit ea5ba76
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -955,14 +955,14 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
}
return None;
}
PathResult::NonModule(path_res) if path_res.base_res() == Res::Err => {
PathResult::NonModule(_) => {
if no_ambiguity {
assert!(import.imported_module.get().is_none());
}
// The error was already reported earlier.
return None;
}
PathResult::Indeterminate | PathResult::NonModule(..) => unreachable!(),
PathResult::Indeterminate => unreachable!(),
};

let (ident, target, source_bindings, target_bindings, type_ns_only) = match import.kind {
Expand Down
7 changes: 7 additions & 0 deletions src/test/ui/imports/tool-mod-child.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use clippy::a; //~ ERROR unresolved import `clippy`
use clippy::a::b; //~ ERROR failed to resolve: maybe a missing crate `clippy`?

use rustdoc::a; //~ ERROR unresolved import `rustdoc`
use rustdoc::a::b; //~ ERROR failed to resolve: maybe a missing crate `rustdoc`?

fn main() {}
28 changes: 28 additions & 0 deletions src/test/ui/imports/tool-mod-child.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
error[E0433]: failed to resolve: maybe a missing crate `clippy`?
--> $DIR/tool-mod-child.rs:2:5
|
LL | use clippy::a::b;
| ^^^^^^ maybe a missing crate `clippy`?

error[E0432]: unresolved import `clippy`
--> $DIR/tool-mod-child.rs:1:5
|
LL | use clippy::a;
| ^^^^^^ maybe a missing crate `clippy`?

error[E0433]: failed to resolve: maybe a missing crate `rustdoc`?
--> $DIR/tool-mod-child.rs:5:5
|
LL | use rustdoc::a::b;
| ^^^^^^^ maybe a missing crate `rustdoc`?

error[E0432]: unresolved import `rustdoc`
--> $DIR/tool-mod-child.rs:4:5
|
LL | use rustdoc::a;
| ^^^^^^^ maybe a missing crate `rustdoc`?

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0432, E0433.
For more information about an error, try `rustc --explain E0432`.

0 comments on commit ea5ba76

Please sign in to comment.