@@ -20,31 +20,13 @@ pub fn renumber_mir<'tcx>(
20
20
) {
21
21
debug ! ( ?body. arg_count) ;
22
22
23
- let mut visitor = NllVisitor { infcx } ;
23
+ let mut renumberer = RegionRenumberer { infcx } ;
24
24
25
25
for body in promoted. iter_mut ( ) {
26
- visitor . visit_body ( body) ;
26
+ renumberer . visit_body ( body) ;
27
27
}
28
28
29
- visitor. visit_body ( body) ;
30
- }
31
-
32
- /// Replaces all regions appearing in `value` with fresh inference
33
- /// variables.
34
- #[ instrument( skip( infcx, get_ctxt_fn) , level = "debug" ) ]
35
- pub ( crate ) fn renumber_regions < ' tcx , T , F > (
36
- infcx : & BorrowckInferCtxt < ' _ , ' tcx > ,
37
- value : T ,
38
- get_ctxt_fn : F ,
39
- ) -> T
40
- where
41
- T : TypeFoldable < TyCtxt < ' tcx > > ,
42
- F : Fn ( ) -> RegionCtxt ,
43
- {
44
- infcx. tcx . fold_regions ( value, |_region, _depth| {
45
- let origin = NllRegionVariableOrigin :: Existential { from_forall : false } ;
46
- infcx. next_nll_region_var ( origin, || get_ctxt_fn ( ) )
47
- } )
29
+ renumberer. visit_body ( body) ;
48
30
}
49
31
50
32
#[ derive( Copy , Clone , Debug , Eq , PartialEq , Hash ) ]
@@ -82,21 +64,26 @@ impl RegionCtxt {
82
64
}
83
65
}
84
66
85
- struct NllVisitor < ' a , ' tcx > {
67
+ struct RegionRenumberer < ' a , ' tcx > {
86
68
infcx : & ' a BorrowckInferCtxt < ' a , ' tcx > ,
87
69
}
88
70
89
- impl < ' a , ' tcx > NllVisitor < ' a , ' tcx > {
71
+ impl < ' a , ' tcx > RegionRenumberer < ' a , ' tcx > {
72
+ /// Replaces all regions appearing in `value` with fresh inference
73
+ /// variables.
90
74
fn renumber_regions < T , F > ( & mut self , value : T , region_ctxt_fn : F ) -> T
91
75
where
92
76
T : TypeFoldable < TyCtxt < ' tcx > > ,
93
77
F : Fn ( ) -> RegionCtxt ,
94
78
{
95
- renumber_regions ( self . infcx , value, region_ctxt_fn)
79
+ let origin = NllRegionVariableOrigin :: Existential { from_forall : false } ;
80
+ self . infcx . tcx . fold_regions ( value, |_region, _depth| {
81
+ self . infcx . next_nll_region_var ( origin, || region_ctxt_fn ( ) )
82
+ } )
96
83
}
97
84
}
98
85
99
- impl < ' a , ' tcx > MutVisitor < ' tcx > for NllVisitor < ' a , ' tcx > {
86
+ impl < ' a , ' tcx > MutVisitor < ' tcx > for RegionRenumberer < ' a , ' tcx > {
100
87
fn tcx ( & self ) -> TyCtxt < ' tcx > {
101
88
self . infcx . tcx
102
89
}
@@ -124,9 +111,9 @@ impl<'a, 'tcx> MutVisitor<'tcx> for NllVisitor<'a, 'tcx> {
124
111
}
125
112
126
113
#[ instrument( skip( self ) , level = "debug" ) ]
127
- fn visit_constant ( & mut self , constant : & mut Constant < ' tcx > , _location : Location ) {
114
+ fn visit_constant ( & mut self , constant : & mut Constant < ' tcx > , location : Location ) {
128
115
let literal = constant. literal ;
129
- constant. literal = self . renumber_regions ( literal, || RegionCtxt :: Location ( _location ) ) ;
116
+ constant. literal = self . renumber_regions ( literal, || RegionCtxt :: Location ( location ) ) ;
130
117
debug ! ( "constant: {:#?}" , constant) ;
131
118
}
132
119
}
0 commit comments