]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lint/suggestions.rs
Auto merge of #106349 - LeSeulArtichaut:dyn-star-tracking-issue, r=jackh726
[rust.git] / src / test / ui / lint / suggestions.rs
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] 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     #[allow(dead_code)] // for rustfix
26     #[no_mangle] 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(crate) const 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     #[no_mangle] 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     while true {
46     //~^ WARN denote infinite loops
47     //~| HELP use `loop`
48         let mut 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 mut
55                 b = 1;
56         //~^^ WARN does not need to be mutable
57         //~| HELP remove this `mut`
58         let d = Equinox { warp_factor: 9.975 };
59         match d {
60             #[allow(unused_variables)] // for rustfix
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 }