They are actually returning a different type than normal methods.
#![feature(async_await)]
#![warn(clippy::should_implement_trait)]
pub struct Foo;
impl Foo {
// actual type: pub fn next(&mut self) -> impl Future<Output = Option<()>>
pub async fn next(&mut self) -> Option<()> { //~ WARN: defining a method called `next` on this type; consider implementing the `std::iter::Iterator` trait or choosing a less ambiguous name
unimplemented!()
}
}
The warning is mostly about the method name next. Since this is a style lint, I think it is totally fine, that the lint triggers here. Maybe calling the function next_async would be better here?
I kind of disagree, since the Stream trait actually also calls its method next(). If Stream was in std, this lint could refer to Stream, but as long as that's not the case, clippy would be better off not warning about this IMO (I've been hit by this multiple times and always just end up silencing the lint).
This was apparently fixed by https://github.com/rust-lang/rust-clippy/pull/5437