@@ -102,7 +102,6 @@ use syntax::codemap::Span;
102
102
use syntax:: visit;
103
103
use syntax:: visit:: Visitor ;
104
104
105
- use self :: RepeatingScope :: Repeating ;
106
105
use self :: SubjectNode :: Subject ;
107
106
108
107
// a variation on try that just returns unit
@@ -114,7 +113,7 @@ macro_rules! ignore_err {
114
113
// PUBLIC ENTRY POINTS
115
114
116
115
pub fn regionck_expr ( fcx : & FnCtxt , e : & ast:: Expr ) {
117
- let mut rcx = Rcx :: new ( fcx, Repeating ( e. id ) , Subject ( e. id ) ) ;
116
+ let mut rcx = Rcx :: new ( fcx, RepeatingScope ( e. id ) , e . id , Subject ( e. id ) ) ;
118
117
if fcx. err_count_since_creation ( ) == 0 {
119
118
// regionck assumes typeck succeeded
120
119
rcx. visit_expr ( e) ;
@@ -124,16 +123,17 @@ pub fn regionck_expr(fcx: &FnCtxt, e: &ast::Expr) {
124
123
}
125
124
126
125
pub fn regionck_item ( fcx : & FnCtxt , item : & ast:: Item ) {
127
- let mut rcx = Rcx :: new ( fcx, Repeating ( item. id ) , Subject ( item. id ) ) ;
126
+ let mut rcx = Rcx :: new ( fcx, RepeatingScope ( item. id ) , item . id , Subject ( item. id ) ) ;
128
127
rcx. visit_region_obligations ( item. id ) ;
129
128
rcx. resolve_regions_and_report_errors ( ) ;
130
129
}
131
130
132
131
pub fn regionck_fn ( fcx : & FnCtxt , id : ast:: NodeId , decl : & ast:: FnDecl , blk : & ast:: Block ) {
133
- let mut rcx = Rcx :: new ( fcx, Repeating ( blk. id ) , Subject ( id) ) ;
132
+ debug ! ( "regionck_fn(id={})" , id) ;
133
+ let mut rcx = Rcx :: new ( fcx, RepeatingScope ( blk. id ) , blk. id , Subject ( id) ) ;
134
134
if fcx. err_count_since_creation ( ) == 0 {
135
135
// regionck assumes typeck succeeded
136
- rcx. visit_fn_body ( id, decl, blk) ;
136
+ rcx. visit_fn_body ( id, decl, blk, blk . span ) ; // TODO suboptimal span
137
137
}
138
138
139
139
// Region checking a fn can introduce new trait obligations,
@@ -148,7 +148,7 @@ pub fn regionck_fn(fcx: &FnCtxt, id: ast::NodeId, decl: &ast::FnDecl, blk: &ast:
148
148
pub fn regionck_ensure_component_tys_wf < ' a , ' tcx > ( fcx : & FnCtxt < ' a , ' tcx > ,
149
149
span : Span ,
150
150
component_tys : & [ Ty < ' tcx > ] ) {
151
- let mut rcx = Rcx :: new ( fcx, Repeating ( 0 ) , SubjectNode :: None ) ;
151
+ let mut rcx = Rcx :: new ( fcx, RepeatingScope ( 0 ) , 0 , SubjectNode :: None ) ;
152
152
for & component_ty in component_tys {
153
153
// Check that each type outlives the empty region. Since the
154
154
// empty region is a subregion of all others, this can't fail
@@ -189,14 +189,14 @@ fn region_of_def(fcx: &FnCtxt, def: def::Def) -> ty::Region {
189
189
}
190
190
}
191
191
192
- pub enum RepeatingScope { Repeating ( ast:: NodeId ) }
192
+ struct RepeatingScope ( ast:: NodeId ) ;
193
193
pub enum SubjectNode { Subject ( ast:: NodeId ) , None }
194
194
195
195
impl < ' a , ' tcx > Rcx < ' a , ' tcx > {
196
196
pub fn new ( fcx : & ' a FnCtxt < ' a , ' tcx > ,
197
197
initial_repeating_scope : RepeatingScope ,
198
198
subject : SubjectNode ) -> Rcx < ' a , ' tcx > {
199
- let Repeating ( initial_repeating_scope) = initial_repeating_scope;
199
+ let RepeatingScope ( initial_repeating_scope) = initial_repeating_scope;
200
200
Rcx { fcx : fcx,
201
201
repeating_scope : initial_repeating_scope,
202
202
subject : subject,
@@ -208,10 +208,8 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> {
208
208
self . fcx . ccx . tcx
209
209
}
210
210
211
- pub fn set_repeating_scope ( & mut self , scope : ast:: NodeId ) -> ast:: NodeId {
212
- let old_scope = self . repeating_scope ;
213
- self . repeating_scope = scope;
214
- old_scope
211
+ fn set_repeating_scope ( & mut self , scope : ast:: NodeId ) -> ast:: NodeId {
212
+ mem:: replace ( & mut self . repeating_scope , scope)
215
213
}
216
214
217
215
/// Try to resolve the type for the given node, returning t_err if an error results. Note that
0 commit comments