@@ -59,53 +59,126 @@ impl chalk_ir::interner::Interner for Interner {
59
59
None
60
60
}
61
61
62
+ fn debug_ty ( _ty : & chalk_ir:: Ty < Self > , _fmt : & mut fmt:: Formatter < ' _ > ) -> Option < fmt:: Result > {
63
+ None
64
+ }
65
+
66
+ fn debug_lifetime (
67
+ _lifetime : & chalk_ir:: Lifetime < Self > ,
68
+ _fmt : & mut fmt:: Formatter < ' _ > ,
69
+ ) -> Option < fmt:: Result > {
70
+ None
71
+ }
72
+
73
+ fn debug_parameter (
74
+ _parameter : & Parameter < Self > ,
75
+ _fmt : & mut fmt:: Formatter < ' _ > ,
76
+ ) -> Option < fmt:: Result > {
77
+ None
78
+ }
79
+
80
+ fn debug_goal ( _goal : & Goal < Self > , _fmt : & mut fmt:: Formatter < ' _ > ) -> Option < fmt:: Result > {
81
+ None
82
+ }
83
+
84
+ fn debug_goals (
85
+ _goals : & chalk_ir:: Goals < Self > ,
86
+ _fmt : & mut fmt:: Formatter < ' _ > ,
87
+ ) -> Option < fmt:: Result > {
88
+ None
89
+ }
90
+
91
+ fn debug_program_clause_implication (
92
+ _pci : & chalk_ir:: ProgramClauseImplication < Self > ,
93
+ _fmt : & mut fmt:: Formatter < ' _ > ,
94
+ ) -> Option < fmt:: Result > {
95
+ None
96
+ }
97
+
98
+ fn debug_application_ty (
99
+ _application_ty : & chalk_ir:: ApplicationTy < Self > ,
100
+ _fmt : & mut fmt:: Formatter < ' _ > ,
101
+ ) -> Option < fmt:: Result > {
102
+ None
103
+ }
104
+
105
+ fn debug_substitution (
106
+ _substitution : & chalk_ir:: Substitution < Self > ,
107
+ _fmt : & mut fmt:: Formatter < ' _ > ,
108
+ ) -> Option < fmt:: Result > {
109
+ None
110
+ }
111
+
112
+ fn debug_separator_trait_ref (
113
+ _separator_trait_ref : & chalk_ir:: SeparatorTraitRef < Self > ,
114
+ _fmt : & mut fmt:: Formatter < ' _ > ,
115
+ ) -> Option < fmt:: Result > {
116
+ None
117
+ }
118
+
62
119
fn intern_ty ( & self , ty : chalk_ir:: TyData < Self > ) -> Box < chalk_ir:: TyData < Self > > {
63
120
Box :: new ( ty)
64
121
}
65
122
66
- fn ty_data ( ty : & Box < chalk_ir:: TyData < Self > > ) -> & chalk_ir:: TyData < Self > {
123
+ fn ty_data < ' a > ( & self , ty : & ' a Box < chalk_ir:: TyData < Self > > ) -> & ' a chalk_ir:: TyData < Self > {
67
124
ty
68
125
}
69
126
70
- fn intern_lifetime ( lifetime : chalk_ir:: LifetimeData < Self > ) -> chalk_ir:: LifetimeData < Self > {
127
+ fn intern_lifetime (
128
+ & self ,
129
+ lifetime : chalk_ir:: LifetimeData < Self > ,
130
+ ) -> chalk_ir:: LifetimeData < Self > {
71
131
lifetime
72
132
}
73
133
74
- fn lifetime_data ( lifetime : & chalk_ir:: LifetimeData < Self > ) -> & chalk_ir:: LifetimeData < Self > {
134
+ fn lifetime_data < ' a > (
135
+ & self ,
136
+ lifetime : & ' a chalk_ir:: LifetimeData < Self > ,
137
+ ) -> & ' a chalk_ir:: LifetimeData < Self > {
75
138
lifetime
76
139
}
77
140
78
- fn intern_parameter ( parameter : chalk_ir:: ParameterData < Self > ) -> chalk_ir:: ParameterData < Self > {
141
+ fn intern_parameter (
142
+ & self ,
143
+ parameter : chalk_ir:: ParameterData < Self > ,
144
+ ) -> chalk_ir:: ParameterData < Self > {
79
145
parameter
80
146
}
81
147
82
- fn parameter_data ( parameter : & chalk_ir:: ParameterData < Self > ) -> & chalk_ir:: ParameterData < Self > {
148
+ fn parameter_data < ' a > (
149
+ & self ,
150
+ parameter : & ' a chalk_ir:: ParameterData < Self > ,
151
+ ) -> & ' a chalk_ir:: ParameterData < Self > {
83
152
parameter
84
153
}
85
154
86
- fn intern_goal ( goal : GoalData < Self > ) -> Arc < GoalData < Self > > {
155
+ fn intern_goal ( & self , goal : GoalData < Self > ) -> Arc < GoalData < Self > > {
87
156
Arc :: new ( goal)
88
157
}
89
158
90
- fn intern_goals ( data : impl IntoIterator < Item = Goal < Self > > ) -> Self :: InternedGoals {
159
+ fn intern_goals ( & self , data : impl IntoIterator < Item = Goal < Self > > ) -> Self :: InternedGoals {
91
160
data. into_iter ( ) . collect ( )
92
161
}
93
162
94
- fn goal_data ( goal : & Arc < GoalData < Self > > ) -> & GoalData < Self > {
163
+ fn goal_data < ' a > ( & self , goal : & ' a Arc < GoalData < Self > > ) -> & ' a GoalData < Self > {
95
164
goal
96
165
}
97
166
98
- fn goals_data ( goals : & Vec < Goal < Interner > > ) -> & [ Goal < Interner > ] {
167
+ fn goals_data < ' a > ( & self , goals : & ' a Vec < Goal < Interner > > ) -> & ' a [ Goal < Interner > ] {
99
168
goals
100
169
}
101
170
102
171
fn intern_substitution < E > (
172
+ & self ,
103
173
data : impl IntoIterator < Item = Result < Parameter < Self > , E > > ,
104
174
) -> Result < Vec < Parameter < Self > > , E > {
105
175
data. into_iter ( ) . collect ( )
106
176
}
107
177
108
- fn substitution_data ( substitution : & Vec < Parameter < Self > > ) -> & [ Parameter < Self > ] {
178
+ fn substitution_data < ' a > (
179
+ & self ,
180
+ substitution : & ' a Vec < Parameter < Self > > ,
181
+ ) -> & ' a [ Parameter < Self > ] {
109
182
substitution
110
183
}
111
184
}
@@ -145,12 +218,14 @@ impl ToChalk for Ty {
145
218
Ty :: Apply ( apply_ty) => {
146
219
let name = apply_ty. ctor . to_chalk ( db) ;
147
220
let substitution = apply_ty. parameters . to_chalk ( db) ;
148
- chalk_ir:: ApplicationTy { name, substitution } . cast ( ) . intern ( & Interner )
221
+ chalk_ir:: ApplicationTy { name, substitution } . cast ( & Interner ) . intern ( & Interner )
149
222
}
150
223
Ty :: Projection ( proj_ty) => {
151
224
let associated_ty_id = proj_ty. associated_ty . to_chalk ( db) ;
152
225
let substitution = proj_ty. parameters . to_chalk ( db) ;
153
- chalk_ir:: AliasTy { associated_ty_id, substitution } . cast ( ) . intern ( & Interner )
226
+ chalk_ir:: AliasTy { associated_ty_id, substitution }
227
+ . cast ( & Interner )
228
+ . intern ( & Interner )
154
229
}
155
230
Ty :: Placeholder ( id) => {
156
231
let interned_id = db. intern_type_param_id ( id) ;
@@ -173,14 +248,14 @@ impl ToChalk for Ty {
173
248
chalk_ir:: TyData :: Dyn ( bounded_ty) . intern ( & Interner )
174
249
}
175
250
Ty :: Opaque ( _) | Ty :: Unknown => {
176
- let substitution = chalk_ir:: Substitution :: empty ( ) ;
251
+ let substitution = chalk_ir:: Substitution :: empty ( & Interner ) ;
177
252
let name = TypeName :: Error ;
178
- chalk_ir:: ApplicationTy { name, substitution } . cast ( ) . intern ( & Interner )
253
+ chalk_ir:: ApplicationTy { name, substitution } . cast ( & Interner ) . intern ( & Interner )
179
254
}
180
255
}
181
256
}
182
257
fn from_chalk ( db : & dyn HirDatabase , chalk : chalk_ir:: Ty < Interner > ) -> Self {
183
- match chalk. data ( ) . clone ( ) {
258
+ match chalk. data ( & Interner ) . clone ( ) {
184
259
chalk_ir:: TyData :: Apply ( apply_ty) => match apply_ty. name {
185
260
TypeName :: Error => Ty :: Unknown ,
186
261
_ => {
@@ -218,13 +293,13 @@ impl ToChalk for Substs {
218
293
type Chalk = chalk_ir:: Substitution < Interner > ;
219
294
220
295
fn to_chalk ( self , db : & dyn HirDatabase ) -> chalk_ir:: Substitution < Interner > {
221
- chalk_ir:: Substitution :: from ( self . iter ( ) . map ( |ty| ty. clone ( ) . to_chalk ( db) ) )
296
+ chalk_ir:: Substitution :: from ( & Interner , self . iter ( ) . map ( |ty| ty. clone ( ) . to_chalk ( db) ) )
222
297
}
223
298
224
299
fn from_chalk ( db : & dyn HirDatabase , parameters : chalk_ir:: Substitution < Interner > ) -> Substs {
225
300
let tys = parameters
226
- . into_iter ( )
227
- . map ( |p| match p. ty ( ) {
301
+ . iter ( & Interner )
302
+ . map ( |p| match p. ty ( & Interner ) {
228
303
Some ( ty) => from_chalk ( db, ty. clone ( ) ) ,
229
304
None => unimplemented ! ( ) ,
230
305
} )
@@ -400,8 +475,8 @@ impl ToChalk for Obligation {
400
475
401
476
fn to_chalk ( self , db : & dyn HirDatabase ) -> chalk_ir:: DomainGoal < Interner > {
402
477
match self {
403
- Obligation :: Trait ( tr) => tr. to_chalk ( db) . cast ( ) ,
404
- Obligation :: Projection ( pr) => pr. to_chalk ( db) . cast ( ) ,
478
+ Obligation :: Trait ( tr) => tr. to_chalk ( db) . cast ( & Interner ) ,
479
+ Obligation :: Projection ( pr) => pr. to_chalk ( db) . cast ( & Interner ) ,
405
480
}
406
481
}
407
482
@@ -438,8 +513,8 @@ impl ToChalk for Arc<super::TraitEnvironment> {
438
513
continue ;
439
514
}
440
515
let program_clause: chalk_ir:: ProgramClause < Interner > =
441
- pred. clone ( ) . to_chalk ( db) . cast ( ) ;
442
- clauses. push ( program_clause. into_from_env_clause ( ) ) ;
516
+ pred. clone ( ) . to_chalk ( db) . cast ( & Interner ) ;
517
+ clauses. push ( program_clause. into_from_env_clause ( & Interner ) ) ;
443
518
}
444
519
chalk_ir:: Environment :: new ( ) . add_clauses ( clauses)
445
520
}
@@ -578,9 +653,9 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
578
653
. map ( |impl_| impl_. to_chalk ( self . db ) )
579
654
. collect ( ) ;
580
655
581
- let ty: Ty = from_chalk ( self . db , parameters[ 0 ] . assert_ty_ref ( ) . clone ( ) ) ;
656
+ let ty: Ty = from_chalk ( self . db , parameters[ 0 ] . assert_ty_ref ( & Interner ) . clone ( ) ) ;
582
657
let arg: Option < Ty > =
583
- parameters. get ( 1 ) . map ( |p| from_chalk ( self . db , p. assert_ty_ref ( ) . clone ( ) ) ) ;
658
+ parameters. get ( 1 ) . map ( |p| from_chalk ( self . db , p. assert_ty_ref ( & Interner ) . clone ( ) ) ) ;
584
659
585
660
builtin:: get_builtin_impls ( self . db , self . krate , & ty, & arg, trait_, |i| {
586
661
result. push ( i. to_chalk ( self . db ) )
0 commit comments