-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
The following code...
#[allow(non_upper_case_globals)]
pub const Foo: &str = "";
mod submod {
use super::Foo;
fn function() {
println!("{}", Foo::Bar);
}
}
...yields the following error and warning:
error[E0433]: failed to resolve: use of undeclared type `Foo`
--> src/lib.rs:7:24
|
7 | println!("{}", Foo::Bar);
| ^^^ use of undeclared type `Foo`
warning: unused import: `super::Foo`
--> src/lib.rs:5:9
|
5 | use super::Foo;
| ^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
The warning says that Foo
is not used but it clearly is, just not properly. This error is normally easier to spot when using the proper casing for constants, but that might not always be the case. Perhaps in this instance, we should look for other items with the exact same name and point out that the user is trying to use a constant as a type.
kennykerr, estebank and henryboisdequin
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.