Cleanup
This commit is contained in:
parent
417473aa3d
commit
37ff15ad83
@ -462,7 +462,11 @@ fn infer_expr_inner(&mut self, tgt_expr: ExprId, expected: &Expectation) -> Ty {
|
|||||||
};
|
};
|
||||||
match canonicalized.decanonicalize_ty(derefed_ty.value).kind(&Interner) {
|
match canonicalized.decanonicalize_ty(derefed_ty.value).kind(&Interner) {
|
||||||
TyKind::Tuple(_, substs) => name.as_tuple_index().and_then(|idx| {
|
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) => {
|
TyKind::Adt(AdtId(hir_def::AdtId::StructId(s)), parameters) => {
|
||||||
let local_id = self.db.struct_data(*s).variant_data.field(name)?;
|
let local_id = self.db.struct_data(*s).variant_data.field(name)?;
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
//! representation of the various objects Chalk deals with (types, goals etc.).
|
//! representation of the various objects Chalk deals with (types, goals etc.).
|
||||||
|
|
||||||
use super::tls;
|
use super::tls;
|
||||||
|
use crate::GenericArg;
|
||||||
use base_db::salsa::InternId;
|
use base_db::salsa::InternId;
|
||||||
use chalk_ir::{Goal, GoalData};
|
use chalk_ir::{Goal, GoalData};
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
intern::{impl_internable, InternStorage, Internable, Interned},
|
intern::{impl_internable, InternStorage, Internable, Interned},
|
||||||
TypeAliasId,
|
TypeAliasId,
|
||||||
};
|
};
|
||||||
use crate::GenericArg;
|
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::{fmt, sync::Arc};
|
use std::{fmt, sync::Arc};
|
||||||
|
|
||||||
@ -30,15 +30,6 @@
|
|||||||
pub(crate) type OpaqueTyDatum = chalk_solve::rust_ir::OpaqueTyDatum<Interner>;
|
pub(crate) type OpaqueTyDatum = chalk_solve::rust_ir::OpaqueTyDatum<Interner>;
|
||||||
pub(crate) type Variances = chalk_ir::Variances<Interner>;
|
pub(crate) type Variances = chalk_ir::Variances<Interner>;
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Hash, Debug)]
|
|
||||||
pub struct InternedVariableKindsInner(Vec<chalk_ir::VariableKind<Interner>>);
|
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Hash, Debug)]
|
|
||||||
pub struct InternedSubstitutionInner(SmallVec<[GenericArg; 2]>);
|
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Hash, Debug)]
|
|
||||||
pub struct InternedTypeInner(chalk_ir::TyData<Interner>);
|
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Hash, Debug)]
|
#[derive(PartialEq, Eq, Hash, Debug)]
|
||||||
pub struct InternedWrapper<T>(T);
|
pub struct InternedWrapper<T>(T);
|
||||||
|
|
||||||
@ -51,9 +42,9 @@ fn deref(&self) -> &Self::Target {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl_internable!(
|
impl_internable!(
|
||||||
InternedVariableKindsInner,
|
InternedWrapper<Vec<chalk_ir::VariableKind<Interner>>>,
|
||||||
InternedSubstitutionInner,
|
InternedWrapper<SmallVec<[GenericArg; 2]>>,
|
||||||
InternedTypeInner,
|
InternedWrapper<chalk_ir::TyData<Interner>>,
|
||||||
InternedWrapper<chalk_ir::LifetimeData<Interner>>,
|
InternedWrapper<chalk_ir::LifetimeData<Interner>>,
|
||||||
InternedWrapper<chalk_ir::ConstData<Interner>>,
|
InternedWrapper<chalk_ir::ConstData<Interner>>,
|
||||||
InternedWrapper<Vec<chalk_ir::CanonicalVarKind<Interner>>>,
|
InternedWrapper<Vec<chalk_ir::CanonicalVarKind<Interner>>>,
|
||||||
@ -63,19 +54,21 @@ fn deref(&self) -> &Self::Target {
|
|||||||
);
|
);
|
||||||
|
|
||||||
impl chalk_ir::interner::Interner for Interner {
|
impl chalk_ir::interner::Interner for Interner {
|
||||||
type InternedType = Interned<InternedTypeInner>;
|
type InternedType = Interned<InternedWrapper<chalk_ir::TyData<Interner>>>;
|
||||||
type InternedLifetime = Interned<InternedWrapper<chalk_ir::LifetimeData<Self>>>;
|
type InternedLifetime = Interned<InternedWrapper<chalk_ir::LifetimeData<Self>>>;
|
||||||
type InternedConst = Interned<InternedWrapper<chalk_ir::ConstData<Self>>>;
|
type InternedConst = Interned<InternedWrapper<chalk_ir::ConstData<Self>>>;
|
||||||
type InternedConcreteConst = ();
|
type InternedConcreteConst = ();
|
||||||
type InternedGenericArg = chalk_ir::GenericArgData<Self>;
|
type InternedGenericArg = chalk_ir::GenericArgData<Self>;
|
||||||
type InternedGoal = Arc<GoalData<Self>>;
|
type InternedGoal = Arc<GoalData<Self>>;
|
||||||
type InternedGoals = Vec<Goal<Self>>;
|
type InternedGoals = Vec<Goal<Self>>;
|
||||||
type InternedSubstitution = Interned<InternedSubstitutionInner>;
|
type InternedSubstitution = Interned<InternedWrapper<SmallVec<[GenericArg; 2]>>>;
|
||||||
type InternedProgramClause = chalk_ir::ProgramClauseData<Self>;
|
type InternedProgramClause = chalk_ir::ProgramClauseData<Self>;
|
||||||
type InternedProgramClauses = Interned<InternedWrapper<Vec<chalk_ir::ProgramClause<Self>>>>;
|
type InternedProgramClauses = Interned<InternedWrapper<Vec<chalk_ir::ProgramClause<Self>>>>;
|
||||||
type InternedQuantifiedWhereClauses = Interned<InternedWrapper<Vec<chalk_ir::QuantifiedWhereClause<Self>>>>;
|
type InternedQuantifiedWhereClauses =
|
||||||
type InternedVariableKinds = Interned<InternedVariableKindsInner>;
|
Interned<InternedWrapper<Vec<chalk_ir::QuantifiedWhereClause<Self>>>>;
|
||||||
type InternedCanonicalVarKinds = Interned<InternedWrapper<Vec<chalk_ir::CanonicalVarKind<Self>>>>;
|
type InternedVariableKinds = Interned<InternedWrapper<Vec<chalk_ir::VariableKind<Interner>>>>;
|
||||||
|
type InternedCanonicalVarKinds =
|
||||||
|
Interned<InternedWrapper<Vec<chalk_ir::CanonicalVarKind<Self>>>>;
|
||||||
type InternedConstraints = Vec<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>>;
|
type InternedConstraints = Vec<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>>;
|
||||||
type InternedVariances = Interned<InternedWrapper<Vec<chalk_ir::Variance>>>;
|
type InternedVariances = Interned<InternedWrapper<Vec<chalk_ir::Variance>>>;
|
||||||
type DefId = InternId;
|
type DefId = InternId;
|
||||||
@ -230,7 +223,7 @@ fn debug_quantified_where_clauses(
|
|||||||
|
|
||||||
fn intern_ty(&self, kind: chalk_ir::TyKind<Self>) -> Self::InternedType {
|
fn intern_ty(&self, kind: chalk_ir::TyKind<Self>) -> Self::InternedType {
|
||||||
let flags = kind.compute_flags(self);
|
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<Self> {
|
fn ty_data<'a>(&self, ty: &'a Self::InternedType) -> &'a chalk_ir::TyData<Self> {
|
||||||
@ -302,7 +295,7 @@ fn intern_substitution<E>(
|
|||||||
&self,
|
&self,
|
||||||
data: impl IntoIterator<Item = Result<GenericArg, E>>,
|
data: impl IntoIterator<Item = Result<GenericArg, E>>,
|
||||||
) -> Result<Self::InternedSubstitution, E> {
|
) -> Result<Self::InternedSubstitution, E> {
|
||||||
Ok(Interned::new(InternedSubstitutionInner(data.into_iter().collect::<Result<SmallVec<_>, _>>()?)))
|
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn substitution_data<'a>(
|
fn substitution_data<'a>(
|
||||||
@ -358,9 +351,7 @@ fn intern_generic_arg_kinds<E>(
|
|||||||
&self,
|
&self,
|
||||||
data: impl IntoIterator<Item = Result<chalk_ir::VariableKind<Self>, E>>,
|
data: impl IntoIterator<Item = Result<chalk_ir::VariableKind<Self>, E>>,
|
||||||
) -> Result<Self::InternedVariableKinds, E> {
|
) -> Result<Self::InternedVariableKinds, E> {
|
||||||
Ok(Interned::new(InternedVariableKindsInner(
|
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
|
||||||
data.into_iter().collect::<Result<Vec<_>, E>>()?,
|
|
||||||
)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn variable_kinds_data<'a>(
|
fn variable_kinds_data<'a>(
|
||||||
|
Loading…
Reference in New Issue
Block a user