]> git.lizzy.rs Git - rust.git/commitdiff
Shorten iterator hints for std::iter iterators behind references
authorLukas Wirth <lukastw97@gmail.com>
Wed, 7 Oct 2020 10:13:32 +0000 (12:13 +0200)
committerLukas Wirth <lukastw97@gmail.com>
Wed, 7 Oct 2020 10:14:08 +0000 (12:14 +0200)
crates/assists/src/utils.rs
crates/ide/src/inlay_hints.rs

index 92b3c3b009b68f29590f85603dab82e299de1534..c074b8d02f9543bfb47bf6be976e72d1880ee04b 100644 (file)
@@ -308,7 +308,7 @@ fn next(&mut self) -> Option<I::Item> {
                 }
             }
         }
-        pub(crate) mod collect {            
+        pub(crate) mod collect {
             pub trait IntoIterator {
                 type Item;
             }
index 279d025417c5632546c53fea6c08f1cbbe377819..7540f56a4b15036f6284cdea2d7acb4c60634733 100644 (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,