From 195414783402d6973f4e673e84be9b7bc19cbfa6 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 14 Mar 2021 16:33:27 +0100 Subject: More renaming --- crates/hir_ty/src/display.rs | 7 +++++-- crates/hir_ty/src/lib.rs | 8 ++++---- crates/hir_ty/src/lower.rs | 7 +++++-- crates/hir_ty/src/traits/chalk/mapping.rs | 18 ++++++++---------- 4 files changed, 22 insertions(+), 18 deletions(-) (limited to 'crates/hir_ty') diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index 21291ddda..378c951c5 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs @@ -319,7 +319,10 @@ impl HirDisplay for Ty { TyKind::Dyn(predicates) if predicates.len() > 1 => { Cow::Borrowed(predicates.as_ref()) } - &TyKind::Alias(AliasTy::Opaque(OpaqueTy { opaque_ty_id, ref parameters })) => { + &TyKind::Alias(AliasTy::Opaque(OpaqueTy { + opaque_ty_id, + substitution: ref parameters, + })) => { let impl_trait_id = f.db.lookup_intern_impl_trait_id(opaque_ty_id.into()); if let ImplTraitId::ReturnTypeImplTrait(func, idx) = impl_trait_id { datas = @@ -579,7 +582,7 @@ impl HirDisplay for Ty { let data = (*datas) .as_ref() .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); - let bounds = data.subst(&opaque_ty.parameters); + let bounds = data.subst(&opaque_ty.substitution); write_bounds_like_dyn_trait_with_prefix("impl", &bounds.value, f)?; } ImplTraitId::AsyncBlockTypeImplTrait(..) => { diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index bc7a7369a..484652073 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs @@ -66,7 +66,7 @@ pub enum Lifetime { #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub struct OpaqueTy { pub opaque_ty_id: OpaqueTyId, - pub parameters: Substs, + pub substitution: Substs, } /// A "projection" type corresponds to an (unnormalized) @@ -903,7 +903,7 @@ impl Ty { let data = (*it) .as_ref() .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); - data.subst(&opaque_ty.parameters) + data.subst(&opaque_ty.substitution) }) } // It always has an parameter for Future::Output type. @@ -1059,7 +1059,7 @@ impl TypeWalk for Ty { } } TyKind::Alias(AliasTy::Opaque(o_ty)) => { - for t in o_ty.parameters.iter() { + for t in o_ty.substitution.iter() { t.walk(f); } } @@ -1094,7 +1094,7 @@ impl TypeWalk for Ty { } } TyKind::Alias(AliasTy::Opaque(o_ty)) => { - o_ty.parameters.walk_mut_binders(f, binders); + o_ty.substitution.walk_mut_binders(f, binders); } _ => { if let Some(substs) = self.substs_mut() { diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index 76b2124af..d026310f4 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs @@ -230,8 +230,11 @@ impl<'a> TyLoweringContext<'a> { let opaque_ty_id = self.db.intern_impl_trait_id(impl_trait_id).into(); let generics = generics(self.db.upcast(), func.into()); let parameters = Substs::bound_vars(&generics, self.in_binders); - TyKind::Alias(AliasTy::Opaque(OpaqueTy { opaque_ty_id, parameters })) - .intern(&Interner) + TyKind::Alias(AliasTy::Opaque(OpaqueTy { + opaque_ty_id, + substitution: parameters, + })) + .intern(&Interner) } ImplTraitLoweringMode::Param => { let idx = self.impl_trait_counter.get(); diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index 1a6fca611..05a4bf0df 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs @@ -87,6 +87,13 @@ impl ToChalk for Ty { .cast(&Interner) .intern(&Interner) } + TyKind::Alias(AliasTy::Opaque(opaque_ty)) => { + let opaque_ty_id = opaque_ty.opaque_ty_id; + let substitution = opaque_ty.substitution.to_chalk(db); + chalk_ir::AliasTy::Opaque(chalk_ir::OpaqueTy { opaque_ty_id, substitution }) + .cast(&Interner) + .intern(&Interner) + } TyKind::Placeholder(idx) => idx.to_ty::(&Interner), TyKind::BoundVar(idx) => chalk_ir::TyKind::BoundVar(idx).intern(&Interner), TyKind::InferenceVar(..) => panic!("uncanonicalized infer ty"), @@ -101,15 +108,6 @@ impl ToChalk for Ty { }; chalk_ir::TyKind::Dyn(bounded_ty).intern(&Interner) } - TyKind::Alias(AliasTy::Opaque(opaque_ty)) => { - let opaque_ty_id = opaque_ty.opaque_ty_id; - let substitution = opaque_ty.parameters.to_chalk(db); - chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(chalk_ir::OpaqueTy { - opaque_ty_id, - substitution, - })) - .intern(&Interner) - } TyKind::Unknown => chalk_ir::TyKind::Error.intern(&Interner), } } @@ -129,7 +127,7 @@ impl ToChalk for Ty { chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(opaque_ty)) => { let opaque_ty_id = opaque_ty.opaque_ty_id; let parameters = from_chalk(db, opaque_ty.substitution); - TyKind::Alias(AliasTy::Opaque(OpaqueTy { opaque_ty_id, parameters })) + TyKind::Alias(AliasTy::Opaque(OpaqueTy { opaque_ty_id, substitution: parameters })) } chalk_ir::TyKind::Function(chalk_ir::FnPointer { num_binders, -- cgit v1.2.3