Skip to content

Commit 8e6ed12

Browse files
committed
bolster UI test converage for lint suggestions
1 parent 38e5a96 commit 8e6ed12

File tree

2 files changed

+83
-11
lines changed

2 files changed

+83
-11
lines changed

src/test/ui/lint/suggestions.rs

+17
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,27 @@
1111
#![warn(unused_mut)] // UI tests pass `-A unused`—see Issue #43896
1212
#![feature(no_debug)]
1313

14+
#[no_mangle] static SHENZHOU: usize = 1; // should suggest `pub`
15+
#[no_mangle] const DISCOVERY: usize = 1; // should suggest `pub static` rather than `const`
16+
17+
#[no_mangle] // should suggest removal (generics can't be no-mangle)
18+
pub fn defiant<T>(_t: T) {}
19+
20+
#[no_mangle]
21+
fn rio_grande() {} // should suggest `pub`
22+
23+
struct Equinox {
24+
warp_factor: f32,
25+
}
26+
1427
#[no_debug] // should suggest removal of deprecated attribute
1528
fn main() {
1629
while true { // should suggest `loop`
1730
let mut a = (1); // should suggest no `mut`, no parens
31+
let d = Equinox { warp_factor: 9.975 };
32+
match d {
33+
Equinox { warp_factor: warp_factor } => {} // should suggest shorthand
34+
}
1835
println!("{}", a);
1936
}
2037
}

src/test/ui/lint/suggestions.stderr

+66-11
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
warning: unnecessary parentheses around assigned value
2-
--> $DIR/suggestions.rs:17:21
2+
--> $DIR/suggestions.rs:30:21
33
|
4-
17 | let mut a = (1); // should suggest no `mut`, no parens
4+
30 | let mut a = (1); // should suggest no `mut`, no parens
55
| ^^^ help: remove these parentheses
66
|
77
= note: #[warn(unused_parens)] on by default
88

99
warning: use of deprecated attribute `no_debug`: the `#[no_debug]` attribute was an experimental feature that has been deprecated due to lack of demand. See https://github.com/rust-lang/rust/issues/29721
10-
--> $DIR/suggestions.rs:14:1
10+
--> $DIR/suggestions.rs:27:1
1111
|
12-
14 | #[no_debug] // should suggest removal of deprecated attribute
12+
27 | #[no_debug] // should suggest removal of deprecated attribute
1313
| ^^^^^^^^^^^ help: remove this attribute
1414
|
1515
= note: #[warn(deprecated)] on by default
1616

1717
warning: variable does not need to be mutable
18-
--> $DIR/suggestions.rs:17:13
18+
--> $DIR/suggestions.rs:30:13
1919
|
20-
17 | let mut a = (1); // should suggest no `mut`, no parens
20+
30 | let mut a = (1); // should suggest no `mut`, no parens
2121
| ---^^
2222
| |
2323
| help: remove this `mut`
@@ -28,18 +28,73 @@ note: lint level defined here
2828
11 | #![warn(unused_mut)] // UI tests pass `-A unused`—see Issue #43896
2929
| ^^^^^^^^^^
3030

31+
warning: static is marked #[no_mangle], but not exported
32+
--> $DIR/suggestions.rs:14:14
33+
|
34+
14 | #[no_mangle] static SHENZHOU: usize = 1; // should suggest `pub`
35+
| -^^^^^^^^^^^^^^^^^^^^^^^^^^
36+
| |
37+
| help: try making it public: `pub `
38+
|
39+
= note: #[warn(private_no_mangle_statics)] on by default
40+
41+
error: const items should never be #[no_mangle]
42+
--> $DIR/suggestions.rs:15:14
43+
|
44+
15 | #[no_mangle] const DISCOVERY: usize = 1; // should suggest `pub static` rather than `const`
45+
| -----^^^^^^^^^^^^^^^^^^^^^^
46+
| |
47+
| help: try a static value: `pub static`
48+
|
49+
= note: #[deny(no_mangle_const_items)] on by default
50+
51+
warning: functions generic over types must be mangled
52+
--> $DIR/suggestions.rs:18:1
53+
|
54+
17 | #[no_mangle] // should suggest removal (generics can't be no-mangle)
55+
| ------------ help: remove this attribute
56+
18 | pub fn defiant<T>(_t: T) {}
57+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
58+
|
59+
= note: #[warn(no_mangle_generic_items)] on by default
60+
61+
warning: function is marked #[no_mangle], but not exported
62+
--> $DIR/suggestions.rs:21:1
63+
|
64+
21 | fn rio_grande() {} // should suggest `pub`
65+
| -^^^^^^^^^^^^^^^^^
66+
| |
67+
| help: try making it public: `pub `
68+
|
69+
= note: #[warn(private_no_mangle_fns)] on by default
70+
3171
warning: denote infinite loops with `loop { ... }`
32-
--> $DIR/suggestions.rs:16:5
72+
--> $DIR/suggestions.rs:29:5
3373
|
34-
16 | while true { // should suggest `loop`
74+
29 | while true { // should suggest `loop`
3575
| ^---------
3676
| |
3777
| _____help: use `loop`
3878
| |
39-
17 | | let mut a = (1); // should suggest no `mut`, no parens
40-
18 | | println!("{}", a);
41-
19 | | }
79+
30 | | let mut a = (1); // should suggest no `mut`, no parens
80+
31 | | let d = Equinox { warp_factor: 9.975 };
81+
32 | | match d {
82+
... |
83+
35 | | println!("{}", a);
84+
36 | | }
4285
| |_____^
4386
|
4487
= note: #[warn(while_true)] on by default
4588

89+
warning: the `warp_factor:` in this pattern is redundant
90+
--> $DIR/suggestions.rs:33:23
91+
|
92+
33 | Equinox { warp_factor: warp_factor } => {} // should suggest shorthand
93+
| ------------^^^^^^^^^^^^
94+
| |
95+
| help: remove this
96+
|
97+
= note: #[warn(non_shorthand_field_patterns)] on by default
98+
99+
error: aborting due to previous error
100+

0 commit comments

Comments
 (0)