This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +220
-127
lines changed Expand file tree Collapse file tree 6 files changed +220
-127
lines changed Original file line number Diff line number Diff line change
1
+ // compile-flags: --error-format pretty-json -Zunstable-options
2
+ // build-pass (FIXME(62277): could be check-pass?)
3
+ // run-rustfix
4
+
5
+ // The output for humans should just highlight the whole span without showing
6
+ // the suggested replacement, but we also want to test that suggested
7
+ // replacement only removes one set of parentheses, rather than naïvely
8
+ // stripping away any starting or ending parenthesis characters—hence this
9
+ // test of the JSON error format.
10
+
11
+ #![warn(unused_parens)]
12
+ #![allow(unreachable_code)]
13
+
14
+ fn main() {
15
+ // We want to suggest the properly-balanced expression `1 / (2 + 3)`, not
16
+ // the malformed `1 / (2 + 3`
17
+ let _a = 1 / (2 + 3);
18
+ f();
19
+ }
20
+
21
+ fn f() -> bool {
22
+ loop {
23
+ if (break { return true }) {
24
+ }
25
+ }
26
+ false
27
+ }
Original file line number Diff line number Diff line change 1
1
// compile-flags: --error-format pretty-json -Zunstable-options
2
2
// build-pass (FIXME(62277): could be check-pass?)
3
+ // run-rustfix
3
4
4
5
// The output for humans should just highlight the whole span without showing
5
6
// the suggested replacement, but we also want to test that suggested
8
9
// test of the JSON error format.
9
10
10
11
#![ warn( unused_parens) ]
12
+ #![ allow( unreachable_code) ]
11
13
12
14
fn main ( ) {
13
15
// We want to suggest the properly-balanced expression `1 / (2 + 3)`, not
Original file line number Diff line number Diff line change 8
8
"spans": [
9
9
{
10
10
"file_name": "$DIR/unused_parens_json_suggestion.rs",
11
- "byte_start": 611 ,
12
- "byte_end": 624 ,
13
- "line_start": 15 ,
14
- "line_end": 15 ,
11
+ "byte_start": 654 ,
12
+ "byte_end": 667 ,
13
+ "line_start": 17 ,
14
+ "line_end": 17 ,
15
15
"column_start": 14,
16
16
"column_end": 27,
17
17
"is_primary": true,
36
36
"spans": [
37
37
{
38
38
"file_name": "$DIR/unused_parens_json_suggestion.rs",
39
- "byte_start": 457 ,
40
- "byte_end": 470 ,
41
- "line_start": 10 ,
42
- "line_end": 10 ,
39
+ "byte_start": 472 ,
40
+ "byte_end": 485 ,
41
+ "line_start": 11 ,
42
+ "line_end": 11 ,
43
43
"column_start": 9,
44
44
"column_end": 22,
45
45
"is_primary": true,
66
66
"spans": [
67
67
{
68
68
"file_name": "$DIR/unused_parens_json_suggestion.rs",
69
- "byte_start": 611 ,
70
- "byte_end": 624 ,
71
- "line_start": 15 ,
72
- "line_end": 15 ,
69
+ "byte_start": 654 ,
70
+ "byte_end": 667 ,
71
+ "line_start": 17 ,
72
+ "line_end": 17 ,
73
73
"column_start": 14,
74
74
"column_end": 27,
75
75
"is_primary": true,
91
91
}
92
92
],
93
93
"rendered": "warning: unnecessary parentheses around assigned value
94
- --> $DIR/unused_parens_json_suggestion.rs:15 :14
94
+ --> $DIR/unused_parens_json_suggestion.rs:17 :14
95
95
|
96
96
LL | let _a = (1 / (2 + 3));
97
97
| ^^^^^^^^^^^^^ help: remove these parentheses
98
98
|
99
99
note: lint level defined here
100
- --> $DIR/unused_parens_json_suggestion.rs:10 :9
100
+ --> $DIR/unused_parens_json_suggestion.rs:11 :9
101
101
|
102
102
LL | #![warn(unused_parens)]
103
103
| ^^^^^^^^^^^^^
Original file line number Diff line number Diff line change
1
+ // compile-flags: --error-format pretty-json -Zunstable-options
2
+ // build-pass
3
+ // run-rustfix
4
+
5
+ // The output for humans should just highlight the whole span without showing
6
+ // the suggested replacement, but we also want to test that suggested
7
+ // replacement only removes one set of parentheses, rather than naïvely
8
+ // stripping away any starting or ending parenthesis characters—hence this
9
+ // test of the JSON error format.
10
+
11
+ #![warn(unused_parens)]
12
+ #![allow(unreachable_code)]
13
+
14
+ fn main() {
15
+
16
+ let _b = false;
17
+
18
+ if _b {
19
+ println!("hello");
20
+ }
21
+
22
+ f();
23
+
24
+ }
25
+
26
+ fn f() -> bool {
27
+ let c = false;
28
+
29
+ if c {
30
+ println!("next");
31
+ }
32
+
33
+ if c {
34
+ println!("prev");
35
+ }
36
+
37
+ while false && true {
38
+ if c {
39
+ println!("norm");
40
+ }
41
+
42
+ }
43
+
44
+ while true && false {
45
+ for _ in 0 .. 3 {
46
+ println!("e~")
47
+ }
48
+ }
49
+
50
+ for _ in 0 .. 3 {
51
+ while true && false {
52
+ println!("e~")
53
+ }
54
+ }
55
+
56
+
57
+ loop {
58
+ if (break { return true }) {
59
+ }
60
+ }
61
+ false
62
+ }
Original file line number Diff line number Diff line change 1
1
// compile-flags: --error-format pretty-json -Zunstable-options
2
2
// build-pass
3
+ // run-rustfix
3
4
4
5
// The output for humans should just highlight the whole span without showing
5
6
// the suggested replacement, but we also want to test that suggested
8
9
// test of the JSON error format.
9
10
10
11
#![ warn( unused_parens) ]
12
+ #![ allow( unreachable_code) ]
11
13
12
14
fn main ( ) {
13
15
@@ -40,12 +42,12 @@ fn f() -> bool {
40
42
}
41
43
42
44
while ( true && false ) {
43
- for i in ( 0 .. 3 ) {
45
+ for _ in ( 0 .. 3 ) {
44
46
println ! ( "e~" )
45
47
}
46
48
}
47
49
48
- for i in ( 0 .. 3 ) {
50
+ for _ in ( 0 .. 3 ) {
49
51
while ( true && false ) {
50
52
println ! ( "e~" )
51
53
}
You can’t perform that action at this time.
0 commit comments