Skip to content

Commit 37ff15a

Browse files
committed
Cleanup
1 parent 417473a commit 37ff15a

File tree

2 files changed

+19
-24
lines changed

2 files changed

+19
-24
lines changed

crates/hir_ty/src/infer/expr.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,11 @@ impl<'a> InferenceContext<'a> {
462462
};
463463
match canonicalized.decanonicalize_ty(derefed_ty.value).kind(&Interner) {
464464
TyKind::Tuple(_, substs) => name.as_tuple_index().and_then(|idx| {
465-
substs.as_slice(&Interner).get(idx).map(|a| a.assert_ty_ref(&Interner)).cloned()
465+
substs
466+
.as_slice(&Interner)
467+
.get(idx)
468+
.map(|a| a.assert_ty_ref(&Interner))
469+
.cloned()
466470
}),
467471
TyKind::Adt(AdtId(hir_def::AdtId::StructId(s)), parameters) => {
468472
let local_id = self.db.struct_data(*s).variant_data.field(name)?;

crates/hir_ty/src/traits/chalk/interner.rs

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
//! representation of the various objects Chalk deals with (types, goals etc.).
33
44
use super::tls;
5+
use crate::GenericArg;
56
use base_db::salsa::InternId;
67
use chalk_ir::{Goal, GoalData};
78
use hir_def::{
89
intern::{impl_internable, InternStorage, Internable, Interned},
910
TypeAliasId,
1011
};
11-
use crate::GenericArg;
1212
use smallvec::SmallVec;
1313
use std::{fmt, sync::Arc};
1414

@@ -30,15 +30,6 @@ pub(crate) type OpaqueTyId = chalk_ir::OpaqueTyId<Interner>;
3030
pub(crate) type OpaqueTyDatum = chalk_solve::rust_ir::OpaqueTyDatum<Interner>;
3131
pub(crate) type Variances = chalk_ir::Variances<Interner>;
3232

33-
#[derive(PartialEq, Eq, Hash, Debug)]
34-
pub struct InternedVariableKindsInner(Vec<chalk_ir::VariableKind<Interner>>);
35-
36-
#[derive(PartialEq, Eq, Hash, Debug)]
37-
pub struct InternedSubstitutionInner(SmallVec<[GenericArg; 2]>);
38-
39-
#[derive(PartialEq, Eq, Hash, Debug)]
40-
pub struct InternedTypeInner(chalk_ir::TyData<Interner>);
41-
4233
#[derive(PartialEq, Eq, Hash, Debug)]
4334
pub struct InternedWrapper<T>(T);
4435

@@ -51,9 +42,9 @@ impl<T> std::ops::Deref for InternedWrapper<T> {
5142
}
5243

5344
impl_internable!(
54-
InternedVariableKindsInner,
55-
InternedSubstitutionInner,
56-
InternedTypeInner,
45+
InternedWrapper<Vec<chalk_ir::VariableKind<Interner>>>,
46+
InternedWrapper<SmallVec<[GenericArg; 2]>>,
47+
InternedWrapper<chalk_ir::TyData<Interner>>,
5748
InternedWrapper<chalk_ir::LifetimeData<Interner>>,
5849
InternedWrapper<chalk_ir::ConstData<Interner>>,
5950
InternedWrapper<Vec<chalk_ir::CanonicalVarKind<Interner>>>,
@@ -63,19 +54,21 @@ impl_internable!(
6354
);
6455

6556
impl chalk_ir::interner::Interner for Interner {
66-
type InternedType = Interned<InternedTypeInner>;
57+
type InternedType = Interned<InternedWrapper<chalk_ir::TyData<Interner>>>;
6758
type InternedLifetime = Interned<InternedWrapper<chalk_ir::LifetimeData<Self>>>;
6859
type InternedConst = Interned<InternedWrapper<chalk_ir::ConstData<Self>>>;
6960
type InternedConcreteConst = ();
7061
type InternedGenericArg = chalk_ir::GenericArgData<Self>;
7162
type InternedGoal = Arc<GoalData<Self>>;
7263
type InternedGoals = Vec<Goal<Self>>;
73-
type InternedSubstitution = Interned<InternedSubstitutionInner>;
64+
type InternedSubstitution = Interned<InternedWrapper<SmallVec<[GenericArg; 2]>>>;
7465
type InternedProgramClause = chalk_ir::ProgramClauseData<Self>;
7566
type InternedProgramClauses = Interned<InternedWrapper<Vec<chalk_ir::ProgramClause<Self>>>>;
76-
type InternedQuantifiedWhereClauses = Interned<InternedWrapper<Vec<chalk_ir::QuantifiedWhereClause<Self>>>>;
77-
type InternedVariableKinds = Interned<InternedVariableKindsInner>;
78-
type InternedCanonicalVarKinds = Interned<InternedWrapper<Vec<chalk_ir::CanonicalVarKind<Self>>>>;
67+
type InternedQuantifiedWhereClauses =
68+
Interned<InternedWrapper<Vec<chalk_ir::QuantifiedWhereClause<Self>>>>;
69+
type InternedVariableKinds = Interned<InternedWrapper<Vec<chalk_ir::VariableKind<Interner>>>>;
70+
type InternedCanonicalVarKinds =
71+
Interned<InternedWrapper<Vec<chalk_ir::CanonicalVarKind<Self>>>>;
7972
type InternedConstraints = Vec<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>>;
8073
type InternedVariances = Interned<InternedWrapper<Vec<chalk_ir::Variance>>>;
8174
type DefId = InternId;
@@ -230,7 +223,7 @@ impl chalk_ir::interner::Interner for Interner {
230223

231224
fn intern_ty(&self, kind: chalk_ir::TyKind<Self>) -> Self::InternedType {
232225
let flags = kind.compute_flags(self);
233-
Interned::new(InternedTypeInner(chalk_ir::TyData { kind, flags }))
226+
Interned::new(InternedWrapper(chalk_ir::TyData { kind, flags }))
234227
}
235228

236229
fn ty_data<'a>(&self, ty: &'a Self::InternedType) -> &'a chalk_ir::TyData<Self> {
@@ -302,7 +295,7 @@ impl chalk_ir::interner::Interner for Interner {
302295
&self,
303296
data: impl IntoIterator<Item = Result<GenericArg, E>>,
304297
) -> Result<Self::InternedSubstitution, E> {
305-
Ok(Interned::new(InternedSubstitutionInner(data.into_iter().collect::<Result<SmallVec<_>, _>>()?)))
298+
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
306299
}
307300

308301
fn substitution_data<'a>(
@@ -358,9 +351,7 @@ impl chalk_ir::interner::Interner for Interner {
358351
&self,
359352
data: impl IntoIterator<Item = Result<chalk_ir::VariableKind<Self>, E>>,
360353
) -> Result<Self::InternedVariableKinds, E> {
361-
Ok(Interned::new(InternedVariableKindsInner(
362-
data.into_iter().collect::<Result<Vec<_>, E>>()?,
363-
)))
354+
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
364355
}
365356

366357
fn variable_kinds_data<'a>(

0 commit comments

Comments
 (0)