Skip to content

Commit b825578

Browse files
committed
backticks and testcase
1 parent 1615a8a commit b825578

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

clippy_lints/src/ranges.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ declare_clippy_lint! {
5252
/// **Known problems:** Will add unnecessary pair of parentheses when the
5353
/// expression is not wrapped in a pair but starts with a opening parenthesis
5454
/// and ends with a closing one.
55-
/// I.e: let _ = (f()+1)..(f()+1) results in let _ = ((f()+1)..(f()+1)).
55+
/// I.e: `let _ = (f()+1)..(f()+1)` results in `let _ = ((f()+1)..(f()+1))`.
5656
///
5757
/// **Example:**
5858
/// ```rust

tests/ui/range_plus_minus_one.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ fn main() {
2727
let _ = ..11-1;
2828
let _ = ..=11-1;
2929
let _ = ..=(11-1);
30+
let _ = (1..11+1);
3031
let _ = (f()+1)..(f()+1);
3132

3233
let mut vec: Vec<()> = std::vec::Vec::new();

tests/ui/range_plus_minus_one.stderr

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,14 @@ error: an exclusive range would be more readable
4141
error: an inclusive range would be more readable
4242
--> $DIR/range_plus_minus_one.rs:30:13
4343
|
44-
28 | let _ = (f()+1)..(f()+1);
44+
30 | let _ = (1..11+1);
45+
| ^^^^^^^^^ help: use: `(1..=11)`
46+
47+
error: an inclusive range would be more readable
48+
--> $DIR/range_plus_minus_one.rs:31:13
49+
|
50+
31 | let _ = (f()+1)..(f()+1);
4551
| ^^^^^^^^^^^^^^^^ help: use: `((f()+1)..=f())`
4652

47-
error: aborting due to 7 previous errors
53+
error: aborting due to 8 previous errors
4854

0 commit comments

Comments
 (0)