From b825578a4a1049f0a29205e35c61f0f47e3ae6dc Mon Sep 17 00:00:00 2001 From: daubaris Date: Mon, 3 Sep 2018 18:24:38 +0300 Subject: [PATCH] backticks and testcase --- clippy_lints/src/ranges.rs | 2 +- tests/ui/range_plus_minus_one.rs | 1 + tests/ui/range_plus_minus_one.stderr | 10 ++++++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs index c69a0943b17..db2fbbad876 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -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 diff --git a/tests/ui/range_plus_minus_one.rs b/tests/ui/range_plus_minus_one.rs index 12a1312de36..1ee3637f266 100644 --- a/tests/ui/range_plus_minus_one.rs +++ b/tests/ui/range_plus_minus_one.rs @@ -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(); diff --git a/tests/ui/range_plus_minus_one.stderr b/tests/ui/range_plus_minus_one.stderr index 1c0d8906caa..3fe4e7ca073 100644 --- a/tests/ui/range_plus_minus_one.stderr +++ b/tests/ui/range_plus_minus_one.stderr @@ -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