Handle type projections in iter_not_returning_iterator
This commit is contained in:
parent
2cc38a2322
commit
d98339d3e0
@ -67,6 +67,10 @@ impl LateLintPass<'_> for IterNotReturningIterator {
|
||||
fn check_sig(cx: &LateContext<'_>, name: &str, sig: &FnSig<'_>, fn_id: LocalDefId) {
|
||||
if sig.decl.implicit_self.has_implicit_self() {
|
||||
let ret_ty = cx.tcx.fn_sig(fn_id).skip_binder().output();
|
||||
let ret_ty = cx
|
||||
.tcx
|
||||
.try_normalize_erasing_regions(cx.param_env, ret_ty)
|
||||
.unwrap_or(ret_ty);
|
||||
if cx
|
||||
.tcx
|
||||
.get_diagnostic_item(sym::Iterator)
|
||||
|
@ -44,6 +44,7 @@ impl Iterator for Counter {
|
||||
}
|
||||
}
|
||||
|
||||
// Issue #8225
|
||||
trait Iter {
|
||||
type I;
|
||||
fn iter(&self) -> Self::I;
|
||||
@ -56,4 +57,11 @@ impl Iter for () {
|
||||
}
|
||||
}
|
||||
|
||||
struct S;
|
||||
impl S {
|
||||
fn iter(&self) -> <() as Iter>::I {
|
||||
().iter()
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -13,7 +13,7 @@ LL | fn iter_mut(&self) -> Counter2 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this method is named `iter` but its return type does not implement `Iterator`
|
||||
--> $DIR/iter_not_returning_iterator.rs:49:5
|
||||
--> $DIR/iter_not_returning_iterator.rs:50:5
|
||||
|
|
||||
LL | fn iter(&self) -> Self::I;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
Loading…
x
Reference in New Issue
Block a user