-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
len_zero
with Range suggests code cannot compile
#3807
Labels
C-bug
Category: Clippy is not doing the correct thing
I-suggestion-causes-error
Issue: The suggestions provided by this Lint cause an ICE/error when applied
L-suggestion
Lint: Improving, adding or fixing lint suggestions
Comments
flip1995
added
C-bug
Category: Clippy is not doing the correct thing
I-suggestion-causes-error
Issue: The suggestions provided by this Lint cause an ICE/error when applied
labels
Feb 24, 2019
This isn't a Clippy bug. See rust-lang/rust#48111. |
🤔 On the other hand, maybe it shouldn't be suggesting unstable methods... |
phansch
added
the
L-suggestion
Lint: Improving, adding or fixing lint suggestions
label
Aug 24, 2019
traviscross
added a commit
to traviscross/async-h1
that referenced
this issue
Mar 25, 2020
Clippy has some warnings for us. For some of them, fixing the code improves things. For others, making clippy happy would make the code worse (or in one case, even break compilation [1]). Let's fix the ones worth fixing, and for the others, let's tell clippy to ignore them. [1] rust-lang/rust-clippy#3807
bors
added a commit
that referenced
this issue
May 28, 2020
len_zero: skip ranges if feature `range_is_empty` is not enabled If the feature is not enabled, calling `is_empty()` on a range is ambiguous. Moreover, the two possible resolutions are unstable methods, one inherent to the range and the other being part of the `ExactSizeIterator` trait. Since `len_zero` only checks for existing `is_empty()` inherent methods, we only take into account the `range_is_empty` feature. Related: rust-lang/rust#48111 (comment) changelog: len_zero: avoid linting ranges without #![feature(range_is_empty)] Fixes: #3807
yvt
added a commit
to yvt/Stella2
that referenced
this issue
May 29, 2020
- `clone_on_copy` - `type_complexity` (threshold adjusted) - `collapsible_if` - `option_map_unit_fn` - `identity_conversion` - `iter_nth_zero` - `eval_order_dependence` (ignored) - `new_without_default` Unaddressed: - `len_zero` - This is a bug in clippy: <rust-lang/rust-clippy#3807>
yvt
added a commit
to yvt/Stella2
that referenced
this issue
May 29, 2020
- `string_lit_as_bytes` - `identity_op` - `len_zero` - `iter_nth_zero` - `collapsible_if` (evaded) - `let_and_return` - `len_without_is_empty` (ignored) - `or_fun_call` - `redundant_clone` - `option_as_ref_deref` Unaddressed: - `len_zero` - This is a bug in clippy: <rust-lang/rust-clippy#3807>
yvt
added a commit
to yvt/Stella2
that referenced
this issue
May 29, 2020
- `clone_on_copy` - `type_complexity` (threshold adjusted) - `collapsible_if` - `option_map_unit_fn` - `identity_conversion` - `iter_nth_zero` - `eval_order_dependence` (ignored) - `new_without_default` (adds `impl Default` for a public type) Unaddressed: - `len_zero` - This is a bug in clippy: <rust-lang/rust-clippy#3807>
yvt
added a commit
to yvt/Stella2
that referenced
this issue
May 29, 2020
- `string_lit_as_bytes` - `identity_op` - `len_zero` - `iter_nth_zero` - `collapsible_if` (evaded) - `let_and_return` - `len_without_is_empty` (ignored) - `or_fun_call` - `redundant_clone` - `option_as_ref_deref` Unaddressed: - `len_zero` - This is a bug in clippy: <rust-lang/rust-clippy#3807>
scottmcm
added a commit
to scottmcm/rust
that referenced
this issue
Aug 24, 2020
I would like to propose these two simple methods for stabilization: - Knowing that a range is exhaused isn't otherwise trivial - Clippy would like to suggest them, but had to do extra work to disable that path <rust-lang/rust-clippy#3807> because they're unstable - These work on `PartialOrd`, consistently with now-stable `contains`, and are thus more general than iterator-based approaches that need `Step` - They've been unchanged for some time, and have picked up uses in the compiler - Stabilizing them doesn't block any future iterator-based is_empty plans, as the inherent ones are preferred in name resolution
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Aug 25, 2020
…dtolnay Stabilize Range[Inclusive]::is_empty I would like to propose these two simple methods for stabilization: - Knowing that a range is exhausted isn't otherwise trivial - Clippy would like to suggest them, but had to do extra work to disable that path <rust-lang/rust-clippy#3807> because they're unstable - These work on `PartialOrd`, consistently with the stable `contains` method, and are thus more general than iterator-based approaches that need `Step` - They've been unchanged for some time, and have picked up uses in the compiler - Stabilizing them doesn't block any future iterator-based `is_empty` plans, as these inherent ones are preferred in name resolution https://doc.rust-lang.org/nightly/std/ops/struct.Range.html#method.is_empty https://doc.rust-lang.org/nightly/std/ops/struct.RangeInclusive.html#method.is_empty Closes rust-lang#48111
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
C-bug
Category: Clippy is not doing the correct thing
I-suggestion-causes-error
Issue: The suggestions provided by this Lint cause an ICE/error when applied
L-suggestion
Lint: Improving, adding or fixing lint suggestions
Code like
(0..42).len() == 0
will triggerlen_zero
, but(0..42).is_empty()
does not compile now.Clippy version: 0.0.212 (2019-02-19)
Rustc version: 1.34.0-nightly (2019-02-22)
Playground link
The text was updated successfully, but these errors were encountered: