Skip to content

Commit

Permalink
Rollup merge of rust-lang#65507 - polyedre:master, r=nikomatsakis
Browse files Browse the repository at this point in the history
Fix test style in unused parentheses lint test

I think this fixes rust-lang#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](rust-lang#63257) but it was marked as closed for inactivity.

r?  @nikomatsakis
  • Loading branch information
JohnTitor authored Oct 23, 2019
2 parents 557d276 + 95d98af commit 1dbb010
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 754 deletions.
7 changes: 3 additions & 4 deletions src/test/ui/lint/unused_parens_json_suggestion.fixed
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// compile-flags: --error-format pretty-json -Zunstable-options
// build-pass (FIXME(62277): could be check-pass?)
// compile-flags: --error-format json -Zunstable-options
// run-rustfix

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

#![warn(unused_parens)]
#![deny(unused_parens)]
#![allow(unreachable_code)]

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

Expand Down
7 changes: 3 additions & 4 deletions src/test/ui/lint/unused_parens_json_suggestion.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// compile-flags: --error-format pretty-json -Zunstable-options
// build-pass (FIXME(62277): could be check-pass?)
// compile-flags: --error-format json -Zunstable-options
// run-rustfix

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

#![warn(unused_parens)]
#![deny(unused_parens)]
#![allow(unreachable_code)]

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

Expand Down
106 changes: 8 additions & 98 deletions src/test/ui/lint/unused_parens_json_suggestion.stderr
Original file line number Diff line number Diff line change
@@ -1,106 +1,16 @@
{
"message": "unnecessary parentheses around assigned value",
"code": {
"code": "unused_parens",
"explanation": null
},
"level": "warning",
"spans": [
{
"file_name": "$DIR/unused_parens_json_suggestion.rs",
"byte_start": 654,
"byte_end": 667,
"line_start": 17,
"line_end": 17,
"column_start": 14,
"column_end": 27,
"is_primary": true,
"text": [
{
"text": " let _a = (1 / (2 + 3));",
"highlight_start": 14,
"highlight_end": 27
}
],
"label": null,
"suggested_replacement": null,
"suggestion_applicability": null,
"expansion": null
}
],
"children": [
{
"message": "lint level defined here",
"code": null,
"level": "note",
"spans": [
{
"file_name": "$DIR/unused_parens_json_suggestion.rs",
"byte_start": 472,
"byte_end": 485,
"line_start": 11,
"line_end": 11,
"column_start": 9,
"column_end": 22,
"is_primary": true,
"text": [
{
"text": "#![warn(unused_parens)]",
"highlight_start": 9,
"highlight_end": 22
}
],
"label": null,
"suggested_replacement": null,
"suggestion_applicability": null,
"expansion": null
}
],
"children": [],
"rendered": null
},
{
"message": "remove these parentheses",
"code": null,
"level": "help",
"spans": [
{
"file_name": "$DIR/unused_parens_json_suggestion.rs",
"byte_start": 654,
"byte_end": 667,
"line_start": 17,
"line_end": 17,
"column_start": 14,
"column_end": 27,
"is_primary": true,
"text": [
{
"text": " let _a = (1 / (2 + 3));",
"highlight_start": 14,
"highlight_end": 27
}
],
"label": null,
"suggested_replacement": "1 / (2 + 3)",
"suggestion_applicability": "MachineApplicable",
"expansion": null
}
],
"children": [],
"rendered": null
}
],
"rendered": "warning: unnecessary parentheses around assigned value
--> $DIR/unused_parens_json_suggestion.rs:17:14
{"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));
--> $DIR/unused_parens_json_suggestion.rs:16:14
|
LL | let _a = (1 / (2 + 3));
| ^^^^^^^^^^^^^ help: remove these parentheses
|
note: lint level defined here
--> $DIR/unused_parens_json_suggestion.rs:11:9
--> $DIR/unused_parens_json_suggestion.rs:10:9
|
LL | #![warn(unused_parens)]
LL | #![deny(unused_parens)]
| ^^^^^^^^^^^^^

"
}
"}
{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error

"}
21 changes: 10 additions & 11 deletions src/test/ui/lint/unused_parens_remove_json_suggestion.fixed
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// compile-flags: --error-format pretty-json -Zunstable-options
// build-pass
// compile-flags: --error-format json -Zunstable-options
// run-rustfix

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

#![warn(unused_parens)]
#![deny(unused_parens)]
#![allow(unreachable_code)]

fn main() {

let _b = false;

if _b {
if _b { //~ ERROR unnecessary parentheses
println!("hello");
}

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

if c {
if c { //~ ERROR unnecessary parentheses
println!("next");
}

if c {
if c { //~ ERROR unnecessary parentheses
println!("prev");
}

while false && true {
if c {
if c { //~ ERROR unnecessary parentheses
println!("norm");
}

}

while true && false {
for _ in 0 .. 3 {
while true && false { //~ ERROR unnecessary parentheses
for _ in 0 .. 3 { //~ ERROR unnecessary parentheses
println!("e~")
}
}

for _ in 0 .. 3 {
while true && false {
for _ in 0 .. 3 { //~ ERROR unnecessary parentheses
while true && false { //~ ERROR unnecessary parentheses
println!("e~")
}
}
Expand Down
21 changes: 10 additions & 11 deletions src/test/ui/lint/unused_parens_remove_json_suggestion.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// compile-flags: --error-format pretty-json -Zunstable-options
// build-pass
// compile-flags: --error-format json -Zunstable-options
// run-rustfix

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

#![warn(unused_parens)]
#![deny(unused_parens)]
#![allow(unreachable_code)]

fn main() {

let _b = false;

if (_b) {
if (_b) { //~ ERROR unnecessary parentheses
println!("hello");
}

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

if(c) {
if(c) { //~ ERROR unnecessary parentheses
println!("next");
}

if (c){
if (c){ //~ ERROR unnecessary parentheses
println!("prev");
}

while (false && true){
if (c) {
if (c) { //~ ERROR unnecessary parentheses
println!("norm");
}

}

while(true && false) {
for _ in (0 .. 3){
while(true && false) { //~ ERROR unnecessary parentheses
for _ in (0 .. 3){ //~ ERROR unnecessary parentheses
println!("e~")
}
}

for _ in (0 .. 3) {
while (true && false) {
for _ in (0 .. 3) { //~ ERROR unnecessary parentheses
while (true && false) { //~ ERROR unnecessary parentheses
println!("e~")
}
}
Expand Down
Loading

0 comments on commit 1dbb010

Please sign in to comment.