Skip to content

Commit 1dbb010

Browse files
authored
Rollup merge of #65507 - polyedre:master, r=nikomatsakis
Fix test style in unused parentheses lint test I think this fixes #63237 I'm not sure if I had to add text after the `//~ ERROR` comments. This is my first pull request, so I'm open to feedback. This issues already received one pull request [here](#63257) but it was marked as closed for inactivity. r? @nikomatsakis
2 parents 557d276 + 95d98af commit 1dbb010

6 files changed

+66
-754
lines changed

src/test/ui/lint/unused_parens_json_suggestion.fixed

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// compile-flags: --error-format pretty-json -Zunstable-options
2-
// build-pass (FIXME(62277): could be check-pass?)
1+
// compile-flags: --error-format json -Zunstable-options
32
// run-rustfix
43

54
// The output for humans should just highlight the whole span without showing
@@ -8,13 +7,13 @@
87
// stripping away any starting or ending parenthesis characters—hence this
98
// test of the JSON error format.
109

11-
#![warn(unused_parens)]
10+
#![deny(unused_parens)]
1211
#![allow(unreachable_code)]
1312

1413
fn main() {
1514
// We want to suggest the properly-balanced expression `1 / (2 + 3)`, not
1615
// the malformed `1 / (2 + 3`
17-
let _a = 1 / (2 + 3);
16+
let _a = 1 / (2 + 3); //~ERROR unnecessary parentheses
1817
f();
1918
}
2019

src/test/ui/lint/unused_parens_json_suggestion.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// compile-flags: --error-format pretty-json -Zunstable-options
2-
// build-pass (FIXME(62277): could be check-pass?)
1+
// compile-flags: --error-format json -Zunstable-options
32
// run-rustfix
43

54
// The output for humans should just highlight the whole span without showing
@@ -8,13 +7,13 @@
87
// stripping away any starting or ending parenthesis characters—hence this
98
// test of the JSON error format.
109

11-
#![warn(unused_parens)]
10+
#![deny(unused_parens)]
1211
#![allow(unreachable_code)]
1312

1413
fn main() {
1514
// We want to suggest the properly-balanced expression `1 / (2 + 3)`, not
1615
// the malformed `1 / (2 + 3`
17-
let _a = (1 / (2 + 3));
16+
let _a = (1 / (2 + 3)); //~ERROR unnecessary parentheses
1817
f();
1918
}
2019

Original file line numberDiff line numberDiff line change
@@ -1,106 +1,16 @@
1-
{
2-
"message": "unnecessary parentheses around assigned value",
3-
"code": {
4-
"code": "unused_parens",
5-
"explanation": null
6-
},
7-
"level": "warning",
8-
"spans": [
9-
{
10-
"file_name": "$DIR/unused_parens_json_suggestion.rs",
11-
"byte_start": 654,
12-
"byte_end": 667,
13-
"line_start": 17,
14-
"line_end": 17,
15-
"column_start": 14,
16-
"column_end": 27,
17-
"is_primary": true,
18-
"text": [
19-
{
20-
"text": " let _a = (1 / (2 + 3));",
21-
"highlight_start": 14,
22-
"highlight_end": 27
23-
}
24-
],
25-
"label": null,
26-
"suggested_replacement": null,
27-
"suggestion_applicability": null,
28-
"expansion": null
29-
}
30-
],
31-
"children": [
32-
{
33-
"message": "lint level defined here",
34-
"code": null,
35-
"level": "note",
36-
"spans": [
37-
{
38-
"file_name": "$DIR/unused_parens_json_suggestion.rs",
39-
"byte_start": 472,
40-
"byte_end": 485,
41-
"line_start": 11,
42-
"line_end": 11,
43-
"column_start": 9,
44-
"column_end": 22,
45-
"is_primary": true,
46-
"text": [
47-
{
48-
"text": "#![warn(unused_parens)]",
49-
"highlight_start": 9,
50-
"highlight_end": 22
51-
}
52-
],
53-
"label": null,
54-
"suggested_replacement": null,
55-
"suggestion_applicability": null,
56-
"expansion": null
57-
}
58-
],
59-
"children": [],
60-
"rendered": null
61-
},
62-
{
63-
"message": "remove these parentheses",
64-
"code": null,
65-
"level": "help",
66-
"spans": [
67-
{
68-
"file_name": "$DIR/unused_parens_json_suggestion.rs",
69-
"byte_start": 654,
70-
"byte_end": 667,
71-
"line_start": 17,
72-
"line_end": 17,
73-
"column_start": 14,
74-
"column_end": 27,
75-
"is_primary": true,
76-
"text": [
77-
{
78-
"text": " let _a = (1 / (2 + 3));",
79-
"highlight_start": 14,
80-
"highlight_end": 27
81-
}
82-
],
83-
"label": null,
84-
"suggested_replacement": "1 / (2 + 3)",
85-
"suggestion_applicability": "MachineApplicable",
86-
"expansion": null
87-
}
88-
],
89-
"children": [],
90-
"rendered": null
91-
}
92-
],
93-
"rendered": "warning: unnecessary parentheses around assigned value
94-
--> $DIR/unused_parens_json_suggestion.rs:17:14
1+
{"message":"unnecessary parentheses around assigned value","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_json_suggestion.rs","byte_start":596,"byte_end":609,"line_start":16,"line_end":16,"column_start":14,"column_end":27,"is_primary":true,"text":[{"text":" let _a = (1 / (2 + 3));
2+
--> $DIR/unused_parens_json_suggestion.rs:16:14
953
|
964
LL | let _a = (1 / (2 + 3));
975
| ^^^^^^^^^^^^^ help: remove these parentheses
986
|
997
note: lint level defined here
100-
--> $DIR/unused_parens_json_suggestion.rs:11:9
8+
--> $DIR/unused_parens_json_suggestion.rs:10:9
1019
|
102-
LL | #![warn(unused_parens)]
10+
LL | #![deny(unused_parens)]
10311
| ^^^^^^^^^^^^^
10412

105-
"
106-
}
13+
"}
14+
{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error
15+
16+
"}

src/test/ui/lint/unused_parens_remove_json_suggestion.fixed

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// compile-flags: --error-format pretty-json -Zunstable-options
2-
// build-pass
1+
// compile-flags: --error-format json -Zunstable-options
32
// run-rustfix
43

54
// The output for humans should just highlight the whole span without showing
@@ -8,14 +7,14 @@
87
// stripping away any starting or ending parenthesis characters—hence this
98
// test of the JSON error format.
109

11-
#![warn(unused_parens)]
10+
#![deny(unused_parens)]
1211
#![allow(unreachable_code)]
1312

1413
fn main() {
1514

1615
let _b = false;
1716

18-
if _b {
17+
if _b { //~ ERROR unnecessary parentheses
1918
println!("hello");
2019
}
2120

@@ -26,29 +25,29 @@ fn main() {
2625
fn f() -> bool {
2726
let c = false;
2827

29-
if c {
28+
if c { //~ ERROR unnecessary parentheses
3029
println!("next");
3130
}
3231

33-
if c {
32+
if c { //~ ERROR unnecessary parentheses
3433
println!("prev");
3534
}
3635

3736
while false && true {
38-
if c {
37+
if c { //~ ERROR unnecessary parentheses
3938
println!("norm");
4039
}
4140

4241
}
4342

44-
while true && false {
45-
for _ in 0 .. 3 {
43+
while true && false { //~ ERROR unnecessary parentheses
44+
for _ in 0 .. 3 { //~ ERROR unnecessary parentheses
4645
println!("e~")
4746
}
4847
}
4948

50-
for _ in 0 .. 3 {
51-
while true && false {
49+
for _ in 0 .. 3 { //~ ERROR unnecessary parentheses
50+
while true && false { //~ ERROR unnecessary parentheses
5251
println!("e~")
5352
}
5453
}

src/test/ui/lint/unused_parens_remove_json_suggestion.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// compile-flags: --error-format pretty-json -Zunstable-options
2-
// build-pass
1+
// compile-flags: --error-format json -Zunstable-options
32
// run-rustfix
43

54
// The output for humans should just highlight the whole span without showing
@@ -8,14 +7,14 @@
87
// stripping away any starting or ending parenthesis characters—hence this
98
// test of the JSON error format.
109

11-
#![warn(unused_parens)]
10+
#![deny(unused_parens)]
1211
#![allow(unreachable_code)]
1312

1413
fn main() {
1514

1615
let _b = false;
1716

18-
if (_b) {
17+
if (_b) { //~ ERROR unnecessary parentheses
1918
println!("hello");
2019
}
2120

@@ -26,29 +25,29 @@ fn main() {
2625
fn f() -> bool {
2726
let c = false;
2827

29-
if(c) {
28+
if(c) { //~ ERROR unnecessary parentheses
3029
println!("next");
3130
}
3231

33-
if (c){
32+
if (c){ //~ ERROR unnecessary parentheses
3433
println!("prev");
3534
}
3635

3736
while (false && true){
38-
if (c) {
37+
if (c) { //~ ERROR unnecessary parentheses
3938
println!("norm");
4039
}
4140

4241
}
4342

44-
while(true && false) {
45-
for _ in (0 .. 3){
43+
while(true && false) { //~ ERROR unnecessary parentheses
44+
for _ in (0 .. 3){ //~ ERROR unnecessary parentheses
4645
println!("e~")
4746
}
4847
}
4948

50-
for _ in (0 .. 3) {
51-
while (true && false) {
49+
for _ in (0 .. 3) { //~ ERROR unnecessary parentheses
50+
while (true && false) { //~ ERROR unnecessary parentheses
5251
println!("e~")
5352
}
5453
}

0 commit comments

Comments
 (0)