22//! representation of the various objects Chalk deals with (types, goals etc.).
33
44use super :: tls;
5+ use crate :: GenericArg ;
56use base_db:: salsa:: InternId ;
67use chalk_ir:: { Goal , GoalData } ;
78use hir_def:: {
89 intern:: { impl_internable, InternStorage , Internable , Interned } ,
910 TypeAliasId ,
1011} ;
11- use crate :: GenericArg ;
1212use smallvec:: SmallVec ;
1313use std:: { fmt, sync:: Arc } ;
1414
@@ -30,15 +30,6 @@ pub(crate) type OpaqueTyId = chalk_ir::OpaqueTyId<Interner>;
3030pub ( crate ) type OpaqueTyDatum = chalk_solve:: rust_ir:: OpaqueTyDatum < Interner > ;
3131pub ( 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 ) ]
4334pub struct InternedWrapper < T > ( T ) ;
4435
@@ -51,9 +42,9 @@ impl<T> std::ops::Deref for InternedWrapper<T> {
5142}
5243
5344impl_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
6556impl 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