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