From 70a6d7b012822576ca299b07f612392ca1e0fb91 Mon Sep 17 00:00:00 2001 From: Jason Newcomb Date: Sat, 15 Jan 2022 00:15:25 -0500 Subject: [PATCH] Erase late bound regions in `iter_not_returning_iterator` --- clippy_lints/src/iter_not_returning_iterator.rs | 2 +- tests/ui/iter_not_returning_iterator.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/iter_not_returning_iterator.rs b/clippy_lints/src/iter_not_returning_iterator.rs index d3bdc819a9f2..b56d87c5348c 100644 --- a/clippy_lints/src/iter_not_returning_iterator.rs +++ b/clippy_lints/src/iter_not_returning_iterator.rs @@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> 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.erase_late_bound_regions(cx.tcx.fn_sig(fn_id).output()); let ret_ty = cx .tcx .try_normalize_erasing_regions(cx.param_env, ret_ty) diff --git a/tests/ui/iter_not_returning_iterator.rs b/tests/ui/iter_not_returning_iterator.rs index 2c91e02e8422..cce216fc649b 100644 --- a/tests/ui/iter_not_returning_iterator.rs +++ b/tests/ui/iter_not_returning_iterator.rs @@ -64,4 +64,11 @@ impl S { } } +struct S2([u8]); +impl S2 { + fn iter(&self) -> core::slice::Iter { + self.0.iter() + } +} + fn main() {}