-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when appliedL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions
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)
djc, LunaBorowska, jonasbb, rocurley, adrienball and 11 more
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when appliedL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions