5
5
//! its name suggest, is to provide an abstraction boundary for creating
6
6
//! interned Chalk types.
7
7
8
- use chalk_ir:: { GoalData , Parameter } ;
9
-
10
- use rustc_middle:: mir:: Mutability ;
8
+ use rustc_middle:: mir:: interpret:: ConstValue ;
11
9
use rustc_middle:: ty:: fold:: { TypeFoldable , TypeFolder , TypeVisitor } ;
12
- use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
10
+ use rustc_middle:: ty:: { self , AdtDef , Ty , TyCtxt } ;
13
11
14
12
use rustc_hir:: def_id:: DefId ;
15
13
@@ -19,27 +17,6 @@ use std::cmp::Ordering;
19
17
use std:: fmt;
20
18
use std:: hash:: { Hash , Hasher } ;
21
19
22
- /// Since Chalk doesn't have full support for all Rust builtin types yet, we
23
- /// need to use an enum here, rather than just `DefId`.
24
- #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , PartialOrd , Ord ) ]
25
- pub enum RustDefId {
26
- Adt ( DefId ) ,
27
- Str ,
28
- Never ,
29
- Slice ,
30
- Array ,
31
- Ref ( Mutability ) ,
32
- RawPtr ,
33
-
34
- Trait ( DefId ) ,
35
-
36
- Impl ( DefId ) ,
37
-
38
- FnDef ( DefId ) ,
39
-
40
- AssocTy ( DefId ) ,
41
- }
42
-
43
20
#[ derive( Copy , Clone ) ]
44
21
pub struct RustInterner < ' tcx > {
45
22
pub tcx : TyCtxt < ' tcx > ,
@@ -86,16 +63,19 @@ impl fmt::Debug for RustInterner<'_> {
86
63
impl < ' tcx > chalk_ir:: interner:: Interner for RustInterner < ' tcx > {
87
64
type InternedType = Box < chalk_ir:: TyData < Self > > ;
88
65
type InternedLifetime = Box < chalk_ir:: LifetimeData < Self > > ;
89
- type InternedParameter = Box < chalk_ir:: ParameterData < Self > > ;
66
+ type InternedConst = Box < chalk_ir:: ConstData < Self > > ;
67
+ type InternedConcreteConst = ConstValue < ' tcx > ;
68
+ type InternedGenericArg = Box < chalk_ir:: GenericArgData < Self > > ;
90
69
type InternedGoal = Box < chalk_ir:: GoalData < Self > > ;
91
70
type InternedGoals = Vec < chalk_ir:: Goal < Self > > ;
92
- type InternedSubstitution = Vec < chalk_ir:: Parameter < Self > > ;
71
+ type InternedSubstitution = Vec < chalk_ir:: GenericArg < Self > > ;
93
72
type InternedProgramClause = Box < chalk_ir:: ProgramClauseData < Self > > ;
94
73
type InternedProgramClauses = Vec < chalk_ir:: ProgramClause < Self > > ;
95
74
type InternedQuantifiedWhereClauses = Vec < chalk_ir:: QuantifiedWhereClause < Self > > ;
96
- type InternedParameterKinds = Vec < chalk_ir:: ParameterKind < ( ) > > ;
97
- type InternedCanonicalVarKinds = Vec < chalk_ir:: ParameterKind < chalk_ir:: UniverseIndex > > ;
98
- type DefId = RustDefId ;
75
+ type InternedVariableKinds = Vec < chalk_ir:: VariableKind < Self > > ;
76
+ type InternedCanonicalVarKinds = Vec < chalk_ir:: CanonicalVarKind < Self > > ;
77
+ type DefId = DefId ;
78
+ type InternedAdtId = & ' tcx AdtDef ;
99
79
type Identifier = ( ) ;
100
80
101
81
fn debug_program_clause_implication (
@@ -209,25 +189,39 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
209
189
& lifetime
210
190
}
211
191
212
- fn intern_parameter (
192
+ fn intern_const ( & self , constant : chalk_ir:: ConstData < Self > ) -> Self :: InternedConst {
193
+ Box :: new ( constant)
194
+ }
195
+
196
+ fn const_data < ' a > ( & self , constant : & ' a Self :: InternedConst ) -> & ' a chalk_ir:: ConstData < Self > {
197
+ & constant
198
+ }
199
+
200
+ fn const_eq (
213
201
& self ,
214
- parameter : chalk_ir:: ParameterData < Self > ,
215
- ) -> Self :: InternedParameter {
216
- Box :: new ( parameter)
202
+ _ty : & Self :: InternedType ,
203
+ c1 : & Self :: InternedConcreteConst ,
204
+ c2 : & Self :: InternedConcreteConst ,
205
+ ) -> bool {
206
+ c1 == c2
207
+ }
208
+
209
+ fn intern_generic_arg ( & self , data : chalk_ir:: GenericArgData < Self > ) -> Self :: InternedGenericArg {
210
+ Box :: new ( data)
217
211
}
218
212
219
- fn parameter_data < ' a > (
213
+ fn generic_arg_data < ' a > (
220
214
& self ,
221
- parameter : & ' a Self :: InternedParameter ,
222
- ) -> & ' a chalk_ir:: ParameterData < Self > {
223
- & parameter
215
+ data : & ' a Self :: InternedGenericArg ,
216
+ ) -> & ' a chalk_ir:: GenericArgData < Self > {
217
+ & data
224
218
}
225
219
226
- fn intern_goal ( & self , goal : GoalData < Self > ) -> Self :: InternedGoal {
220
+ fn intern_goal ( & self , goal : chalk_ir :: GoalData < Self > ) -> Self :: InternedGoal {
227
221
Box :: new ( goal)
228
222
}
229
223
230
- fn goal_data < ' a > ( & self , goal : & ' a Self :: InternedGoal ) -> & ' a GoalData < Self > {
224
+ fn goal_data < ' a > ( & self , goal : & ' a Self :: InternedGoal ) -> & ' a chalk_ir :: GoalData < Self > {
231
225
& goal
232
226
}
233
227
@@ -244,15 +238,15 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
244
238
245
239
fn intern_substitution < E > (
246
240
& self ,
247
- data : impl IntoIterator < Item = Result < chalk_ir:: Parameter < Self > , E > > ,
241
+ data : impl IntoIterator < Item = Result < chalk_ir:: GenericArg < Self > , E > > ,
248
242
) -> Result < Self :: InternedSubstitution , E > {
249
243
data. into_iter ( ) . collect :: < Result < Vec < _ > , _ > > ( )
250
244
}
251
245
252
246
fn substitution_data < ' a > (
253
247
& self ,
254
248
substitution : & ' a Self :: InternedSubstitution ,
255
- ) -> & ' a [ Parameter < Self > ] {
249
+ ) -> & ' a [ chalk_ir :: GenericArg < Self > ] {
256
250
substitution
257
251
}
258
252
@@ -298,31 +292,31 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
298
292
clauses
299
293
}
300
294
301
- fn intern_parameter_kinds < E > (
295
+ fn intern_generic_arg_kinds < E > (
302
296
& self ,
303
- data : impl IntoIterator < Item = Result < chalk_ir:: ParameterKind < ( ) > , E > > ,
304
- ) -> Result < Self :: InternedParameterKinds , E > {
297
+ data : impl IntoIterator < Item = Result < chalk_ir:: VariableKind < Self > , E > > ,
298
+ ) -> Result < Self :: InternedVariableKinds , E > {
305
299
data. into_iter ( ) . collect :: < Result < Vec < _ > , _ > > ( )
306
300
}
307
301
308
- fn parameter_kinds_data < ' a > (
302
+ fn variable_kinds_data < ' a > (
309
303
& self ,
310
- parameter_kinds : & ' a Self :: InternedParameterKinds ,
311
- ) -> & ' a [ chalk_ir:: ParameterKind < ( ) > ] {
304
+ parameter_kinds : & ' a Self :: InternedVariableKinds ,
305
+ ) -> & ' a [ chalk_ir:: VariableKind < Self > ] {
312
306
parameter_kinds
313
307
}
314
308
315
309
fn intern_canonical_var_kinds < E > (
316
310
& self ,
317
- data : impl IntoIterator < Item = Result < chalk_ir:: ParameterKind < chalk_ir :: UniverseIndex > , E > > ,
311
+ data : impl IntoIterator < Item = Result < chalk_ir:: CanonicalVarKind < Self > , E > > ,
318
312
) -> Result < Self :: InternedCanonicalVarKinds , E > {
319
313
data. into_iter ( ) . collect :: < Result < Vec < _ > , _ > > ( )
320
314
}
321
315
322
316
fn canonical_var_kinds_data < ' a > (
323
317
& self ,
324
318
canonical_var_kinds : & ' a Self :: InternedCanonicalVarKinds ,
325
- ) -> & ' a [ chalk_ir:: ParameterKind < chalk_ir :: UniverseIndex > ] {
319
+ ) -> & ' a [ chalk_ir:: CanonicalVarKind < Self > ] {
326
320
canonical_var_kinds
327
321
}
328
322
}
0 commit comments