]> git.lizzy.rs Git - rust.git/blob - tests/ui/lint/suggestions.fixed
Auto merge of #106884 - clubby789:fieldless-enum-debug, r=michaelwoerister
[rust.git] / tests / ui / lint / suggestions.fixed
1 // ignore-tidy-tab
2 // run-rustfix
3
4 #![warn(unused_mut, unused_parens)] // UI tests pass `-A unused`—see Issue #43896
5
6 #[no_mangle] pub static DISCOVERY: usize = 1;
7 //~^ ERROR const items should never be `#[no_mangle]`
8 //~| HELP try a static value
9
10
11 //~^ HELP remove this attribute
12 pub fn defiant<T>(_t: T) {}
13 //~^ WARN functions generic over types or consts must be mangled
14
15 #[no_mangle]
16 fn rio_grande() {}
17
18 mod badlands {
19     // The private-no-mangle lints shouldn't suggest inserting `pub` when the
20     // item is already `pub` (but triggered the lint because, e.g., it's in a
21     // private module). (Issue #47383)
22     #[no_mangle] pub static DAUNTLESS: bool = true;
23     //~^ ERROR const items should never be `#[no_mangle]`
24     //~| HELP try a static value
25     #[allow(dead_code)] // for rustfix
26      pub fn val_jean<T>() {}
27     //~^ WARN functions generic over types or consts must be mangled
28     //~| HELP remove this attribute
29
30     // ... but we can suggest just-`pub` instead of restricted
31     #[no_mangle] pub static VETAR: bool = true;
32     //~^ ERROR const items should never be `#[no_mangle]`
33     //~| HELP try a static value
34     #[allow(dead_code)] // for rustfix
35      pub(crate) fn crossfield<T>() {}
36     //~^ WARN functions generic over types or consts must be mangled
37     //~| HELP remove this attribute
38 }
39
40 struct Equinox {
41     warp_factor: f32,
42 }
43
44 fn main() {
45     loop {
46     //~^ WARN denote infinite loops
47     //~| HELP use `loop`
48         let registry_no = format!("NX-{}", 74205);
49         //~^ WARN does not need to be mutable
50         //~| HELP remove this `mut`
51         //~| WARN unnecessary parentheses
52         //~| HELP remove these parentheses
53         // the line after `mut` has a `\t` at the beginning, this is on purpose
54         let b = 1;
55         //~^^ WARN does not need to be mutable
56         //~| HELP remove this `mut`
57         let d = Equinox { warp_factor: 9.975 };
58         match d {
59             #[allow(unused_variables)] // for rustfix
60             Equinox { warp_factor } => {}
61             //~^ WARN this pattern is redundant
62             //~| HELP use shorthand field pattern
63         }
64         println!("{} {}", registry_no, b);
65     }
66 }