From 3411fe3e84e641aad03abbc22eec33fdc29b15f8 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 14 Mar 2021 16:26:12 +0100 Subject: Rename some fields to their Chalk names --- crates/hir_ty/src/autoderef.rs | 2 +- crates/hir_ty/src/display.rs | 16 ++++++++-------- crates/hir_ty/src/infer.rs | 4 ++-- crates/hir_ty/src/infer/expr.rs | 4 ++-- crates/hir_ty/src/infer/unify.rs | 6 +++--- crates/hir_ty/src/lib.rs | 18 +++++++++--------- crates/hir_ty/src/lower.rs | 12 ++++++------ crates/hir_ty/src/traits.rs | 2 +- crates/hir_ty/src/traits/chalk.rs | 4 ++-- crates/hir_ty/src/traits/chalk/mapping.rs | 22 +++++++++++----------- 10 files changed, 45 insertions(+), 45 deletions(-) (limited to 'crates/hir_ty') diff --git a/crates/hir_ty/src/autoderef.rs b/crates/hir_ty/src/autoderef.rs index d739d5d60..d5c2b9a20 100644 --- a/crates/hir_ty/src/autoderef.rs +++ b/crates/hir_ty/src/autoderef.rs @@ -84,7 +84,7 @@ fn deref_by_trait( let projection = super::traits::ProjectionPredicate { ty: TyKind::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, ty.value.kinds.len())) .intern(&Interner), - projection_ty: super::ProjectionTy { associated_ty: to_assoc_type_id(target), parameters }, + projection_ty: super::ProjectionTy { associated_ty_id: to_assoc_type_id(target), substitution: parameters }, }; let obligation = super::Obligation::Projection(projection); diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index e6473586b..21291ddda 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs @@ -245,19 +245,19 @@ impl HirDisplay for ProjectionTy { } let trait_ = f.db.trait_data(self.trait_(f.db)); - let first_parameter = self.parameters[0].into_displayable( + let first_parameter = self.substitution[0].into_displayable( f.db, f.max_size, f.omit_verbose_types, f.display_target, ); write!(f, "<{} as {}", first_parameter, trait_.name)?; - if self.parameters.len() > 1 { + if self.substitution.len() > 1 { write!(f, "<")?; - f.write_joined(&self.parameters[1..], ", ")?; + f.write_joined(&self.substitution[1..], ", ")?; write!(f, ">")?; } - write!(f, ">::{}", f.db.type_alias_data(from_assoc_type_id(self.associated_ty)).name)?; + write!(f, ">::{}", f.db.type_alias_data(from_assoc_type_id(self.associated_ty_id)).name)?; Ok(()) } } @@ -491,8 +491,8 @@ impl HirDisplay for Ty { } } else { let projection_ty = ProjectionTy { - associated_ty: to_assoc_type_id(type_alias), - parameters: parameters.clone(), + associated_ty_id: to_assoc_type_id(type_alias), + substitution: parameters.clone(), }; projection_ty.hir_fmt(f)?; @@ -709,7 +709,7 @@ fn write_bounds_like_dyn_trait( angle_open = true; } let type_alias = f.db.type_alias_data(from_assoc_type_id( - projection_pred.projection_ty.associated_ty, + projection_pred.projection_ty.associated_ty_id, )); write!(f, "{} = ", type_alias.name)?; projection_pred.ty.hir_fmt(f)?; @@ -782,7 +782,7 @@ impl HirDisplay for GenericPredicate { f, ">::{} = ", f.db.type_alias_data(from_assoc_type_id( - projection_pred.projection_ty.associated_ty + projection_pred.projection_ty.associated_ty_id )) .name, )?; diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs index 8cf59821f..fbfedb4e6 100644 --- a/crates/hir_ty/src/infer.rs +++ b/crates/hir_ty/src/infer.rs @@ -385,8 +385,8 @@ impl<'a> InferenceContext<'a> { let projection = ProjectionPredicate { ty: ty.clone(), projection_ty: ProjectionTy { - associated_ty: to_assoc_type_id(res_assoc_ty), - parameters: substs, + associated_ty_id: to_assoc_type_id(res_assoc_ty), + substitution: substs, }, }; self.obligations.push(Obligation::Trait(trait_ref)); diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index eee3e6ec5..b7870e771 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs @@ -99,8 +99,8 @@ impl<'a> InferenceContext<'a> { if self.db.trait_solve(krate, goal.value).is_some() { self.obligations.push(implements_fn_trait); let output_proj_ty = crate::ProjectionTy { - associated_ty: to_assoc_type_id(output_assoc_type), - parameters: substs, + associated_ty_id: to_assoc_type_id(output_assoc_type), + substitution: substs, }; let return_ty = self.normalize_projection_ty(output_proj_ty); Some((arg_tys, return_ty)) diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs index 16d89ed1b..ebc612ca9 100644 --- a/crates/hir_ty/src/infer/unify.rs +++ b/crates/hir_ty/src/infer/unify.rs @@ -381,11 +381,11 @@ impl InferenceTable { self.unify_substs(&tr1.substs, &tr2.substs, depth + 1) } (GenericPredicate::Projection(proj1), GenericPredicate::Projection(proj2)) - if proj1.projection_ty.associated_ty == proj2.projection_ty.associated_ty => + if proj1.projection_ty.associated_ty_id == proj2.projection_ty.associated_ty_id => { self.unify_substs( - &proj1.projection_ty.parameters, - &proj2.projection_ty.parameters, + &proj1.projection_ty.substitution, + &proj2.projection_ty.substitution, depth + 1, ) && self.unify_inner(&proj1.ty, &proj2.ty, depth + 1) } diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index d6ff968f0..ddcee2084 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs @@ -74,17 +74,17 @@ pub struct OpaqueTy { /// trait and all its parameters are fully known. #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub struct ProjectionTy { - pub associated_ty: AssocTypeId, - pub parameters: Substs, + pub associated_ty_id: AssocTypeId, + pub substitution: Substs, } impl ProjectionTy { pub fn trait_ref(&self, db: &dyn HirDatabase) -> TraitRef { - TraitRef { trait_: self.trait_(db), substs: self.parameters.clone() } + TraitRef { trait_: self.trait_(db), substs: self.substitution.clone() } } fn trait_(&self, db: &dyn HirDatabase) -> TraitId { - match from_assoc_type_id(self.associated_ty).lookup(db.upcast()).container { + match from_assoc_type_id(self.associated_ty_id).lookup(db.upcast()).container { AssocContainerId::TraitId(it) => it, _ => panic!("projection ty without parent trait"), } @@ -93,7 +93,7 @@ impl ProjectionTy { impl TypeWalk for ProjectionTy { fn walk(&self, f: &mut impl FnMut(&Ty)) { - self.parameters.walk(f); + self.substitution.walk(f); } fn walk_mut_binders( @@ -101,7 +101,7 @@ impl TypeWalk for ProjectionTy { f: &mut impl FnMut(&mut Ty, DebruijnIndex), binders: DebruijnIndex, ) { - self.parameters.walk_mut_binders(f, binders); + self.substitution.walk_mut_binders(f, binders); } } @@ -945,7 +945,7 @@ impl Ty { } } TyKind::Alias(AliasTy::Projection(projection_ty)) => { - match from_assoc_type_id(projection_ty.associated_ty).lookup(db.upcast()).container + match from_assoc_type_id(projection_ty.associated_ty_id).lookup(db.upcast()).container { AssocContainerId::TraitId(trait_id) => Some(trait_id), _ => None, @@ -1055,7 +1055,7 @@ impl TypeWalk for Ty { fn walk(&self, f: &mut impl FnMut(&Ty)) { match self.interned(&Interner) { TyKind::Alias(AliasTy::Projection(p_ty)) => { - for t in p_ty.parameters.iter() { + for t in p_ty.substitution.iter() { t.walk(f); } } @@ -1087,7 +1087,7 @@ impl TypeWalk for Ty { ) { match &mut self.0 { TyKind::Alias(AliasTy::Projection(p_ty)) => { - p_ty.parameters.walk_mut_binders(f, binders); + p_ty.substitution.walk_mut_binders(f, binders); } TyKind::Dyn(predicates) => { for p in make_mut_slice(predicates) { diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index c32dca9d7..17eb29911 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs @@ -357,8 +357,8 @@ impl<'a> TyLoweringContext<'a> { Some((super_trait_ref, associated_ty)) => { // FIXME handle type parameters on the segment TyKind::Alias(AliasTy::Projection(ProjectionTy { - associated_ty: to_assoc_type_id(associated_ty), - parameters: super_trait_ref.substs, + associated_ty_id: to_assoc_type_id(associated_ty), + substitution: super_trait_ref.substs, })) .intern(&Interner) } @@ -478,8 +478,8 @@ impl<'a> TyLoweringContext<'a> { // FIXME handle type parameters on the segment return Some( TyKind::Alias(AliasTy::Projection(ProjectionTy { - associated_ty: to_assoc_type_id(associated_ty), - parameters: substs, + associated_ty_id: to_assoc_type_id(associated_ty), + substitution: substs, })) .intern(&Interner), ); @@ -736,8 +736,8 @@ impl<'a> TyLoweringContext<'a> { Some(t) => t, }; let projection_ty = ProjectionTy { - associated_ty: to_assoc_type_id(associated_ty), - parameters: super_trait_ref.substs, + associated_ty_id: to_assoc_type_id(associated_ty), + substitution: super_trait_ref.substs, }; let mut preds = SmallVec::with_capacity( binding.type_ref.as_ref().map_or(0, |_| 1) + binding.bounds.len(), diff --git a/crates/hir_ty/src/traits.rs b/crates/hir_ty/src/traits.rs index edfafdff8..a6a63c673 100644 --- a/crates/hir_ty/src/traits.rs +++ b/crates/hir_ty/src/traits.rs @@ -143,7 +143,7 @@ pub(crate) fn trait_solve_query( log::info!("trait_solve_query({})", goal.value.value.display(db)); if let Obligation::Projection(pred) = &goal.value.value { - if let TyKind::BoundVar(_) = &pred.projection_ty.parameters[0].interned(&Interner) { + if let TyKind::BoundVar(_) = &pred.projection_ty.substitution[0].interned(&Interner) { // Hack: don't ask Chalk to normalize with an unknown self type, it'll say that's impossible return Some(Solution::Ambig(Guidance::Unknown)); } diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs index ef1e6b2df..232cf9cd0 100644 --- a/crates/hir_ty/src/traits/chalk.rs +++ b/crates/hir_ty/src/traits/chalk.rs @@ -234,9 +234,9 @@ impl<'a> chalk_solve::RustIrDatabase for ChalkContext<'a> { ty: TyKind::BoundVar(BoundVar { debruijn: DebruijnIndex::ONE, index: 0 }) .intern(&Interner), projection_ty: ProjectionTy { - associated_ty: to_assoc_type_id(future_output), + associated_ty_id: to_assoc_type_id(future_output), // Self type as the first parameter. - parameters: Substs::single( + substitution: Substs::single( TyKind::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, 0)) .intern(&Interner), ), diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index 2a66a2310..68effbbf3 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs @@ -78,8 +78,8 @@ impl ToChalk for Ty { chalk_ir::TyKind::Adt(adt_id, substitution).intern(&Interner) } TyKind::Alias(AliasTy::Projection(proj_ty)) => { - let associated_ty_id = proj_ty.associated_ty; - let substitution = proj_ty.parameters.to_chalk(db); + let associated_ty_id = proj_ty.associated_ty_id; + let substitution = proj_ty.substitution.to_chalk(db); chalk_ir::AliasTy::Projection(chalk_ir::ProjectionTy { associated_ty_id, substitution, @@ -121,7 +121,7 @@ impl ToChalk for Ty { chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Projection(proj)) => { let associated_ty = proj.associated_ty_id; let parameters = from_chalk(db, proj.substitution); - TyKind::Alias(AliasTy::Projection(ProjectionTy { associated_ty, parameters })) + TyKind::Alias(AliasTy::Projection(ProjectionTy { associated_ty_id: associated_ty, substitution: parameters })) } chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(opaque_ty)) => { let opaque_ty_id = opaque_ty.opaque_ty_id; @@ -372,8 +372,8 @@ impl ToChalk for ProjectionTy { fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::ProjectionTy { chalk_ir::ProjectionTy { - associated_ty_id: self.associated_ty, - substitution: self.parameters.to_chalk(db), + associated_ty_id: self.associated_ty_id, + substitution: self.substitution.to_chalk(db), } } @@ -382,8 +382,8 @@ impl ToChalk for ProjectionTy { projection_ty: chalk_ir::ProjectionTy, ) -> ProjectionTy { ProjectionTy { - associated_ty: projection_ty.associated_ty_id, - parameters: from_chalk(db, projection_ty.substitution), + associated_ty_id: projection_ty.associated_ty_id, + substitution: from_chalk(db, projection_ty.substitution), } } } @@ -533,24 +533,24 @@ pub(super) fn generic_predicate_to_inline_bound( Some(rust_ir::InlineBound::TraitBound(trait_bound)) } GenericPredicate::Projection(proj) => { - if &proj.projection_ty.parameters[0] != self_ty { + if &proj.projection_ty.substitution[0] != self_ty { return None; } - let trait_ = match from_assoc_type_id(proj.projection_ty.associated_ty) + let trait_ = match from_assoc_type_id(proj.projection_ty.associated_ty_id) .lookup(db.upcast()) .container { AssocContainerId::TraitId(t) => t, _ => panic!("associated type not in trait"), }; - let args_no_self = proj.projection_ty.parameters[1..] + let args_no_self = proj.projection_ty.substitution[1..] .iter() .map(|ty| ty.clone().to_chalk(db).cast(&Interner)) .collect(); let alias_eq_bound = rust_ir::AliasEqBound { value: proj.ty.clone().to_chalk(db), trait_bound: rust_ir::TraitBound { trait_id: trait_.to_chalk(db), args_no_self }, - associated_ty_id: proj.projection_ty.associated_ty, + associated_ty_id: proj.projection_ty.associated_ty_id, parameters: Vec::new(), // FIXME we don't support generic associated types yet }; Some(rust_ir::InlineBound::AliasEqBound(alias_eq_bound)) -- cgit v1.2.3