Skip to content

Commit e80cb20

Browse files
committed
resolve: Fix regression in resolution of raw keywords in paths
1 parent 42ce9b4 commit e80cb20

7 files changed

+29
-10
lines changed

src/librustc_resolve/lib.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -2183,11 +2183,8 @@ impl<'a> Resolver<'a> {
21832183
Applicability::MaybeIncorrect,
21842184
)),
21852185
)
2186-
} else if !ident.is_reserved() {
2187-
(format!("maybe a missing crate `{}`?", ident), None)
21882186
} else {
2189-
// the parser will already have complained about the keyword being used
2190-
return PathResult::NonModule(PartialRes::new(Res::Err));
2187+
(format!("maybe a missing crate `{}`?", ident), None)
21912188
}
21922189
} else if i == 0 {
21932190
(format!("use of undeclared type or module `{}`", ident), None)

src/test/rustdoc-ui/issue-61732.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// This previously triggered an ICE.
22

33
pub(in crate::r#mod) fn main() {}
4-
//~^ ERROR expected module, found unresolved item
4+
//~^ ERROR failed to resolve: maybe a missing crate `r#mod`
+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
error[E0577]: expected module, found unresolved item `crate::r#mod`
2-
--> $DIR/issue-61732.rs:3:8
1+
error[E0433]: failed to resolve: maybe a missing crate `r#mod`?
2+
--> $DIR/issue-61732.rs:3:15
33
|
44
LL | pub(in crate::r#mod) fn main() {}
5-
| ^^^^^^^^^^^^ not a module
5+
| ^^^^^ maybe a missing crate `r#mod`?
66

77
error: Compilation failed, aborting rustdoc
88

99
error: aborting due to 2 previous errors
1010

11-
For more information about this error, try `rustc --explain E0577`.
11+
For more information about this error, try `rustc --explain E0433`.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
use extern::foo; //~ ERROR expected identifier, found keyword `extern`
2+
//~| ERROR unresolved import `r#extern`
23

34
fn main() {}

src/test/ui/keyword/extern/keyword-extern-as-identifier-use.stderr

+8-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,12 @@ help: you can escape reserved keywords to use them as identifiers
99
LL | use r#extern::foo;
1010
| ^^^^^^^^
1111

12-
error: aborting due to previous error
12+
error[E0432]: unresolved import `r#extern`
13+
--> $DIR/keyword-extern-as-identifier-use.rs:1:5
14+
|
15+
LL | use extern::foo;
16+
| ^^^^^^ maybe a missing crate `r#extern`?
17+
18+
error: aborting due to 2 previous errors
1319

20+
For more information about this error, try `rustc --explain E0432`.
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Regression test for issue #63882.
2+
3+
type A = crate::r#break; //~ ERROR cannot find type `r#break` in module `crate`
4+
5+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0412]: cannot find type `r#break` in module `crate`
2+
--> $DIR/raw-ident-in-path.rs:3:17
3+
|
4+
LL | type A = crate::r#break;
5+
| ^^^^^^^ not found in `crate`
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0412`.

0 commit comments

Comments
 (0)