@@ -70,11 +70,13 @@ impl<'a, 'tcx> Visitor<'tcx> for BorrowckCtxt<'a, 'tcx> {
70
70
match fk {
71
71
FnKind :: ItemFn ( ..) |
72
72
FnKind :: Method ( ..) => {
73
- borrowck_fn ( self , fk, fd, b, s, id, fk. attrs ( ) )
73
+ borrowck_fn ( self , b) ;
74
+ intravisit:: walk_fn ( self , fk, fd, b, s, id) ;
74
75
}
75
76
76
77
FnKind :: Closure ( ..) => {
77
- borrowck_fn ( self , fk, fd, b, s, id, fk. attrs ( ) ) ;
78
+ borrowck_fn ( self , b) ;
79
+ intravisit:: walk_fn ( self , fk, fd, b, s, id) ;
78
80
}
79
81
}
80
82
}
@@ -154,24 +156,20 @@ pub struct AnalysisData<'a, 'tcx: 'a> {
154
156
pub move_data : move_data:: FlowedMoveData < ' a , ' tcx > ,
155
157
}
156
158
157
- fn borrowck_fn < ' a , ' tcx > ( this : & mut BorrowckCtxt < ' a , ' tcx > ,
158
- fk : FnKind < ' tcx > ,
159
- decl : & ' tcx hir:: FnDecl ,
160
- body_id : hir:: BodyId ,
161
- sp : Span ,
162
- id : ast:: NodeId ,
163
- attributes : & [ ast:: Attribute ] ) {
164
- debug ! ( "borrowck_fn(id={})" , id) ;
159
+ fn borrowck_fn < ' a , ' tcx > ( this : & mut BorrowckCtxt < ' a , ' tcx > , body_id : hir:: BodyId ) {
160
+ debug ! ( "borrowck_fn(body_id={:?})" , body_id) ;
165
161
166
162
assert ! ( this. tables. is_none( ) ) ;
167
- let owner_def_id = this. tcx . hir . local_def_id ( this. tcx . hir . body_owner ( body_id) ) ;
163
+ let owner_id = this. tcx . hir . body_owner ( body_id) ;
164
+ let owner_def_id = this. tcx . hir . local_def_id ( owner_id) ;
165
+ let attributes = this. tcx . get_attrs ( owner_def_id) ;
168
166
let tables = this. tcx . item_tables ( owner_def_id) ;
169
167
this. tables = Some ( tables) ;
170
168
171
169
let body = this. tcx . hir . body ( body_id) ;
172
170
173
- if attributes . iter ( ) . any ( |item| item . check_name ( "rustc_mir_borrowck" ) ) {
174
- mir:: borrowck_mir ( this, id , attributes) ;
171
+ if this . tcx . has_attr ( owner_def_id , "rustc_mir_borrowck" ) {
172
+ mir:: borrowck_mir ( this, owner_id , & attributes) ;
175
173
}
176
174
177
175
let cfg = cfg:: CFG :: new ( this. tcx , & body. value ) ;
@@ -182,17 +180,14 @@ fn borrowck_fn<'a, 'tcx>(this: &mut BorrowckCtxt<'a, 'tcx>,
182
180
183
181
move_data:: fragments:: instrument_move_fragments ( & flowed_moves. move_data ,
184
182
this. tcx ,
185
- sp,
186
- id) ;
183
+ owner_id) ;
187
184
move_data:: fragments:: build_unfragmented_map ( this,
188
185
& flowed_moves. move_data ,
189
- id ) ;
186
+ owner_id ) ;
190
187
191
188
check_loans:: check_loans ( this, & loan_dfcx, & flowed_moves, & all_loans[ ..] , body) ;
192
189
193
190
this. tables = None ;
194
-
195
- intravisit:: walk_fn ( this, fk, decl, body_id, sp, id) ;
196
191
}
197
192
198
193
fn build_borrowck_dataflow_data < ' a , ' tcx > ( this : & mut BorrowckCtxt < ' a , ' tcx > ,
0 commit comments