-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
Summary
As of most recent nightly, and as of current master of clippy (7a4acf9), I haven't found a function named iter
or iter_mut
which does not trigger this lint. Even if the function returns an implementation of Iterator
the lint triggers.
Lint Name
iter_not_returning_iterator
Reproducer
#![deny(clippy::iter_not_returning_iterator)]
pub struct Matrix;
pub struct Element;
impl Matrix {
pub fn iter(&self) -> Iter {
Iter([].iter())
}
}
pub struct Iter<'a>(std::slice::Iter<'a, Element>);
impl<'a> Iterator for Iter<'a> {
type Item = &'a Element;
fn next(&mut self) -> Option<Self::Item> {
self.0.next()
}
}
error: this method is named `iter` but its return type does not implement `Iterator`
--> src/main.rs:7:5
|
7 | pub fn iter(&self) -> Iter {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> src/main.rs:1:9
|
1 | #![deny(clippy::iter_not_returning_iterator)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_not_returning_iterator
Version
rustc 1.60.0-nightly (ad46af247 2022-01-14)
binary: rustc
commit-hash: ad46af24713115e7b9b258346e66b9b2d14eacfc
commit-date: 2022-01-14
host: x86_64-unknown-linux-gnu
release: 1.60.0-nightly
LLVM version: 13.0.0
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have