Skip to content

Commit 510c4d8

Browse files
committed
auto merge of rust-lang#8993 : pnkfelix/rust/fsk-fix-7740-dont-recur-on-items-during-gather-loans-of-block, r=nikomatsakis
Fix rust-lang#7740 r? anyone, @nikomatsakis especially.
2 parents 6f176a1 + c7352e6 commit 510c4d8

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/librustc/middle/borrowck/gather_loans/mod.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ impl visit::Visitor<@mut GatherLoanCtxt> for GatherLoanVisitor {
9595
fn visit_local(&mut self, l:@Local, e:@mut GatherLoanCtxt) {
9696
gather_loans_in_local(self, l, e);
9797
}
98+
99+
// #7740: Do not visit items here, not even fn items nor methods
100+
// of impl items; the outer loop in borrowck/mod will visit them
101+
// for us in turn. Thus override visit_item's walk with a no-op.
102+
fn visit_item(&mut self, _:@ast::item, _:@mut GatherLoanCtxt) { }
98103
}
99104

100105
pub fn gather_loans(bccx: @BorrowckCtxt,
@@ -135,10 +140,8 @@ fn gather_loans_in_fn(v: &mut GatherLoanVisitor,
135140
id: ast::NodeId,
136141
this: @mut GatherLoanCtxt) {
137142
match fk {
138-
// Do not visit items here, the outer loop in borrowck/mod
139-
// will visit them for us in turn.
140143
&visit::fk_item_fn(*) | &visit::fk_method(*) => {
141-
return;
144+
fail!("cannot occur, due to visit_item override");
142145
}
143146

144147
// Visit closures as part of the containing item.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Regression test for issue #7740
12+
13+
fn main() {
14+
static A: &'static char = &'A';
15+
}

0 commit comments

Comments
 (0)