@@ -24,7 +24,7 @@ pub(super) fn relate_types<'tcx>(
24
24
b : Ty < ' tcx > ,
25
25
locations : Locations ,
26
26
category : ConstraintCategory ,
27
- borrowck_context : Option < & mut BorrowCheckContext < ' _ , ' tcx > > ,
27
+ borrowck_context : & mut BorrowCheckContext < ' _ , ' tcx > ,
28
28
) -> Fallible < ( ) > {
29
29
debug ! ( "relate_types(a={:?}, v={:?}, b={:?}, locations={:?})" , a, v, b, locations) ;
30
30
TypeRelating :: new (
@@ -38,7 +38,7 @@ pub(super) fn relate_types<'tcx>(
38
38
39
39
struct NllTypeRelatingDelegate < ' me , ' bccx , ' tcx > {
40
40
infcx : & ' me InferCtxt < ' me , ' tcx > ,
41
- borrowck_context : Option < & ' me mut BorrowCheckContext < ' bccx , ' tcx > > ,
41
+ borrowck_context : & ' me mut BorrowCheckContext < ' bccx , ' tcx > ,
42
42
43
43
param_env : ty:: ParamEnv < ' tcx > ,
44
44
@@ -52,7 +52,7 @@ struct NllTypeRelatingDelegate<'me, 'bccx, 'tcx> {
52
52
impl NllTypeRelatingDelegate < ' me , ' bccx , ' tcx > {
53
53
fn new (
54
54
infcx : & ' me InferCtxt < ' me , ' tcx > ,
55
- borrowck_context : Option < & ' me mut BorrowCheckContext < ' bccx , ' tcx > > ,
55
+ borrowck_context : & ' me mut BorrowCheckContext < ' bccx , ' tcx > ,
56
56
param_env : ty:: ParamEnv < ' tcx > ,
57
57
locations : Locations ,
58
58
category : ConstraintCategory ,
@@ -71,20 +71,12 @@ impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> {
71
71
}
72
72
73
73
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)
80
76
}
81
77
82
78
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)
88
80
}
89
81
90
82
fn generalize_existential ( & mut self , universe : ty:: UniverseIndex ) -> ty:: Region < ' tcx > {
@@ -100,17 +92,15 @@ impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> {
100
92
sub : ty:: Region < ' tcx > ,
101
93
info : ty:: VarianceDiagInfo < ' tcx > ,
102
94
) {
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
+ } ) ;
114
104
}
115
105
116
106
// We don't have to worry about the equality of consts during borrow checking
0 commit comments