Shorten iterator hints for std::iter iterators behind references

This commit is contained in:
Lukas Wirth 2020-10-07 12:13:32 +02:00
parent 209e9b9926
commit e106857e80
2 changed files with 5 additions and 3 deletions

View File

@ -211,7 +211,9 @@ fn hint_iterator(
ty: &Type,
) -> Option<SmolStr> {
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<Item = ()>",
},
InlayHint {
range: 175..207,