summaryrefslogtreecommitdiffstats
path: root/tests/ui/lint/suggestions.fixed
blob: 35851690b738135126aa773d6b3437f1d056f3b4 (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
61
62
63
64
65
66
// ignore-tidy-tab
// run-rustfix

#![warn(unused_mut, unused_parens)] // UI tests pass `-A unused`—see Issue #43896

#[no_mangle] pub static DISCOVERY: usize = 1;
//~^ ERROR const items should never be `#[no_mangle]`
//~| HELP try a static value


//~^ HELP remove this attribute
pub fn defiant<T>(_t: T) {}
//~^ WARN functions generic over types or consts must be mangled

#[no_mangle]
fn rio_grande() {}

mod badlands {
    // The private-no-mangle lints shouldn't suggest inserting `pub` when the
    // item is already `pub` (but triggered the lint because, e.g., it's in a
    // private module). (Issue #47383)
    #[no_mangle] pub static DAUNTLESS: bool = true;
    //~^ ERROR const items should never be `#[no_mangle]`
    //~| HELP try a static value
    #[allow(dead_code)] // for rustfix
     pub fn val_jean<T>() {}
    //~^ WARN functions generic over types or consts must be mangled
    //~| HELP remove this attribute

    // ... but we can suggest just-`pub` instead of restricted
    #[no_mangle] pub static VETAR: bool = true;
    //~^ ERROR const items should never be `#[no_mangle]`
    //~| HELP try a static value
    #[allow(dead_code)] // for rustfix
     pub(crate) fn crossfield<T>() {}
    //~^ WARN functions generic over types or consts must be mangled
    //~| HELP remove this attribute
}

struct Equinox {
    warp_factor: f32,
}

fn main() {
    loop {
    //~^ WARN denote infinite loops
    //~| HELP use `loop`
        let registry_no = format!("NX-{}", 74205);
        //~^ WARN does not need to be mutable
        //~| HELP remove this `mut`
        //~| WARN unnecessary parentheses
        //~| HELP remove these parentheses
        // the line after `mut` has a `\t` at the beginning, this is on purpose
        let b = 1;
        //~^^ WARN does not need to be mutable
        //~| HELP remove this `mut`
        let d = Equinox { warp_factor: 9.975 };
        match d {
            #[allow(unused_variables)] // for rustfix
            Equinox { warp_factor } => {}
            //~^ WARN this pattern is redundant
            //~| HELP use shorthand field pattern
        }
        println!("{} {}", registry_no, b);
    }
}