Skip to content

len_zero with Range suggests code cannot compile #3807

Closed
@oxalica

Description

@oxalica

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

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

    Development

    No branches or pull requests

    Issue actions