Skip to content
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

resolve: Fix regression in resolution of raw keywords in paths #70000

Merged
merged 1 commit into from
Mar 17, 2020
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
5 changes: 1 addition & 4 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2183,11 +2183,8 @@ impl<'a> Resolver<'a> {
Applicability::MaybeIncorrect,
)),
)
} else if !ident.is_reserved() {
(format!("maybe a missing crate `{}`?", ident), None)
} else {
// the parser will already have complained about the keyword being used
return PathResult::NonModule(PartialRes::new(Res::Err));
(format!("maybe a missing crate `{}`?", ident), None)
}
} else if i == 0 {
(format!("use of undeclared type or module `{}`", ident), None)
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/issue-61732.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This previously triggered an ICE.

pub(in crate::r#mod) fn main() {}
//~^ ERROR expected module, found unresolved item
//~^ ERROR failed to resolve: maybe a missing crate `r#mod`
8 changes: 4 additions & 4 deletions src/test/rustdoc-ui/issue-61732.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0577]: expected module, found unresolved item `crate::r#mod`
--> $DIR/issue-61732.rs:3:8
error[E0433]: failed to resolve: maybe a missing crate `r#mod`?
--> $DIR/issue-61732.rs:3:15
|
LL | pub(in crate::r#mod) fn main() {}
| ^^^^^^^^^^^^ not a module
| ^^^^^ maybe a missing crate `r#mod`?

error: Compilation failed, aborting rustdoc

error: aborting due to 2 previous errors

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

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,12 @@ help: you can escape reserved keywords to use them as identifiers
LL | use r#extern::foo;
| ^^^^^^^^

error: aborting due to previous error
error[E0432]: unresolved import `r#extern`
--> $DIR/keyword-extern-as-identifier-use.rs:1:5
|
LL | use extern::foo;
| ^^^^^^ maybe a missing crate `r#extern`?

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0432`.
5 changes: 5 additions & 0 deletions src/test/ui/resolve/raw-ident-in-path.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Regression test for issue #63882.

type A = crate::r#break; //~ ERROR cannot find type `r#break` in module `crate`

fn main() {}
9 changes: 9 additions & 0 deletions src/test/ui/resolve/raw-ident-in-path.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0412]: cannot find type `r#break` in module `crate`
--> $DIR/raw-ident-in-path.rs:3:17
|
LL | type A = crate::r#break;
| ^^^^^^^ not found in `crate`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0412`.