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/lib.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'crates/hir_ty/src/lib.rs') 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) { -- cgit v1.2.3 From eea777c7148ac6c52434e8ea4913cdb50a466a3e Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 14 Mar 2021 16:30:02 +0100 Subject: Use chalk_ir::FnSig --- crates/hir_ty/src/lib.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'crates/hir_ty/src/lib.rs') diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index ddcee2084..bc7a7369a 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs @@ -46,7 +46,7 @@ pub use lower::{ }; pub use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment}; -pub use chalk_ir::{AdtId, BoundVar, DebruijnIndex, Mutability, Scalar, TyVariableKind}; +pub use chalk_ir::{AdtId, BoundVar, DebruijnIndex, Mutability, Safety, Scalar, TyVariableKind}; pub use crate::traits::chalk::Interner; @@ -105,10 +105,7 @@ impl TypeWalk for ProjectionTy { } } -#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)] -pub struct FnSig { - pub variadic: bool, -} +pub type FnSig = chalk_ir::FnSig; #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub struct FnPointer { @@ -643,7 +640,7 @@ impl Ty { pub fn fn_ptr(sig: CallableSig) -> Self { TyKind::Function(FnPointer { num_args: sig.params().len(), - sig: FnSig { variadic: sig.is_varargs }, + sig: FnSig { abi: (), safety: Safety::Safe, variadic: sig.is_varargs }, substs: Substs(sig.params_and_return), }) .intern(&Interner) @@ -945,7 +942,9 @@ impl Ty { } } TyKind::Alias(AliasTy::Projection(projection_ty)) => { - match from_assoc_type_id(projection_ty.associated_ty_id).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, -- cgit v1.2.3 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/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/hir_ty/src/lib.rs') 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() { -- cgit v1.2.3