From 37ff15ad835ee4ba6d231cac8b1adbd301aec20b Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 8 Apr 2021 21:15:01 +0200 Subject: Cleanup --- crates/hir_ty/src/infer/expr.rs | 6 ++++- crates/hir_ty/src/traits/chalk/interner.rs | 37 +++++++++++------------------- 2 files changed, 19 insertions(+), 24 deletions(-) (limited to 'crates/hir_ty') diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index ee6763926..7961f4a52 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs @@ -462,7 +462,11 @@ impl<'a> InferenceContext<'a> { }; match canonicalized.decanonicalize_ty(derefed_ty.value).kind(&Interner) { TyKind::Tuple(_, substs) => name.as_tuple_index().and_then(|idx| { - substs.as_slice(&Interner).get(idx).map(|a| a.assert_ty_ref(&Interner)).cloned() + substs + .as_slice(&Interner) + .get(idx) + .map(|a| a.assert_ty_ref(&Interner)) + .cloned() }), TyKind::Adt(AdtId(hir_def::AdtId::StructId(s)), parameters) => { let local_id = self.db.struct_data(*s).variant_data.field(name)?; diff --git a/crates/hir_ty/src/traits/chalk/interner.rs b/crates/hir_ty/src/traits/chalk/interner.rs index f2c9a0d4b..b6a3cec6d 100644 --- a/crates/hir_ty/src/traits/chalk/interner.rs +++ b/crates/hir_ty/src/traits/chalk/interner.rs @@ -2,13 +2,13 @@ //! representation of the various objects Chalk deals with (types, goals etc.). use super::tls; +use crate::GenericArg; use base_db::salsa::InternId; use chalk_ir::{Goal, GoalData}; use hir_def::{ intern::{impl_internable, InternStorage, Internable, Interned}, TypeAliasId, }; -use crate::GenericArg; use smallvec::SmallVec; use std::{fmt, sync::Arc}; @@ -30,15 +30,6 @@ pub(crate) type OpaqueTyId = chalk_ir::OpaqueTyId; pub(crate) type OpaqueTyDatum = chalk_solve::rust_ir::OpaqueTyDatum; pub(crate) type Variances = chalk_ir::Variances; -#[derive(PartialEq, Eq, Hash, Debug)] -pub struct InternedVariableKindsInner(Vec>); - -#[derive(PartialEq, Eq, Hash, Debug)] -pub struct InternedSubstitutionInner(SmallVec<[GenericArg; 2]>); - -#[derive(PartialEq, Eq, Hash, Debug)] -pub struct InternedTypeInner(chalk_ir::TyData); - #[derive(PartialEq, Eq, Hash, Debug)] pub struct InternedWrapper(T); @@ -51,9 +42,9 @@ impl std::ops::Deref for InternedWrapper { } impl_internable!( - InternedVariableKindsInner, - InternedSubstitutionInner, - InternedTypeInner, + InternedWrapper>>, + InternedWrapper>, + InternedWrapper>, InternedWrapper>, InternedWrapper>, InternedWrapper>>, @@ -63,19 +54,21 @@ impl_internable!( ); impl chalk_ir::interner::Interner for Interner { - type InternedType = Interned; + type InternedType = Interned>>; type InternedLifetime = Interned>>; type InternedConst = Interned>>; type InternedConcreteConst = (); type InternedGenericArg = chalk_ir::GenericArgData; type InternedGoal = Arc>; type InternedGoals = Vec>; - type InternedSubstitution = Interned; + type InternedSubstitution = Interned>>; type InternedProgramClause = chalk_ir::ProgramClauseData; type InternedProgramClauses = Interned>>>; - type InternedQuantifiedWhereClauses = Interned>>>; - type InternedVariableKinds = Interned; - type InternedCanonicalVarKinds = Interned>>>; + type InternedQuantifiedWhereClauses = + Interned>>>; + type InternedVariableKinds = Interned>>>; + type InternedCanonicalVarKinds = + Interned>>>; type InternedConstraints = Vec>>; type InternedVariances = Interned>>; type DefId = InternId; @@ -230,7 +223,7 @@ impl chalk_ir::interner::Interner for Interner { fn intern_ty(&self, kind: chalk_ir::TyKind) -> Self::InternedType { let flags = kind.compute_flags(self); - Interned::new(InternedTypeInner(chalk_ir::TyData { kind, flags })) + Interned::new(InternedWrapper(chalk_ir::TyData { kind, flags })) } fn ty_data<'a>(&self, ty: &'a Self::InternedType) -> &'a chalk_ir::TyData { @@ -302,7 +295,7 @@ impl chalk_ir::interner::Interner for Interner { &self, data: impl IntoIterator>, ) -> Result { - Ok(Interned::new(InternedSubstitutionInner(data.into_iter().collect::, _>>()?))) + Ok(Interned::new(InternedWrapper(data.into_iter().collect::>()?))) } fn substitution_data<'a>( @@ -358,9 +351,7 @@ impl chalk_ir::interner::Interner for Interner { &self, data: impl IntoIterator, E>>, ) -> Result { - Ok(Interned::new(InternedVariableKindsInner( - data.into_iter().collect::, E>>()?, - ))) + Ok(Interned::new(InternedWrapper(data.into_iter().collect::>()?))) } fn variable_kinds_data<'a>( -- cgit v1.2.3