Skip to content
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

range_plus_one suggests using RangeInclusive where it is not valid #6561

Closed
RDambrosio016 opened this issue Jan 7, 2021 · 2 comments
Closed
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@RDambrosio016
Copy link

I tried this code:

use std::ops::Range;

trait Foo {};
// not implemented for RangeInclusive!
impl Foo for Range<usize> {}

fn foo(_: impl Foo) {}

fn main() {
  let idx = 1;
  // clippy suggests you use `idx..=idx` but that produces an error because RangeInclusive
  // is not accepted for `impl Foo`
  foo(idx..idx + 1);
}

I expected to see this happen: No warning

Instead, this happened: an inclusive range would be more readable

Meta

  • cargo clippy -V: clippy 0.0.212 (44e3daf 2020-12-31)
  • rustc -Vv:
rustc 1.51.0-nightly (44e3daf5e 2020-12-31)
binary: rustc
commit-hash: 44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e
commit-date: 2020-12-31
host: x86_64-pc-windows-msvc
release: 1.51.0-nightly
@RDambrosio016 RDambrosio016 added the C-bug Category: Clippy is not doing the correct thing label Jan 7, 2021
@flip1995
Copy link
Member

flip1995 commented Jan 7, 2021

Duplicate of #3307

@flip1995 flip1995 marked this as a duplicate of #3307 Jan 7, 2021
@flip1995 flip1995 closed this as completed Jan 7, 2021
@RDambrosio016
Copy link
Author

Ah i apologize, i tried looking for a duplicate but couldnt find it 😄

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
Projects
None yet
Development

No branches or pull requests

2 participants