Skip to content

Commit dd68685

Browse files
committed
resolve: Fix ICE in macro import error recovery
1 parent d586d5d commit dd68685

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

src/librustc_resolve/macros.rs

+3
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,9 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
449449
return Err(Determinacy::Determined);
450450
}
451451
}
452+
Def::Err => {
453+
return Err(Determinacy::Determined);
454+
}
452455
_ => panic!("expected `Def::Macro` or `Def::NonMacroAttr`"),
453456
}
454457

src/test/ui/imports/issue-55457.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
use NonExistent; //~ ERROR unresolved import `NonExistent`
2+
use non_existent::non_existent; //~ ERROR unresolved import `non_existent`
3+
4+
#[non_existent] //~ ERROR cannot determine resolution for the attribute macro `non_existent`
5+
#[derive(NonExistent)] //~ ERROR cannot determine resolution for the derive macro `NonExistent`
6+
struct S;
7+
8+
fn main() {}
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
error[E0432]: unresolved import `NonExistent`
2+
--> $DIR/issue-55457.rs:1:5
3+
|
4+
LL | use NonExistent; //~ ERROR unresolved import `NonExistent`
5+
| ^^^^^^^^^^^ no `NonExistent` in the root. Did you mean to use `non_existent`?
6+
7+
error[E0432]: unresolved import `non_existent`
8+
--> $DIR/issue-55457.rs:2:5
9+
|
10+
LL | use non_existent::non_existent; //~ ERROR unresolved import `non_existent`
11+
| ^^^^^^^^^^^^ Maybe a missing `extern crate non_existent;`?
12+
13+
error: cannot determine resolution for the derive macro `NonExistent`
14+
--> $DIR/issue-55457.rs:5:10
15+
|
16+
LL | #[derive(NonExistent)] //~ ERROR cannot determine resolution for the derive macro `NonExistent`
17+
| ^^^^^^^^^^^
18+
|
19+
= note: import resolution is stuck, try simplifying macro imports
20+
21+
error: cannot determine resolution for the attribute macro `non_existent`
22+
--> $DIR/issue-55457.rs:4:3
23+
|
24+
LL | #[non_existent] //~ ERROR cannot determine resolution for the attribute macro `non_existent`
25+
| ^^^^^^^^^^^^
26+
|
27+
= note: import resolution is stuck, try simplifying macro imports
28+
29+
error: aborting due to 4 previous errors
30+
31+
For more information about this error, try `rustc --explain E0432`.

0 commit comments

Comments
 (0)