Skip to content

Commit e106857

Browse files
committed
Shorten iterator hints for std::iter iterators behind references
1 parent 209e9b9 commit e106857

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

crates/assists/src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ pub mod iter {
308308
}
309309
}
310310
}
311-
pub(crate) mod collect {
311+
pub(crate) mod collect {
312312
pub trait IntoIterator {
313313
type Item;
314314
}

crates/ide/src/inlay_hints.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ fn hint_iterator(
211211
ty: &Type,
212212
) -> Option<SmolStr> {
213213
let db = sema.db;
214-
let strukt = ty.as_adt()?;
214+
let strukt = std::iter::successors(Some(ty.clone()), |ty| ty.remove_ref())
215+
.last()
216+
.and_then(|strukt| strukt.as_adt())?;
215217
let krate = strukt.krate(db)?;
216218
if krate.declaration_name(db).as_deref() != Some("core") {
217219
return None;
@@ -1169,7 +1171,7 @@ fn main() {
11691171
InlayHint {
11701172
range: 175..225,
11711173
kind: ChainingHint,
1172-
label: "&mut Take<&mut MyIter>",
1174+
label: "impl Iterator<Item = ()>",
11731175
},
11741176
InlayHint {
11751177
range: 175..207,

0 commit comments

Comments
 (0)