@@ -24,7 +24,7 @@ pub(super) fn relate_types<'tcx>(
2424 b : Ty < ' tcx > ,
2525 locations : Locations ,
2626 category : ConstraintCategory ,
27- borrowck_context : Option < & mut BorrowCheckContext < ' _ , ' tcx > > ,
27+ borrowck_context : & mut BorrowCheckContext < ' _ , ' tcx > ,
2828) -> Fallible < ( ) > {
2929 debug ! ( "relate_types(a={:?}, v={:?}, b={:?}, locations={:?})" , a, v, b, locations) ;
3030 TypeRelating :: new (
@@ -38,7 +38,7 @@ pub(super) fn relate_types<'tcx>(
3838
3939struct NllTypeRelatingDelegate < ' me , ' bccx , ' tcx > {
4040 infcx : & ' me InferCtxt < ' me , ' tcx > ,
41- borrowck_context : Option < & ' me mut BorrowCheckContext < ' bccx , ' tcx > > ,
41+ borrowck_context : & ' me mut BorrowCheckContext < ' bccx , ' tcx > ,
4242
4343 param_env : ty:: ParamEnv < ' tcx > ,
4444
@@ -52,7 +52,7 @@ struct NllTypeRelatingDelegate<'me, 'bccx, 'tcx> {
5252impl NllTypeRelatingDelegate < ' me , ' bccx , ' tcx > {
5353 fn new (
5454 infcx : & ' me InferCtxt < ' me , ' tcx > ,
55- borrowck_context : Option < & ' me mut BorrowCheckContext < ' bccx , ' tcx > > ,
55+ borrowck_context : & ' me mut BorrowCheckContext < ' bccx , ' tcx > ,
5656 param_env : ty:: ParamEnv < ' tcx > ,
5757 locations : Locations ,
5858 category : ConstraintCategory ,
@@ -71,20 +71,12 @@ impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> {
7171 }
7272
7373 fn next_existential_region_var ( & mut self , from_forall : bool ) -> ty:: Region < ' tcx > {
74- if self . borrowck_context . is_some ( ) {
75- let origin = NllRegionVariableOrigin :: Existential { from_forall } ;
76- self . infcx . next_nll_region_var ( origin)
77- } else {
78- self . infcx . tcx . lifetimes . re_erased
79- }
74+ let origin = NllRegionVariableOrigin :: Existential { from_forall } ;
75+ self . infcx . next_nll_region_var ( origin)
8076 }
8177
8278 fn next_placeholder_region ( & mut self , placeholder : ty:: PlaceholderRegion ) -> ty:: Region < ' tcx > {
83- if let Some ( borrowck_context) = & mut self . borrowck_context {
84- borrowck_context. constraints . placeholder_region ( self . infcx , placeholder)
85- } else {
86- self . infcx . tcx . lifetimes . re_erased
87- }
79+ self . borrowck_context . constraints . placeholder_region ( self . infcx , placeholder)
8880 }
8981
9082 fn generalize_existential ( & mut self , universe : ty:: UniverseIndex ) -> ty:: Region < ' tcx > {
@@ -100,17 +92,15 @@ impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> {
10092 sub : ty:: Region < ' tcx > ,
10193 info : ty:: VarianceDiagInfo < ' tcx > ,
10294 ) {
103- if let Some ( borrowck_context) = & mut self . borrowck_context {
104- let sub = borrowck_context. universal_regions . to_region_vid ( sub) ;
105- let sup = borrowck_context. universal_regions . to_region_vid ( sup) ;
106- borrowck_context. constraints . outlives_constraints . push ( OutlivesConstraint {
107- sup,
108- sub,
109- locations : self . locations ,
110- category : self . category ,
111- variance_info : info,
112- } ) ;
113- }
95+ let sub = self . borrowck_context . universal_regions . to_region_vid ( sub) ;
96+ let sup = self . borrowck_context . universal_regions . to_region_vid ( sup) ;
97+ self . borrowck_context . constraints . outlives_constraints . push ( OutlivesConstraint {
98+ sup,
99+ sub,
100+ locations : self . locations ,
101+ category : self . category ,
102+ variance_info : info,
103+ } ) ;
114104 }
115105
116106 // We don't have to worry about the equality of consts during borrow checking
0 commit comments