]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lint/suggestions.rs
Auto merge of #67290 - jonas-schievink:leak-audit, r=KodrAus
[rust.git] / src / test / ui / lint / suggestions.rs
1 // ignore-tidy-tab
2
3 #![warn(unused_mut, unused_parens)] // UI tests pass `-A unused`—see Issue #43896
4 #![feature(no_debug)]
5
6 #[no_mangle] const DISCOVERY: usize = 1;
7 //~^ ERROR const items should never be `#[no_mangle]`
8 //~| HELP try a static value
9
10 #[no_mangle]
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 const DAUNTLESS: bool = true;
23     //~^ ERROR const items should never be `#[no_mangle]`
24     //~| HELP try a static value
25     #[no_mangle] pub fn val_jean<T>() {}
26     //~^ WARN functions generic over types or consts must be mangled
27     //~| HELP remove this attribute
28
29     // ... but we can suggest just-`pub` instead of restricted
30     #[no_mangle] pub(crate) const VETAR: bool = true;
31     //~^ ERROR const items should never be `#[no_mangle]`
32     //~| HELP try a static value
33     #[no_mangle] pub(crate) fn crossfield<T>() {}
34     //~^ WARN functions generic over types or consts must be mangled
35     //~| HELP remove this attribute
36 }
37
38 struct Equinox {
39     warp_factor: f32,
40 }
41
42 #[no_debug] // should suggest removal of deprecated attribute
43 //~^ WARN deprecated
44 //~| HELP remove this attribute
45 fn main() {
46     while true {
47     //~^ WARN denote infinite loops
48     //~| HELP use `loop`
49         let mut registry_no = (format!("NX-{}", 74205));
50         //~^ WARN does not need to be mutable
51         //~| HELP remove this `mut`
52         //~| WARN unnecessary parentheses
53         //~| HELP remove these parentheses
54         // the line after `mut` has a `\t` at the beginning, this is on purpose
55         let mut
56                 b = 1;
57         //~^^ WARN does not need to be mutable
58         //~| HELP remove this `mut`
59         let d = Equinox { warp_factor: 9.975 };
60         match d {
61             Equinox { warp_factor: warp_factor } => {}
62             //~^ WARN this pattern is redundant
63             //~| HELP use shorthand field pattern
64         }
65         println!("{} {}", registry_no, b);
66     }
67 }