about summary refs log tree commit diff
path: root/tests/ui/lint/unused/must-use-macros.fixed
blob: 609d0c6392b57a59dd8adbd3192dc2c54cf3ed01 (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
// Makes sure the suggestions of the `unused_must_use` lint are not inside
//
// See <https://github.com/rust-lang/rust/issues/143025>

//@ check-pass
//@ run-rustfix

#![expect(unused_macros)]
#![warn(unused_must_use)]

fn main() {
    {
        macro_rules! cmp {
            ($a:tt, $b:tt) => {
                $a == $b
            };
        }

        // FIXME(Urgau): For some unknown reason the spans we get are not
        // recorded to be from any expansions, preventing us from either
        // suggesting in front of the macro or not at all.
        // cmp!(1, 1);
    }

    {
        macro_rules! cmp {
            ($a:ident, $b:ident) => {
                $a == $b
            }; //~^ WARN unused comparison that must be used
        }

        let a = 1;
        let b = 1;
        let _ = cmp!(a, b);
        //~^ SUGGESTION let _
    }

    {
        macro_rules! cmp {
            ($a:expr, $b:expr) => {
                $a == $b
            }; //~^ WARN unused comparison that must be used
        }

        let _ = cmp!(1, 1);
        //~^ SUGGESTION let _
    }

    {
        macro_rules! cmp {
            ($a:tt, $b:tt) => {
                $a.eq(&$b)
            };
        }

        let _ = cmp!(1, 1);
        //~^ WARN unused return value
        //~| SUGGESTION let _
    }
}