@@ -50,6 +50,19 @@ impl<'tcx> RustIrDatabase<'tcx> {
50
50
. map ( |wc| wc. fold_with ( & mut regions_substitutor) )
51
51
. filter_map ( |wc| LowerInto :: < Option < chalk_ir:: QuantifiedWhereClause < RustInterner < ' tcx > > > > :: lower_into ( wc, & self . interner ) ) . collect ( )
52
52
}
53
+
54
+ fn bounds_for < T > ( & self , def_id : DefId , bound_vars : SubstsRef < ' tcx > ) -> Vec < T >
55
+ where
56
+ ty:: Predicate < ' tcx > : LowerInto < ' tcx , std:: option:: Option < T > > ,
57
+ {
58
+ self . interner
59
+ . tcx
60
+ . explicit_item_bounds ( def_id)
61
+ . iter ( )
62
+ . map ( |( bound, _) | bound. subst ( self . interner . tcx , & bound_vars) )
63
+ . filter_map ( |bound| LowerInto :: < Option < _ > > :: lower_into ( bound, & self . interner ) )
64
+ . collect ( )
65
+ }
53
66
}
54
67
55
68
impl < ' tcx > chalk_solve:: RustIrDatabase < RustInterner < ' tcx > > for RustIrDatabase < ' tcx > {
@@ -75,19 +88,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
75
88
let binders = binders_for ( & self . interner , bound_vars) ;
76
89
77
90
let where_clauses = self . where_clauses_for ( def_id, bound_vars) ;
78
-
79
- let bounds = self
80
- . interner
81
- . tcx
82
- . explicit_item_bounds ( def_id)
83
- . iter ( )
84
- . map ( |( bound, _) | bound. subst ( self . interner . tcx , & bound_vars) )
85
- . filter_map ( |bound| {
86
- LowerInto :: <
87
- Option < chalk_solve:: rust_ir:: QuantifiedInlineBound < RustInterner < ' tcx > > > ,
88
- > :: lower_into ( bound, & self . interner )
89
- } )
90
- . collect ( ) ;
91
+ let bounds = self . bounds_for ( def_id, bound_vars) ;
91
92
92
93
Arc :: new ( chalk_solve:: rust_ir:: AssociatedTyDatum {
93
94
trait_id : chalk_ir:: TraitId ( trait_def_id) ,
@@ -453,17 +454,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
453
454
let bound_vars = bound_vars_for_item ( self . interner . tcx , opaque_ty_id. 0 ) ;
454
455
let binders = binders_for ( & self . interner , bound_vars) ;
455
456
let where_clauses = self . where_clauses_for ( opaque_ty_id. 0 , bound_vars) ;
456
-
457
- let bounds: Vec < _ > = self
458
- . interner
459
- . tcx
460
- . explicit_item_bounds ( opaque_ty_id. 0 )
461
- . iter ( )
462
- . map ( |( bound, _) | bound. subst ( self . interner . tcx , & bound_vars) )
463
- . filter_map ( |bound| {
464
- LowerInto :: < Option < chalk_ir:: QuantifiedWhereClause < RustInterner < ' tcx > > > > :: lower_into ( bound, & self . interner )
465
- } )
466
- . collect ( ) ;
457
+ let bounds = self . bounds_for ( opaque_ty_id. 0 , bound_vars) ;
467
458
468
459
let value = chalk_solve:: rust_ir:: OpaqueTyDatumBound {
469
460
bounds : chalk_ir:: Binders :: new ( binders. clone ( ) , bounds) ,
0 commit comments