Open
Description
The range_plus_one
lint suggests replacing Range
syntax with RangeInclusive
syntax. That's fine if you're immediately going to loop. But it's invalid if the Range
in question is going to be assigned to a variable of type Range
. For example, clippy will suggest replacing this code:
struct Foo {
r: Range<u32>
}
fn bar() {
let x = 0;
let foo = Foo{r: x..x+1};
}
with this:
struct Foo {
r: Range<u32>
}
fn bar() {
let x = 0;
let foo = Foo{r: x..=x};
}
But that fails to compile
2263 | let foo = Foo{r: x..=x};
| ^^^^^ expected struct `std::ops::Range`, found struct `std::ops::RangeInclusive`
|
= note: expected type `std::ops::Range<u32>`
found type `std::ops::RangeInclusive<{integer}>`
clippy 0.0.212 (32b1d1fc 2018-10-05)