2
2
//! representation of the various objects Chalk deals with (types, goals etc.).
3
3
4
4
use super :: tls;
5
+ use crate :: GenericArg ;
5
6
use base_db:: salsa:: InternId ;
6
7
use chalk_ir:: { Goal , GoalData } ;
7
8
use hir_def:: {
8
9
intern:: { impl_internable, InternStorage , Internable , Interned } ,
9
10
TypeAliasId ,
10
11
} ;
11
- use crate :: GenericArg ;
12
12
use smallvec:: SmallVec ;
13
13
use std:: { fmt, sync:: Arc } ;
14
14
@@ -30,15 +30,6 @@ pub(crate) type OpaqueTyId = chalk_ir::OpaqueTyId<Interner>;
30
30
pub ( crate ) type OpaqueTyDatum = chalk_solve:: rust_ir:: OpaqueTyDatum < Interner > ;
31
31
pub ( crate ) type Variances = chalk_ir:: Variances < Interner > ;
32
32
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
-
42
33
#[ derive( PartialEq , Eq , Hash , Debug ) ]
43
34
pub struct InternedWrapper < T > ( T ) ;
44
35
@@ -51,9 +42,9 @@ impl<T> std::ops::Deref for InternedWrapper<T> {
51
42
}
52
43
53
44
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 >> ,
57
48
InternedWrapper <chalk_ir:: LifetimeData <Interner >>,
58
49
InternedWrapper <chalk_ir:: ConstData <Interner >>,
59
50
InternedWrapper <Vec <chalk_ir:: CanonicalVarKind <Interner >>>,
@@ -63,19 +54,21 @@ impl_internable!(
63
54
) ;
64
55
65
56
impl chalk_ir:: interner:: Interner for Interner {
66
- type InternedType = Interned < InternedTypeInner > ;
57
+ type InternedType = Interned < InternedWrapper < chalk_ir :: TyData < Interner > > > ;
67
58
type InternedLifetime = Interned < InternedWrapper < chalk_ir:: LifetimeData < Self > > > ;
68
59
type InternedConst = Interned < InternedWrapper < chalk_ir:: ConstData < Self > > > ;
69
60
type InternedConcreteConst = ( ) ;
70
61
type InternedGenericArg = chalk_ir:: GenericArgData < Self > ;
71
62
type InternedGoal = Arc < GoalData < Self > > ;
72
63
type InternedGoals = Vec < Goal < Self > > ;
73
- type InternedSubstitution = Interned < InternedSubstitutionInner > ;
64
+ type InternedSubstitution = Interned < InternedWrapper < SmallVec < [ GenericArg ; 2 ] > > > ;
74
65
type InternedProgramClause = chalk_ir:: ProgramClauseData < Self > ;
75
66
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 > > > > ;
79
72
type InternedConstraints = Vec < chalk_ir:: InEnvironment < chalk_ir:: Constraint < Self > > > ;
80
73
type InternedVariances = Interned < InternedWrapper < Vec < chalk_ir:: Variance > > > ;
81
74
type DefId = InternId ;
@@ -230,7 +223,7 @@ impl chalk_ir::interner::Interner for Interner {
230
223
231
224
fn intern_ty ( & self , kind : chalk_ir:: TyKind < Self > ) -> Self :: InternedType {
232
225
let flags = kind. compute_flags ( self ) ;
233
- Interned :: new ( InternedTypeInner ( chalk_ir:: TyData { kind, flags } ) )
226
+ Interned :: new ( InternedWrapper ( chalk_ir:: TyData { kind, flags } ) )
234
227
}
235
228
236
229
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 {
302
295
& self ,
303
296
data : impl IntoIterator < Item = Result < GenericArg , E > > ,
304
297
) -> 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 < _ , _ > > ( ) ?) ) )
306
299
}
307
300
308
301
fn substitution_data < ' a > (
@@ -358,9 +351,7 @@ impl chalk_ir::interner::Interner for Interner {
358
351
& self ,
359
352
data : impl IntoIterator < Item = Result < chalk_ir:: VariableKind < Self > , E > > ,
360
353
) -> 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 < _ , _ > > ( ) ?) ) )
364
355
}
365
356
366
357
fn variable_kinds_data < ' a > (
0 commit comments