Fix #7740: gather_loans should not recur into the items of the block.
gather_loans does not need to recurse into any items declared in the current block. Rather than special-case `fk_item_fn` and `fk_method`, just make the GatherLoanVisitor's visit_item method a no-op. This indirectly implies that the example of #7740 is fixed: fn f() { static A: &'static char = &'A'; } Since we do not recurse into items, we no longer encounter `&'A'`.
This commit is contained in:
parent
45c3ca72bc
commit
41e7924670
1 changed files with 6 additions and 3 deletions
|
@ -95,6 +95,11 @@ impl visit::Visitor<@mut GatherLoanCtxt> for GatherLoanVisitor {
|
|||
fn visit_local(&mut self, l:@Local, e:@mut GatherLoanCtxt) {
|
||||
gather_loans_in_local(self, l, e);
|
||||
}
|
||||
|
||||
// #7740: Do not visit items here, not even fn items nor methods
|
||||
// of impl items; the outer loop in borrowck/mod will visit them
|
||||
// for us in turn. Thus override visit_item's walk with a no-op.
|
||||
fn visit_item(&mut self, _:@ast::item, _:@mut GatherLoanCtxt) { }
|
||||
}
|
||||
|
||||
pub fn gather_loans(bccx: @BorrowckCtxt,
|
||||
|
@ -135,10 +140,8 @@ fn gather_loans_in_fn(v: &mut GatherLoanVisitor,
|
|||
id: ast::NodeId,
|
||||
this: @mut GatherLoanCtxt) {
|
||||
match fk {
|
||||
// Do not visit items here, the outer loop in borrowck/mod
|
||||
// will visit them for us in turn.
|
||||
&visit::fk_item_fn(*) | &visit::fk_method(*) => {
|
||||
return;
|
||||
fail!("cannot occur, due to visit_item override");
|
||||
}
|
||||
|
||||
// Visit closures as part of the containing item.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue