backticks and testcase

This commit is contained in:
daubaris 2018-09-03 18:24:38 +03:00
parent 1615a8a2b6
commit b825578a4a
3 changed files with 10 additions and 3 deletions

View File

@ -52,7 +52,7 @@ declare_clippy_lint! {
/// **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)).
/// I.e: `let _ = (f()+1)..(f()+1)` results in `let _ = ((f()+1)..(f()+1))`.
///
/// **Example:**
/// ```rust

View File

@ -27,6 +27,7 @@ fn main() {
let _ = ..11-1;
let _ = ..=11-1;
let _ = ..=(11-1);
let _ = (1..11+1);
let _ = (f()+1)..(f()+1);
let mut vec: Vec<()> = std::vec::Vec::new();

View File

@ -41,8 +41,14 @@ error: an exclusive range would be more readable
error: an inclusive range would be more readable
--> $DIR/range_plus_minus_one.rs:30:13
|
28 | let _ = (f()+1)..(f()+1);
30 | let _ = (1..11+1);
| ^^^^^^^^^ help: use: `(1..=11)`
error: an inclusive range would be more readable
--> $DIR/range_plus_minus_one.rs:31:13
|
31 | let _ = (f()+1)..(f()+1);
| ^^^^^^^^^^^^^^^^ help: use: `((f()+1)..=f())`
error: aborting due to 7 previous errors
error: aborting due to 8 previous errors