fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
2.1 KiB66 linesraw
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
12pub fn defiant<T>(_t: T) {}
13//~^ WARN functions generic over types or consts must be mangled
14
15#[no_mangle]
16fn rio_grande() {}
17
18mod 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
40struct Equinox {
41    warp_factor: f32,
42}
43
44fn 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}