diff options
author | Lukas Wirth <[email protected]> | 2020-10-07 11:13:32 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2020-10-07 11:14:08 +0100 |
commit | e106857e80d1ea304b00b5ff8a3294ca9bacd959 (patch) | |
tree | b8f78f6e5218568046f09ba9ecb2c7fee924eb53 /crates | |
parent | 209e9b9926d27ac71bc054bfdd48888e5d7d6d1a (diff) |
Shorten iterator hints for std::iter iterators behind references
Diffstat (limited to 'crates')
-rw-r--r-- | crates/assists/src/utils.rs | 2 | ||||
-rw-r--r-- | crates/ide/src/inlay_hints.rs | 6 |
2 files changed, 5 insertions, 3 deletions
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 { | |||
308 | } | 308 | } |
309 | } | 309 | } |
310 | } | 310 | } |
311 | pub(crate) mod collect { | 311 | pub(crate) mod collect { |
312 | pub trait IntoIterator { | 312 | pub trait IntoIterator { |
313 | type Item; | 313 | type Item; |
314 | } | 314 | } |
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( | |||
211 | ty: &Type, | 211 | ty: &Type, |
212 | ) -> Option<SmolStr> { | 212 | ) -> Option<SmolStr> { |
213 | let db = sema.db; | 213 | 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())?; | ||
215 | let krate = strukt.krate(db)?; | 217 | let krate = strukt.krate(db)?; |
216 | if krate.declaration_name(db).as_deref() != Some("core") { | 218 | if krate.declaration_name(db).as_deref() != Some("core") { |
217 | return None; | 219 | return None; |
@@ -1169,7 +1171,7 @@ fn main() { | |||
1169 | InlayHint { | 1171 | InlayHint { |
1170 | range: 175..225, | 1172 | range: 175..225, |
1171 | kind: ChainingHint, | 1173 | kind: ChainingHint, |
1172 | label: "&mut Take<&mut MyIter>", | 1174 | label: "impl Iterator<Item = ()>", |
1173 | }, | 1175 | }, |
1174 | InlayHint { | 1176 | InlayHint { |
1175 | range: 175..207, | 1177 | range: 175..207, |