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 11// compile-flags: --error-format pretty-json -Zunstable-options
22// build-pass (FIXME(62277): could be check-pass?)
3+ // run-rustfix
34
45// The output for humans should just highlight the whole span without showing
56// the suggested replacement, but we also want to test that suggested
89// test of the JSON error format.
910
1011#![ warn( unused_parens) ]
12+ #![ allow( unreachable_code) ]
1113
1214fn main ( ) {
1315 // We want to suggest the properly-balanced expression `1 / (2 + 3)`, not
Original file line number Diff line number Diff line change 88 "spans": [
99 {
1010 "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 ,
1515 "column_start": 14,
1616 "column_end": 27,
1717 "is_primary": true,
3636 "spans": [
3737 {
3838 "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 ,
4343 "column_start": 9,
4444 "column_end": 22,
4545 "is_primary": true,
6666 "spans": [
6767 {
6868 "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 ,
7373 "column_start": 14,
7474 "column_end": 27,
7575 "is_primary": true,
9191 }
9292 ],
9393 "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
9595 |
9696LL | let _a = (1 / (2 + 3));
9797 | ^^^^^^^^^^^^^ help: remove these parentheses
9898 |
9999note: lint level defined here
100- --> $DIR/unused_parens_json_suggestion.rs:10 :9
100+ --> $DIR/unused_parens_json_suggestion.rs:11 :9
101101 |
102102LL | #![warn(unused_parens)]
103103 | ^^^^^^^^^^^^^
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 11// compile-flags: --error-format pretty-json -Zunstable-options
22// build-pass
3+ // run-rustfix
34
45// The output for humans should just highlight the whole span without showing
56// the suggested replacement, but we also want to test that suggested
89// test of the JSON error format.
910
1011#![ warn( unused_parens) ]
12+ #![ allow( unreachable_code) ]
1113
1214fn main ( ) {
1315
@@ -40,12 +42,12 @@ fn f() -> bool {
4042 }
4143
4244 while ( true && false ) {
43- for i in ( 0 .. 3 ) {
45+ for _ in ( 0 .. 3 ) {
4446 println ! ( "e~" )
4547 }
4648 }
4749
48- for i in ( 0 .. 3 ) {
50+ for _ in ( 0 .. 3 ) {
4951 while ( true && false ) {
5052 println ! ( "e~" )
5153 }
You can’t perform that action at this time.
0 commit comments