]> git.lizzy.rs Git - rust.git/blob - tests/ui/resolve/issue-81508.rs
Rollup merge of #106779 - RReverser:patch-2, r=Mark-Simulacrum
[rust.git] / tests / ui / resolve / issue-81508.rs
1 // Confusing diagnostic when using variable as a type:
2 //
3 // Previous warnings indicate Foo is not used, when in fact it is
4 // used improperly as a variable or constant. New warning points
5 // out user may be trying to use variable as a type. Test demonstrates
6 // cases for both local variable and const.
7
8 fn main() {
9     let Baz: &str = "";
10
11     println!("{}", Baz::Bar); //~ ERROR: failed to resolve: use of undeclared type `Baz`
12 }
13
14 #[allow(non_upper_case_globals)]
15 pub const Foo: &str = "";
16
17 mod submod {
18     use super::Foo;
19     fn function() {
20         println!("{}", Foo::Bar); //~ ERROR: failed to resolve: use of undeclared type `Foo`
21     }
22 }