forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#63163 - bravomikekilo:master, r=cramertj
add a pair of whitespace after remove parentheses fix [issue-63156](rust-lang#63156). add a pair of whitespace after remove parentheses.
- Loading branch information
Showing
7 changed files
with
916 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/test/ui/lint/unused_parens_remove_json_suggestion.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.