Skip to content

Commit 252c8d7

Browse files
committed
rewrite borrowck_fn to only use the body-id
1 parent 5c391d7 commit 252c8d7

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

src/librustc_borrowck/borrowck/fragments.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use rustc::middle::mem_categorization as mc;
2727
use std::mem;
2828
use std::rc::Rc;
2929
use syntax::ast;
30-
use syntax_pos::{Span, DUMMY_SP};
30+
use syntax_pos::DUMMY_SP;
3131

3232
#[derive(PartialEq, Eq, PartialOrd, Ord)]
3333
enum Fragment {
@@ -200,14 +200,15 @@ impl FragmentSets {
200200

201201
pub fn instrument_move_fragments<'a, 'tcx>(this: &MoveData<'tcx>,
202202
tcx: TyCtxt<'a, 'tcx, 'tcx>,
203-
sp: Span,
204203
id: ast::NodeId) {
205204
let span_err = tcx.hir.attrs(id).iter()
206205
.any(|a| a.check_name("rustc_move_fragments"));
207206
let print = tcx.sess.opts.debugging_opts.print_move_fragments;
208207

209208
if !span_err && !print { return; }
210209

210+
let sp = tcx.hir.span(id);
211+
211212
let instrument_all_paths = |kind, vec_rc: &Vec<MovePathIndex>| {
212213
for (i, mpi) in vec_rc.iter().enumerate() {
213214
let lp = || this.path_loan_path(*mpi);

src/librustc_borrowck/borrowck/mod.rs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,13 @@ impl<'a, 'tcx> Visitor<'tcx> for BorrowckCtxt<'a, 'tcx> {
7070
match fk {
7171
FnKind::ItemFn(..) |
7272
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);
7475
}
7576

7677
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);
7880
}
7981
}
8082
}
@@ -154,24 +156,20 @@ pub struct AnalysisData<'a, 'tcx: 'a> {
154156
pub move_data: move_data::FlowedMoveData<'a, 'tcx>,
155157
}
156158

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);
165161

166162
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);
168166
let tables = this.tcx.item_tables(owner_def_id);
169167
this.tables = Some(tables);
170168

171169
let body = this.tcx.hir.body(body_id);
172170

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);
175173
}
176174

177175
let cfg = cfg::CFG::new(this.tcx, &body.value);
@@ -182,17 +180,14 @@ fn borrowck_fn<'a, 'tcx>(this: &mut BorrowckCtxt<'a, 'tcx>,
182180

183181
move_data::fragments::instrument_move_fragments(&flowed_moves.move_data,
184182
this.tcx,
185-
sp,
186-
id);
183+
owner_id);
187184
move_data::fragments::build_unfragmented_map(this,
188185
&flowed_moves.move_data,
189-
id);
186+
owner_id);
190187

191188
check_loans::check_loans(this, &loan_dfcx, &flowed_moves, &all_loans[..], body);
192189

193190
this.tables = None;
194-
195-
intravisit::walk_fn(this, fk, decl, body_id, sp, id);
196191
}
197192

198193
fn build_borrowck_dataflow_data<'a, 'tcx>(this: &mut BorrowckCtxt<'a, 'tcx>,

0 commit comments

Comments
 (0)