aboutsummaryrefslogtreecommitdiff
path: root/crates/ide
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2020-10-10 19:37:20 +0100
committerKirill Bulatov <[email protected]>2020-10-10 19:39:57 +0100
commit2bb80a4f0350045503258518d354a4e63e4c68fd (patch)
treeb9b9e8283753f469177797dac60c76fc89a8bcd3 /crates/ide
parent9a72b7bccde54d901f3d89300777e0685790aefd (diff)
Also replace the associated types with iter
Diffstat (limited to 'crates/ide')
-rw-r--r--crates/ide/src/inlay_hints.rs25
1 files changed, 14 insertions, 11 deletions
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs
index 08ef49a27..2ed84095d 100644
--- a/crates/ide/src/inlay_hints.rs
+++ b/crates/ide/src/inlay_hints.rs
@@ -228,17 +228,20 @@ fn hint_iterator(
228 _ => None, 228 _ => None,
229 })?; 229 })?;
230 if let Some(ty) = ty.normalize_trait_assoc_type(db, iter_trait, &[], assoc_type_item) { 230 if let Some(ty) = ty.normalize_trait_assoc_type(db, iter_trait, &[], assoc_type_item) {
231 // TODO kb also check for the iterator impls for this ty
232 dbg!(ty.display(db).to_string());
233 const LABEL_START: &str = "impl Iterator<Item = "; 231 const LABEL_START: &str = "impl Iterator<Item = ";
234 const LABEL_END: &str = ">"; 232 const LABEL_END: &str = ">";
235 233
236 let ty_display = ty.display_truncated( 234 let ty_display = hint_iterator(sema, config, &ty)
237 db, 235 .map(|assoc_type_impl| assoc_type_impl.to_string())
238 config 236 .unwrap_or_else(|| {
239 .max_length 237 ty.display_truncated(
240 .map(|len| len.saturating_sub(LABEL_START.len() + LABEL_END.len())), 238 db,
241 ); 239 config
240 .max_length
241 .map(|len| len.saturating_sub(LABEL_START.len() + LABEL_END.len())),
242 )
243 .to_string()
244 });
242 return Some(format!("{}{}{}", LABEL_START, ty_display, LABEL_END).into()); 245 return Some(format!("{}{}{}", LABEL_START, ty_display, LABEL_END).into());
243 } 246 }
244 } 247 }
@@ -1169,7 +1172,7 @@ fn main() {
1169 InlayHintsConfig { 1172 InlayHintsConfig {
1170 parameter_hints: false, 1173 parameter_hints: false,
1171 type_hints: true, 1174 type_hints: true,
1172 chaining_hints: true, 1175 chaining_hints: false,
1173 max_length: None, 1176 max_length: None,
1174 }, 1177 },
1175 r#" 1178 r#"
@@ -1193,8 +1196,8 @@ fn main() {
1193 let mut some_iter = SomeIter::new(); 1196 let mut some_iter = SomeIter::new();
1194 //^^^^^^^^^^^^^ SomeIter<Take<Repeat<i32>>> 1197 //^^^^^^^^^^^^^ SomeIter<Take<Repeat<i32>>>
1195 some_iter.push(iter::repeat(2).take(2)); 1198 some_iter.push(iter::repeat(2).take(2));
1196 let zz = some_iter.take(2); 1199 let iter_of_iters = some_iter.take(2);
1197 //^^ impl Iterator<Item = Take<Repeat<i32>>> 1200 //^^^^^^^^^^^^^ impl Iterator<Item = impl Iterator<Item = i32>>
1198} 1201}
1199"#, 1202"#,
1200 ); 1203 );