@@ -68,8 +68,9 @@ use crate::infer::{
68
68
use crate :: traits:: { ObligationCause , ObligationCauseCode } ;
69
69
use rustc_data_structures:: undo_log:: UndoLogs ;
70
70
use rustc_middle:: mir:: ConstraintCategory ;
71
- use rustc_middle:: ty:: GenericArgKind ;
72
71
use rustc_middle:: ty:: { self , GenericArgsRef , Region , Ty , TyCtxt , TypeVisitableExt } ;
72
+ use rustc_middle:: ty:: { GenericArgKind , ToPredicate } ;
73
+ use rustc_span:: DUMMY_SP ;
73
74
use smallvec:: smallvec;
74
75
75
76
use super :: env:: OutlivesEnvironment ;
@@ -131,6 +132,25 @@ impl<'tcx> InferCtxt<'tcx> {
131
132
) -> Result < ( ) , ( E , SubregionOrigin < ' tcx > ) > {
132
133
assert ! ( !self . in_snapshot( ) , "cannot process registered region obligations in a snapshot" ) ;
133
134
135
+ let normalized_caller_bounds: Vec < _ > = outlives_env
136
+ . param_env
137
+ . caller_bounds ( )
138
+ . iter ( )
139
+ . filter_map ( |clause| {
140
+ let bound_clause = clause. kind ( ) ;
141
+ let ty:: ClauseKind :: TypeOutlives ( outlives) = bound_clause. skip_binder ( ) else {
142
+ return None ;
143
+ } ;
144
+ Some ( deeply_normalize_ty ( outlives. 0 ) . map ( |ty| {
145
+ bound_clause
146
+ . rebind ( ty:: ClauseKind :: TypeOutlives ( ty:: OutlivesPredicate ( ty, outlives. 1 ) ) )
147
+ . to_predicate ( self . tcx )
148
+ } ) )
149
+ } )
150
+ // FIXME: How do we accurately report an error here :(
151
+ . try_collect ( )
152
+ . map_err ( |e| ( e, SubregionOrigin :: AscribeUserTypeProvePredicate ( DUMMY_SP ) ) ) ?;
153
+
134
154
let my_region_obligations = self . take_registered_region_obligations ( ) ;
135
155
136
156
for RegionObligation { sup_type, sub_region, origin } in my_region_obligations {
@@ -142,7 +162,7 @@ impl<'tcx> InferCtxt<'tcx> {
142
162
self . tcx ,
143
163
outlives_env. region_bound_pairs ( ) ,
144
164
None ,
145
- outlives_env . param_env ,
165
+ & normalized_caller_bounds ,
146
166
) ;
147
167
let category = origin. to_constraint_category ( ) ;
148
168
outlives. type_must_outlive ( origin, sup_type, sub_region, category) ;
@@ -196,7 +216,7 @@ where
196
216
tcx : TyCtxt < ' tcx > ,
197
217
region_bound_pairs : & ' cx RegionBoundPairs < ' tcx > ,
198
218
implicit_region_bound : Option < ty:: Region < ' tcx > > ,
199
- param_env : ty:: ParamEnv < ' tcx > ,
219
+ caller_bounds : & ' cx [ ty:: Clause < ' tcx > ] ,
200
220
) -> Self {
201
221
Self {
202
222
delegate,
@@ -205,7 +225,7 @@ where
205
225
tcx,
206
226
region_bound_pairs,
207
227
implicit_region_bound,
208
- param_env ,
228
+ caller_bounds ,
209
229
) ,
210
230
}
211
231
}
0 commit comments