]> git.proxmox.com Git - rustc.git/blob - src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.rs
New upstream version 1.24.1+dfsg1
[rustc.git] / src / test / ui / resolve / suggest-path-instead-of-mod-dot-item.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // Beginners write `mod.item` when they should write `mod::item`.
12 // This tests that we suggest the latter when we encounter the former.
13
14 pub mod a {
15 pub const I: i32 = 1;
16
17 pub fn f() -> i32 { 2 }
18
19 pub mod b {
20 pub const J: i32 = 3;
21
22 pub fn g() -> i32 { 4 }
23 }
24 }
25
26 fn h1() -> i32 {
27 a.I
28 //~^ ERROR expected value, found module `a`
29 }
30
31 fn h2() -> i32 {
32 a.g()
33 //~^ ERROR expected value, found module `a`
34 }
35
36 fn h3() -> i32 {
37 a.b.J
38 //~^ ERROR expected value, found module `a`
39 }
40
41 fn h4() -> i32 {
42 a::b.J
43 //~^ ERROR expected value, found module `a::b`
44 }
45
46 fn h5() {
47 a.b.f();
48 //~^ ERROR expected value, found module `a`
49 let v = Vec::new();
50 v.push(a::b);
51 //~^ ERROR expected value, found module `a::b`
52 }
53
54 fn h6() -> i32 {
55 a::b.f()
56 //~^ ERROR expected value, found module `a::b`
57 }
58
59 fn h7() {
60 a::b
61 //~^ ERROR expected value, found module `a::b`
62 }
63
64 fn h8() -> i32 {
65 a::b()
66 //~^ ERROR expected function, found module `a::b`
67 }