From e106857e80d1ea304b00b5ff8a3294ca9bacd959 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 7 Oct 2020 12:13:32 +0200 Subject: Shorten iterator hints for std::iter iterators behind references --- crates/ide/src/inlay_hints.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'crates/ide') diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs index 279d02541..7540f56a4 100644 --- a/crates/ide/src/inlay_hints.rs +++ b/crates/ide/src/inlay_hints.rs @@ -211,7 +211,9 @@ fn hint_iterator( ty: &Type, ) -> Option { let db = sema.db; - let strukt = ty.as_adt()?; + let strukt = std::iter::successors(Some(ty.clone()), |ty| ty.remove_ref()) + .last() + .and_then(|strukt| strukt.as_adt())?; let krate = strukt.krate(db)?; if krate.declaration_name(db).as_deref() != Some("core") { return None; @@ -1169,7 +1171,7 @@ fn main() { InlayHint { range: 175..225, kind: ChainingHint, - label: "&mut Take<&mut MyIter>", + label: "impl Iterator", }, InlayHint { range: 175..207, -- cgit v1.2.3