]>
Commit | Line | Data |
---|---|---|
8bb4bdeb | 1 | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT |
223e47cc LB |
2 | // file at the top-level directory of this distribution and at |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
2c00a5a8 XL |
11 | // ignore-tidy-tab |
12 | ||
abe05a73 | 13 | #![warn(unused_mut, unused_parens)] // UI tests pass `-A unused`—see Issue #43896 |
ea8adc8c | 14 | #![feature(no_debug)] |
3b2f2976 | 15 | |
abe05a73 | 16 | #[no_mangle] static SHENZHOU: usize = 1; // should suggest `pub` |
ff7c6d11 | 17 | //~^ WARN static is marked #[no_mangle] |
abe05a73 | 18 | #[no_mangle] const DISCOVERY: usize = 1; // should suggest `pub static` rather than `const` |
ff7c6d11 | 19 | //~^ ERROR const items should never be #[no_mangle] |
abe05a73 XL |
20 | |
21 | #[no_mangle] // should suggest removal (generics can't be no-mangle) | |
22 | pub fn defiant<T>(_t: T) {} | |
ff7c6d11 | 23 | //~^ WARN functions generic over types must be mangled |
abe05a73 XL |
24 | |
25 | #[no_mangle] | |
26 | fn rio_grande() {} // should suggest `pub` | |
ff7c6d11 | 27 | //~^ WARN function is marked |
abe05a73 | 28 | |
2c00a5a8 XL |
29 | mod badlands { |
30 | // The private-no-mangle lints shouldn't suggest inserting `pub` when the | |
31 | // item is already `pub` (but triggered the lint because, e.g., it's in a | |
32 | // private module). (Issue #47383) | |
33 | #[no_mangle] pub static DAUNTLESS: bool = true; | |
34 | //~^ WARN static is marked | |
35 | #[no_mangle] pub fn val_jean() {} | |
36 | //~^ WARN function is marked | |
37 | } | |
38 | ||
abe05a73 XL |
39 | struct Equinox { |
40 | warp_factor: f32, | |
41 | } | |
42 | ||
ea8adc8c | 43 | #[no_debug] // should suggest removal of deprecated attribute |
ff7c6d11 | 44 | //~^ WARN deprecated |
7453a54e | 45 | fn main() { |
ea8adc8c | 46 | while true { // should suggest `loop` |
ff7c6d11 | 47 | //~^ WARN denote infinite loops |
ea8adc8c | 48 | let mut a = (1); // should suggest no `mut`, no parens |
ff7c6d11 XL |
49 | //~^ WARN does not need to be mutable |
50 | //~| WARN unnecessary parentheses | |
2c00a5a8 XL |
51 | // the line after `mut` has a `\t` at the beginning, this is on purpose |
52 | let mut | |
53 | b = 1; | |
54 | //~^^ WARN does not need to be mutable | |
abe05a73 XL |
55 | let d = Equinox { warp_factor: 9.975 }; |
56 | match d { | |
57 | Equinox { warp_factor: warp_factor } => {} // should suggest shorthand | |
ff7c6d11 | 58 | //~^ WARN this pattern is redundant |
abe05a73 | 59 | } |
2c00a5a8 | 60 | println!("{} {}", a, b); |
ea8adc8c | 61 | } |
223e47cc | 62 | } |