]> git.lizzy.rs Git - rust.git/blob - src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.rs
Rollup merge of #87180 - notriddle:notriddle/sidebar-keyboard-mobile, r=GuillaumeGomez
[rust.git] / src / test / ui / resolve / suggest-path-instead-of-mod-dot-item.rs
1 // Beginners write `mod.item` when they should write `mod::item`.
2 // This tests that we suggest the latter when we encounter the former.
3
4 pub mod a {
5     pub const I: i32 = 1;
6
7     pub fn f() -> i32 { 2 }
8
9     pub mod b {
10         pub const J: i32 = 3;
11
12         pub fn g() -> i32 { 4 }
13     }
14 }
15
16 fn h1() -> i32 {
17     a.I
18     //~^ ERROR expected value, found module `a`
19 }
20
21 fn h2() -> i32 {
22     a.g()
23     //~^ ERROR expected value, found module `a`
24 }
25
26 fn h3() -> i32 {
27     a.b.J
28     //~^ ERROR expected value, found module `a`
29 }
30
31 fn h4() -> i32 {
32     a::b.J
33     //~^ ERROR expected value, found module `a::b`
34 }
35
36 fn h5() {
37     a.b.f();
38     //~^ ERROR expected value, found module `a`
39     let v = Vec::new();
40     v.push(a::b);
41     //~^ ERROR expected value, found module `a::b`
42 }
43
44 fn h6() -> i32 {
45     a::b.f()
46     //~^ ERROR expected value, found module `a::b`
47 }
48
49 fn h7() {
50     a::b
51     //~^ ERROR expected value, found module `a::b`
52 }
53
54 fn h8() -> i32 {
55     a::b()
56     //~^ ERROR expected function, found module `a::b`
57 }
58
59 fn main() {}