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

False positive with Box<dyn Iterator<>> and iter_not_returning_iterator #8308

Closed
HollayHorvath opened this issue Jan 18, 2022 · 3 comments
Closed
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@HollayHorvath
Copy link

Summary

Having an function returning a boxed iterator triggers this lint.

Lint Name

iter_not_returning_iterator

Reproducer

I tried this code:

pub trait Foo {
    fn iter(&self) -> Box<dyn Iterator<Item = i32> + '_>;
}

I saw this happen:

warning: this method is named `iter` but its return type does not implement `Iterator`
 --> src/lib.rs:3:5
  |
3 |     fn iter(&self) -> Box<dyn Iterator<Item = i32> + '_>;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: the lint level is defined here
 --> src/lib.rs:1:9
  |
1 | #![warn(clippy::iter_not_returning_iterator)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_not_returning_iterator

I expected to see this happen:
No warn being triggered

Version

rustc 1.60.0-nightly (bd3cb5256 2022-01-16)
binary: rustc
commit-hash: bd3cb52565faab2755ff1bdb54d88bc91f47b4b9
commit-date: 2022-01-16
host: x86_64-unknown-linux-gnu
release: 1.60.0-nightly
LLVM version: 13.0.0

Additional Labels

No response

@HollayHorvath HollayHorvath added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Jan 18, 2022
@Jarcho
Copy link
Contributor

Jarcho commented Jan 18, 2022

Fixed in #8287

@HollayHorvath
Copy link
Author

I'm getting the same error with the latest clippy version (clippy 0.1.60 (ee5d8d3 2022-01-17)). Is it possible that #8287 isn't landed yet on nightly?

@xFrednet
Copy link
Member

Correct, it takes some time until Clippy changes are distributed with nightly. Tomorrow's version should have this fix as it was synced and merged today in rust-lang/rust#93001 🙃

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-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

No branches or pull requests

3 participants