From 2bb80a4f0350045503258518d354a4e63e4c68fd Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sat, 10 Oct 2020 21:37:20 +0300 Subject: [PATCH] Also replace the associated types with iter --- crates/hir/src/code_model.rs | 6 +++++- crates/ide/src/inlay_hints.rs | 25 ++++++++++++++----------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index 031c91ccf612..9aaa280c8c3b 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs @@ -1372,7 +1372,7 @@ impl Type { r#trait: Trait, args: &[Type], alias: TypeAlias, - ) -> Option { + ) -> Option { let subst = Substs::build_for_def(db, r#trait.id) .push(self.ty.value.clone()) .fill(args.iter().map(|t| t.ty.value.clone())) @@ -1393,6 +1393,10 @@ impl Type { Solution::Unique(SolutionVariables(subst)) => subst.value.first().cloned(), Solution::Ambig(_) => None, } + .map(|ty| Type { + krate: self.krate, + ty: InEnvironment { value: ty, environment: Arc::clone(&self.ty.environment) }, + }) } pub fn is_copy(&self, db: &dyn HirDatabase) -> bool { diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs index 08ef49a27b6d..2ed84095da19 100644 --- a/crates/ide/src/inlay_hints.rs +++ b/crates/ide/src/inlay_hints.rs @@ -228,17 +228,20 @@ fn hint_iterator( _ => None, })?; if let Some(ty) = ty.normalize_trait_assoc_type(db, iter_trait, &[], assoc_type_item) { - // TODO kb also check for the iterator impls for this ty - dbg!(ty.display(db).to_string()); const LABEL_START: &str = "impl Iterator>> some_iter.push(iter::repeat(2).take(2)); - let zz = some_iter.take(2); - //^^ impl Iterator>> + let iter_of_iters = some_iter.take(2); + //^^^^^^^^^^^^^ impl Iterator> } "#, );