Closed
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.