Skip to content

Commit 298a1fa

Browse files
committed
Move range_minus_one to pedantic
This moves the range_minus_one lint to the pedantic category, so there will not be any warnings emitted by default. This should work around problems where the suggestion is impossible to resolve due to the range consumer only accepting a specific range implementation, rather than the `RangeBounds` trait (see rust-lang#3307). While it is possible to work around this by extracting the boundary into a variable, I don't think clippy should encourage people to disable or work around lints, but instead the lints should be fixable. So hopefully this will help until a proper implementation checks what the range is used for.
1 parent be88122 commit 298a1fa

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

clippy_lints/src/ranges.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ declare_clippy_lint! {
5252
/// exclusive ranges, because they essentially add an extra branch that
5353
/// LLVM may fail to hoist out of the loop.
5454
///
55+
/// This will cause a warning that cannot be fixed if the consumer of the
56+
/// range only accepts a specific range type, instead of the generic
57+
/// `RangeBounds` trait
58+
/// ([#3307](https://github.com/rust-lang/rust-clippy/issues/3307)).
59+
///
5560
/// **Example:**
5661
/// ```rust,ignore
5762
/// for x..(y+1) { .. }
@@ -72,7 +77,10 @@ declare_clippy_lint! {
7277
/// **Why is this bad?** The code is more readable with an exclusive range
7378
/// like `x..y`.
7479
///
75-
/// **Known problems:** None.
80+
/// **Known problems:** This will cause a warning that cannot be fixed if
81+
/// the consumer of the range only accepts a specific range type, instead of
82+
/// the generic `RangeBounds` trait
83+
/// ([#3307](https://github.com/rust-lang/rust-clippy/issues/3307)).
7684
///
7785
/// **Example:**
7886
/// ```rust,ignore
@@ -83,7 +91,7 @@ declare_clippy_lint! {
8391
/// for x..y { .. }
8492
/// ```
8593
pub RANGE_MINUS_ONE,
86-
complexity,
94+
pedantic,
8795
"`x..=(y-1)` reads better as `x..y`"
8896
}
8997

0 commit comments

Comments
 (0)