-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
range_plus_one suggestion should not remove braces fix #3108
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution and welcome to Clippy! Dogfood test currently fails on your code.
clippy_lints/src/ranges.rs
Outdated
/// **Known problems:** Will add unnecessary pair of parentheses when the | ||
/// expression is not wrapped in a pair but starts with a opening parenthesis | ||
/// and ends with a closing one. | ||
/// I.e: let _ = (f()+1)..(f()+1) results in let _ = ((f()+1)..(f()+1)). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backticks "`" around code missing. "results in let _ = ((f()+1)..=f())
"
tests/ui/range_plus_minus_one.stderr
Outdated
@@ -42,7 +42,7 @@ error: an inclusive range would be more readable | |||
--> $DIR/range_plus_minus_one.rs:28:13 | |||
| | |||
28 | let _ = (f()+1)..(f()+1); | |||
| ^^^^^^^^^^^^^^^^ help: use: `(f()+1)..=f()` | |||
| ^^^^^^^^^^^^^^^^ help: use: `((f()+1)..=f())` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add another test especially for the issue #3103 .
clippy_lints/src/ranges.rs
Outdated
/// **Known problems:** Will add unnecessary pair of parentheses when the | ||
/// expression is not wrapped in a pair but starts with a opening parenthesis | ||
/// and ends with a closing one. | ||
/// I.e: `let _ = (f()+1)..(f()+1)` results in `let _ = ((f()+1)..(f()+1))`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second let _ = ((f()+1)..(f()+1))
should be let _ = ((f()+1)..=f())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dogfood test is still failing.
https://travis-ci.org/rust-lang-nursery/rust-clippy/jobs/424066517#L1330-L1345
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Appveyor failure is unrelated #3118
Hi! Could you leave the requested comment in #3230 for relicensing? |
Looking into #3103 decided to go with the first suggestion.
#3103 (comment)
Added information to the known problems that lint adds unnecessary parentheses if the expression is not wrapped in a pair but starts with a opening parenthesis and ends with a closing one.