Skip to content

len_zero with Range suggests code cannot compile #3807

Closed
@oxalica

Description

@oxalica
Contributor

Code like (0..42).len() == 0 will trigger len_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

  |
4 |     println!("{}", (0..42).is_empty());
  |                            ^^^^^^^^ multiple `is_empty` found
  |
  = note: candidate #1 is defined in an impl for the type `std::ops::Range<_>`
note: candidate #2 is defined in the trait `std::iter::ExactSizeIterator`
  = help: to disambiguate the method call, write `std::iter::ExactSizeIterator::is_empty(::std::ops::Range{start: 0, end: 42,})` instead

Activity

added
C-bugCategory: Clippy is not doing the correct thing
I-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied
on Feb 24, 2019
ghost

ghost commented on Jul 5, 2019

@ghost

This isn't a Clippy bug. See rust-lang/rust#48111.

ghost

ghost commented on Jul 5, 2019

@ghost

🤔 On the other hand, maybe it shouldn't be suggesting unstable methods...

added
L-suggestionLint: Improving, adding or fixing lint suggestions
on Aug 24, 2019
added a commit that references this issue on Mar 25, 2020
added a commit that references this issue on May 28, 2020

Auto merge of #5656 - ebroto:len_zero_ranges, r=matthiaskrgr

ebfbe2b
added a commit that references this issue on May 31, 2020

Rollup merge of rust-lang#5656 - ebroto:len_zero_ranges, r=matthiaskrgr

873c9fc
added a commit that references this issue on Aug 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedL-suggestionLint: Improving, adding or fixing lint suggestions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @phansch@flip1995@oxalica

      Issue actions

        `len_zero` with Range suggests code cannot compile · Issue #3807 · rust-lang/rust-clippy