File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
rustc_infer/src/infer/outlives
rustc_trait_selection/src/traits/query/type_op Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -170,6 +170,10 @@ impl<'tcx> InferCtxt<'tcx> {
170
170
std:: mem:: take ( & mut self . inner . borrow_mut ( ) . region_obligations )
171
171
}
172
172
173
+ pub fn clone_registered_region_obligations ( & self ) -> Vec < TypeOutlivesConstraint < ' tcx > > {
174
+ self . inner . borrow ( ) . region_obligations . clone ( )
175
+ }
176
+
173
177
pub fn register_region_assumption ( & self , assumption : ty:: ArgOutlivesPredicate < ' tcx > ) {
174
178
let mut inner = self . inner . borrow_mut ( ) ;
175
179
inner. undo_log . push ( UndoLog :: PushRegionAssumption ) ;
Original file line number Diff line number Diff line change @@ -55,6 +55,12 @@ pub fn compute_implied_outlives_bounds_inner<'tcx>(
55
55
span : Span ,
56
56
disable_implied_bounds_hack : bool ,
57
57
) -> Result < Vec < OutlivesBound < ' tcx > > , NoSolution > {
58
+ // Inside mir borrowck, each computation starts with an empty list.
59
+ assert ! (
60
+ ocx. infcx. inner. borrow( ) . region_obligations( ) . is_empty( ) ,
61
+ "compute_implied_outlives_bounds assumes region obligations are empty before starting"
62
+ ) ;
63
+
58
64
let normalize_ty = |ty| -> Result < _ , NoSolution > {
59
65
// We must normalize the type so we can compute the right outlives components.
60
66
// for example, if we have some constrained param type like `T: Trait<Out = U>`,
@@ -143,7 +149,7 @@ pub fn compute_implied_outlives_bounds_inner<'tcx>(
143
149
&& ty. visit_with ( & mut ContainsBevyParamSet { tcx : ocx. infcx . tcx } ) . is_break ( )
144
150
{
145
151
for TypeOutlivesConstraint { sup_type, sub_region, .. } in
146
- ocx. infcx . take_registered_region_obligations ( )
152
+ ocx. infcx . clone_registered_region_obligations ( )
147
153
{
148
154
let mut components = smallvec ! [ ] ;
149
155
push_outlives_components ( ocx. infcx . tcx , sup_type, & mut components) ;
You can’t perform that action at this time.
0 commit comments