@@ -32,6 +32,9 @@ impl chalk_ir::interner::Interner for Interner {
3232 type InternedGoal = Arc < GoalData < Self > > ;
3333 type InternedGoals = Vec < Goal < Self > > ;
3434 type InternedSubstitution = Vec < Parameter < Self > > ;
35+ type InternedProgramClause = chalk_ir:: ProgramClauseData < Self > ;
36+ type InternedProgramClauses = Vec < chalk_ir:: ProgramClause < Self > > ;
37+ type InternedQuantifiedWhereClauses = Vec < chalk_ir:: QuantifiedWhereClause < Self > > ;
3538 type Identifier = TypeAliasId ;
3639 type DefId = InternId ;
3740
@@ -181,6 +184,48 @@ impl chalk_ir::interner::Interner for Interner {
181184 ) -> & ' a [ Parameter < Self > ] {
182185 substitution
183186 }
187+
188+ fn intern_program_clause (
189+ & self ,
190+ data : chalk_ir:: ProgramClauseData < Self > ,
191+ ) -> chalk_ir:: ProgramClauseData < Self > {
192+ data
193+ }
194+
195+ fn program_clause_data < ' a > (
196+ & self ,
197+ clause : & ' a chalk_ir:: ProgramClauseData < Self > ,
198+ ) -> & ' a chalk_ir:: ProgramClauseData < Self > {
199+ clause
200+ }
201+
202+ fn intern_program_clauses (
203+ & self ,
204+ data : impl IntoIterator < Item = chalk_ir:: ProgramClause < Self > > ,
205+ ) -> Vec < chalk_ir:: ProgramClause < Self > > {
206+ data. into_iter ( ) . collect ( )
207+ }
208+
209+ fn program_clauses_data < ' a > (
210+ & self ,
211+ clauses : & ' a Vec < chalk_ir:: ProgramClause < Self > > ,
212+ ) -> & ' a [ chalk_ir:: ProgramClause < Self > ] {
213+ clauses
214+ }
215+
216+ fn intern_quantified_where_clauses (
217+ & self ,
218+ data : impl IntoIterator < Item = chalk_ir:: QuantifiedWhereClause < Self > > ,
219+ ) -> Self :: InternedQuantifiedWhereClauses {
220+ data. into_iter ( ) . collect ( )
221+ }
222+
223+ fn quantified_where_clauses_data < ' a > (
224+ & self ,
225+ clauses : & ' a Self :: InternedQuantifiedWhereClauses ,
226+ ) -> & ' a [ chalk_ir:: QuantifiedWhereClause < Self > ] {
227+ clauses
228+ }
184229}
185230
186231impl chalk_ir:: interner:: HasInterner for Interner {
@@ -238,12 +283,10 @@ impl ToChalk for Ty {
238283 Ty :: Bound ( idx) => chalk_ir:: TyData :: BoundVar ( idx) . intern ( & Interner ) ,
239284 Ty :: Infer ( _infer_ty) => panic ! ( "uncanonicalized infer ty" ) ,
240285 Ty :: Dyn ( predicates) => {
241- let where_clauses = predicates
242- . iter ( )
243- . filter ( |p| !p. is_error ( ) )
244- . cloned ( )
245- . map ( |p| p. to_chalk ( db) )
246- . collect ( ) ;
286+ let where_clauses = chalk_ir:: QuantifiedWhereClauses :: from (
287+ & Interner ,
288+ predicates. iter ( ) . filter ( |p| !p. is_error ( ) ) . cloned ( ) . map ( |p| p. to_chalk ( db) ) ,
289+ ) ;
247290 let bounded_ty = chalk_ir:: DynTy { bounds : make_binders ( where_clauses, 1 ) } ;
248291 chalk_ir:: TyData :: Dyn ( bounded_ty) . intern ( & Interner )
249292 }
@@ -281,8 +324,12 @@ impl ToChalk for Ty {
281324 chalk_ir:: TyData :: InferenceVar ( _iv) => Ty :: Unknown ,
282325 chalk_ir:: TyData :: Dyn ( where_clauses) => {
283326 assert_eq ! ( where_clauses. bounds. binders. len( ) , 1 ) ;
284- let predicates =
285- where_clauses. bounds . value . into_iter ( ) . map ( |c| from_chalk ( db, c) ) . collect ( ) ;
327+ let predicates = where_clauses
328+ . bounds
329+ . skip_binders ( )
330+ . iter ( & Interner )
331+ . map ( |c| from_chalk ( db, c. clone ( ) ) )
332+ . collect ( ) ;
286333 Ty :: Dyn ( predicates)
287334 }
288335 }
@@ -426,7 +473,7 @@ impl ToChalk for GenericPredicate {
426473 ) -> GenericPredicate {
427474 // we don't produce any where clauses with binders and can't currently deal with them
428475 match where_clause
429- . value
476+ . skip_binders ( )
430477 . shifted_out ( & Interner )
431478 . expect ( "unexpected bound vars in where clause" )
432479 {
@@ -521,7 +568,7 @@ impl ToChalk for Arc<super::TraitEnvironment> {
521568 pred. clone ( ) . to_chalk ( db) . cast ( & Interner ) ;
522569 clauses. push ( program_clause. into_from_env_clause ( & Interner ) ) ;
523570 }
524- chalk_ir:: Environment :: new ( ) . add_clauses ( clauses)
571+ chalk_ir:: Environment :: new ( & Interner ) . add_clauses ( & Interner , clauses)
525572 }
526573
527574 fn from_chalk (
@@ -603,10 +650,10 @@ impl ToChalk for builtin::BuiltinImplAssocTyValueData {
603650}
604651
605652fn make_binders < T > ( value : T , num_vars : usize ) -> chalk_ir:: Binders < T > {
606- chalk_ir:: Binders {
653+ chalk_ir:: Binders :: new (
654+ std:: iter:: repeat ( chalk_ir:: ParameterKind :: Ty ( ( ) ) ) . take ( num_vars) . collect ( ) ,
607655 value,
608- binders : std:: iter:: repeat ( chalk_ir:: ParameterKind :: Ty ( ( ) ) ) . take ( num_vars) . collect ( ) ,
609- }
656+ )
610657}
611658
612659fn convert_where_clauses (
@@ -696,6 +743,12 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
696743 fn interner ( & self ) -> & Interner {
697744 & Interner
698745 }
746+ fn well_known_trait_id (
747+ & self ,
748+ _well_known_trait : chalk_rust_ir:: WellKnownTrait ,
749+ ) -> chalk_ir:: TraitId < Interner > {
750+ unimplemented ! ( )
751+ }
699752}
700753
701754pub ( crate ) fn associated_ty_data_query (
0 commit comments