Skip to content

Commit 3d25622

Browse files
authored
Rollup merge of #70000 - petrochenkov:rawkeypars, r=davidtwco
resolve: Fix regression in resolution of raw keywords in paths Fixes #63882.
2 parents 1b0c73b + e80cb20 commit 3d25622

7 files changed

+29
-10
lines changed

src/librustc_resolve/lib.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -2188,11 +2188,8 @@ impl<'a> Resolver<'a> {
21882188
Applicability::MaybeIncorrect,
21892189
)),
21902190
)
2191-
} else if !ident.is_reserved() {
2192-
(format!("maybe a missing crate `{}`?", ident), None)
21932191
} else {
2194-
// the parser will already have complained about the keyword being used
2195-
return PathResult::NonModule(PartialRes::new(Res::Err));
2192+
(format!("maybe a missing crate `{}`?", ident), None)
21962193
}
21972194
} else if i == 0 {
21982195
(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)