Skip to content

Commit

Permalink
Add rustfix test and fix test name.
Browse files Browse the repository at this point in the history
  • Loading branch information
bravomikekilo committed Aug 6, 2019
1 parent 4c1d892 commit 3a95c71
Show file tree
Hide file tree
Showing 6 changed files with 220 additions and 127 deletions.
27 changes: 27 additions & 0 deletions src/test/ui/lint/unused_parens_json_suggestion.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// compile-flags: --error-format pretty-json -Zunstable-options
// build-pass (FIXME(62277): could be check-pass?)
// run-rustfix

// The output for humans should just highlight the whole span without showing
// the suggested replacement, but we also want to test that suggested
// replacement only removes one set of parentheses, rather than naïvely
// stripping away any starting or ending parenthesis characters—hence this
// test of the JSON error format.

#![warn(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);
f();
}

fn f() -> bool {
loop {
if (break { return true }) {
}
}
false
}
2 changes: 2 additions & 0 deletions src/test/ui/lint/unused_parens_json_suggestion.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// compile-flags: --error-format pretty-json -Zunstable-options
// build-pass (FIXME(62277): could be check-pass?)
// run-rustfix

// The output for humans should just highlight the whole span without showing
// the suggested replacement, but we also want to test that suggested
Expand All @@ -8,6 +9,7 @@
// test of the JSON error format.

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

fn main() {
// We want to suggest the properly-balanced expression `1 / (2 + 3)`, not
Expand Down
28 changes: 14 additions & 14 deletions src/test/ui/lint/unused_parens_json_suggestion.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"spans": [
{
"file_name": "$DIR/unused_parens_json_suggestion.rs",
"byte_start": 611,
"byte_end": 624,
"line_start": 15,
"line_end": 15,
"byte_start": 654,
"byte_end": 667,
"line_start": 17,
"line_end": 17,
"column_start": 14,
"column_end": 27,
"is_primary": true,
Expand All @@ -36,10 +36,10 @@
"spans": [
{
"file_name": "$DIR/unused_parens_json_suggestion.rs",
"byte_start": 457,
"byte_end": 470,
"line_start": 10,
"line_end": 10,
"byte_start": 472,
"byte_end": 485,
"line_start": 11,
"line_end": 11,
"column_start": 9,
"column_end": 22,
"is_primary": true,
Expand All @@ -66,10 +66,10 @@
"spans": [
{
"file_name": "$DIR/unused_parens_json_suggestion.rs",
"byte_start": 611,
"byte_end": 624,
"line_start": 15,
"line_end": 15,
"byte_start": 654,
"byte_end": 667,
"line_start": 17,
"line_end": 17,
"column_start": 14,
"column_end": 27,
"is_primary": true,
Expand All @@ -91,13 +91,13 @@
}
],
"rendered": "warning: unnecessary parentheses around assigned value
--> $DIR/unused_parens_json_suggestion.rs:15:14
--> $DIR/unused_parens_json_suggestion.rs:17:14
|
LL | let _a = (1 / (2 + 3));
| ^^^^^^^^^^^^^ help: remove these parentheses
|
note: lint level defined here
--> $DIR/unused_parens_json_suggestion.rs:10:9
--> $DIR/unused_parens_json_suggestion.rs:11:9
|
LL | #![warn(unused_parens)]
| ^^^^^^^^^^^^^
Expand Down
62 changes: 62 additions & 0 deletions src/test/ui/lint/unused_parens_remove_json_suggestion.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// compile-flags: --error-format pretty-json -Zunstable-options
// build-pass
// run-rustfix

// The output for humans should just highlight the whole span without showing
// the suggested replacement, but we also want to test that suggested
// replacement only removes one set of parentheses, rather than naïvely
// stripping away any starting or ending parenthesis characters—hence this
// test of the JSON error format.

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

fn main() {

let _b = false;

if _b {
println!("hello");
}

f();

}

fn f() -> bool {
let c = false;

if c {
println!("next");
}

if c {
println!("prev");
}

while false && true {
if c {
println!("norm");
}

}

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

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


loop {
if (break { return true }) {
}
}
false
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// compile-flags: --error-format pretty-json -Zunstable-options
// build-pass
// run-rustfix

// The output for humans should just highlight the whole span without showing
// the suggested replacement, but we also want to test that suggested
Expand All @@ -8,6 +9,7 @@
// test of the JSON error format.

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

fn main() {

Expand Down Expand Up @@ -40,12 +42,12 @@ fn f() -> bool {
}

while(true && false) {
for i in (0 .. 3){
for _ in (0 .. 3){
println!("e~")
}
}

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

0 comments on commit 3a95c71

Please sign in to comment.