-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add note and suggestion when crate location fails due to the identifi…
…er `meta` being used
- Loading branch information
Showing
5 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/test/ui/suggestions/issue-73948-meta-as-module-name.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// check-only | ||
// run-rustfix | ||
// edition:2018 | ||
|
||
// https://github.com/rust-lang/rust/issues/73948 | ||
// Tests that when `meta` is used as a module name and imported uniformly a | ||
// suggestion is made to make the import unambiguous with `crate::meta` | ||
|
||
mod meta { | ||
pub const FOO: bool = true; | ||
} | ||
|
||
use crate::meta::FOO; //~ ERROR can't find crate for `meta` | ||
|
||
fn main() { | ||
assert!(FOO); | ||
} |
17 changes: 17 additions & 0 deletions
17
src/test/ui/suggestions/issue-73948-meta-as-module-name.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// check-only | ||
// run-rustfix | ||
// edition:2018 | ||
|
||
// https://github.com/rust-lang/rust/issues/73948 | ||
// Tests that when `meta` is used as a module name and imported uniformly a | ||
// suggestion is made to make the import unambiguous with `crate::meta` | ||
|
||
mod meta { | ||
pub const FOO: bool = true; | ||
} | ||
|
||
use meta::FOO; //~ ERROR can't find crate for `meta` | ||
|
||
fn main() { | ||
assert!(FOO); | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/ui/suggestions/issue-73948-meta-as-module-name.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error[E0463]: can't find crate for `meta` | ||
--> $DIR/issue-73948-meta-as-module-name.rs:13:5 | ||
| | ||
LL | use meta::FOO; | ||
| ^^^^ can't find crate | ||
| | ||
= note: meta is a reserved crate name | ||
help: you can use `crate::` or `self::` if you intended to refer to a local module and not a crate | ||
| | ||
LL | use crate::meta::FOO; | ||
| ^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0463`. |