summaryrefslogtreecommitdiffstats
path: root/src/test/ui/resolve/issue-22692.rs
blob: 31a76261408ef7021eecf5beac57e5dd24b35255 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
fn main() {
    let _ = String.new();
    //~^ ERROR expected value, found struct `String`
    //~| HELP use the path separator

    let _ = String.default;
    //~^ ERROR expected value, found struct `String`
    //~| HELP use the path separator

    let _ = Vec::<()>.with_capacity(1);
    //~^ ERROR expected value, found struct `Vec`
    //~| HELP use the path separator
}

macro_rules! Type {
    () => {
        ::std::cell::Cell
        //~^ ERROR expected value, found struct `std::cell::Cell`
        //~| ERROR expected value, found struct `std::cell::Cell`
        //~| ERROR expected value, found struct `std::cell::Cell`
    };
}

macro_rules! create {
    (type method) => {
        Vec.new()
        //~^ ERROR expected value, found struct `Vec`
        //~| HELP use the path separator
    };
    (type field) => {
        Vec.new
        //~^ ERROR expected value, found struct `Vec`
        //~| HELP use the path separator
    };
    (macro method) => {
        Type!().new(0)
        //~^ HELP use the path separator
    };
}

fn interaction_with_macros() {
    //
    // Verify that we do not only suggest to replace `.` with `::` if the receiver is a
    // macro call but that we also correctly suggest to surround it with angle brackets.
    //

    Type!().get();
    //~^ HELP use the path separator

    Type! {}.get;
    //~^ HELP use the path separator

    //
    // Ensure that the suggestion is shown for expressions inside of macro definitions.
    //

    let _ = create!(type method);
    let _ = create!(type field);
    let _ = create!(macro method);
}