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/assists/src/utils.rs | 2 +- crates/ide/src/inlay_hints.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'crates') diff --git a/crates/assists/src/utils.rs b/crates/assists/src/utils.rs index 92b3c3b00..c074b8d02 100644 --- a/crates/assists/src/utils.rs +++ b/crates/assists/src/utils.rs @@ -308,7 +308,7 @@ pub mod iter { } } } - pub(crate) mod collect { + pub(crate) mod collect { pub trait IntoIterator { type Item; } 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