55//! its name suggest, is to provide an abstraction boundary for creating
66//! interned Chalk types.
77
8- use chalk_ir:: { GoalData , Parameter } ;
9-
10- use rustc_middle:: mir:: Mutability ;
8+ use rustc_middle:: mir:: interpret:: ConstValue ;
119use rustc_middle:: ty:: fold:: { TypeFoldable , TypeFolder , TypeVisitor } ;
12- use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
10+ use rustc_middle:: ty:: { self , AdtDef , Ty , TyCtxt } ;
1311
1412use rustc_hir:: def_id:: DefId ;
1513
@@ -19,27 +17,6 @@ use std::cmp::Ordering;
1917use std:: fmt;
2018use std:: hash:: { Hash , Hasher } ;
2119
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-
4320#[ derive( Copy , Clone ) ]
4421pub struct RustInterner < ' tcx > {
4522 pub tcx : TyCtxt < ' tcx > ,
@@ -86,16 +63,19 @@ impl fmt::Debug for RustInterner<'_> {
8663impl < ' tcx > chalk_ir:: interner:: Interner for RustInterner < ' tcx > {
8764 type InternedType = Box < chalk_ir:: TyData < Self > > ;
8865 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 > > ;
9069 type InternedGoal = Box < chalk_ir:: GoalData < Self > > ;
9170 type InternedGoals = Vec < chalk_ir:: Goal < Self > > ;
92- type InternedSubstitution = Vec < chalk_ir:: Parameter < Self > > ;
71+ type InternedSubstitution = Vec < chalk_ir:: GenericArg < Self > > ;
9372 type InternedProgramClause = Box < chalk_ir:: ProgramClauseData < Self > > ;
9473 type InternedProgramClauses = Vec < chalk_ir:: ProgramClause < Self > > ;
9574 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 ;
9979 type Identifier = ( ) ;
10080
10181 fn debug_program_clause_implication (
@@ -209,25 +189,39 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
209189 & lifetime
210190 }
211191
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 (
213201 & 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)
217211 }
218212
219- fn parameter_data < ' a > (
213+ fn generic_arg_data < ' a > (
220214 & 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
224218 }
225219
226- fn intern_goal ( & self , goal : GoalData < Self > ) -> Self :: InternedGoal {
220+ fn intern_goal ( & self , goal : chalk_ir :: GoalData < Self > ) -> Self :: InternedGoal {
227221 Box :: new ( goal)
228222 }
229223
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 > {
231225 & goal
232226 }
233227
@@ -244,15 +238,15 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
244238
245239 fn intern_substitution < E > (
246240 & self ,
247- data : impl IntoIterator < Item = Result < chalk_ir:: Parameter < Self > , E > > ,
241+ data : impl IntoIterator < Item = Result < chalk_ir:: GenericArg < Self > , E > > ,
248242 ) -> Result < Self :: InternedSubstitution , E > {
249243 data. into_iter ( ) . collect :: < Result < Vec < _ > , _ > > ( )
250244 }
251245
252246 fn substitution_data < ' a > (
253247 & self ,
254248 substitution : & ' a Self :: InternedSubstitution ,
255- ) -> & ' a [ Parameter < Self > ] {
249+ ) -> & ' a [ chalk_ir :: GenericArg < Self > ] {
256250 substitution
257251 }
258252
@@ -298,31 +292,31 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
298292 clauses
299293 }
300294
301- fn intern_parameter_kinds < E > (
295+ fn intern_generic_arg_kinds < E > (
302296 & 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 > {
305299 data. into_iter ( ) . collect :: < Result < Vec < _ > , _ > > ( )
306300 }
307301
308- fn parameter_kinds_data < ' a > (
302+ fn variable_kinds_data < ' a > (
309303 & self ,
310- parameter_kinds : & ' a Self :: InternedParameterKinds ,
311- ) -> & ' a [ chalk_ir:: ParameterKind < ( ) > ] {
304+ parameter_kinds : & ' a Self :: InternedVariableKinds ,
305+ ) -> & ' a [ chalk_ir:: VariableKind < Self > ] {
312306 parameter_kinds
313307 }
314308
315309 fn intern_canonical_var_kinds < E > (
316310 & 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 > > ,
318312 ) -> Result < Self :: InternedCanonicalVarKinds , E > {
319313 data. into_iter ( ) . collect :: < Result < Vec < _ > , _ > > ( )
320314 }
321315
322316 fn canonical_var_kinds_data < ' a > (
323317 & self ,
324318 canonical_var_kinds : & ' a Self :: InternedCanonicalVarKinds ,
325- ) -> & ' a [ chalk_ir:: ParameterKind < chalk_ir :: UniverseIndex > ] {
319+ ) -> & ' a [ chalk_ir:: CanonicalVarKind < Self > ] {
326320 canonical_var_kinds
327321 }
328322}
0 commit comments