Skip to content

Commit b8d0edc

Browse files
committed
---
yaml --- r: 143975 b: refs/heads/try2 c: ef854c9 h: refs/heads/master i: 143973: ab08c2d 143971: 053ae7f 143967: d397c84 v: v3
1 parent 9a2cd5e commit b8d0edc

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 0d85928e37dec4795cf288e9f0bbe23d7a100b7a
8+
refs/heads/try2: ef854c9b04cf916241587ea1764b86027e380e8f
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/borrowck/mod.rs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ use std::ops::{BitOr, BitAnd};
2626
use std::result::{Result};
2727
use syntax::ast;
2828
use syntax::ast_map;
29-
use syntax::oldvisit;
3029
use syntax::codemap::span;
3130
use syntax::parse::token;
31+
use syntax::visit;
32+
use syntax::visit::{Visitor,fn_kind};
33+
use syntax::ast::{fn_decl,Block,NodeId};
3234

3335
macro_rules! if_ok(
3436
($inp: expr) => (
@@ -59,6 +61,15 @@ impl Clone for LoanDataFlowOperator {
5961

6062
pub type LoanDataFlow = DataFlowContext<LoanDataFlowOperator>;
6163

64+
struct BorrowckVisitor;
65+
66+
impl Visitor<@BorrowckCtxt> for BorrowckVisitor {
67+
fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl,
68+
b:&Block, s:span, n:NodeId, e:@BorrowckCtxt) {
69+
borrowck_fn(self, fk, fd, b, s, n, e);
70+
}
71+
}
72+
6273
pub fn check_crate(
6374
tcx: ty::ctxt,
6475
method_map: typeck::method_map,
@@ -86,9 +97,8 @@ pub fn check_crate(
8697
}
8798
};
8899

89-
let v = oldvisit::mk_vt(@oldvisit::Visitor {visit_fn: borrowck_fn,
90-
..*oldvisit::default_visitor()});
91-
oldvisit::visit_crate(crate, (bccx, v));
100+
let mut v = BorrowckVisitor;
101+
visit::walk_crate(&mut v, crate, bccx);
92102

93103
if tcx.sess.borrowck_stats() {
94104
io::println("--- borrowck stats ---");
@@ -113,21 +123,21 @@ pub fn check_crate(
113123
}
114124
}
115125

116-
fn borrowck_fn(fk: &oldvisit::fn_kind,
126+
fn borrowck_fn(v: &mut BorrowckVisitor,
127+
fk: &visit::fn_kind,
117128
decl: &ast::fn_decl,
118129
body: &ast::Block,
119130
sp: span,
120131
id: ast::NodeId,
121-
(this, v): (@BorrowckCtxt,
122-
oldvisit::vt<@BorrowckCtxt>)) {
132+
this: @BorrowckCtxt) {
123133
match fk {
124-
&oldvisit::fk_anon(*) |
125-
&oldvisit::fk_fn_block(*) => {
134+
&visit::fk_anon(*) |
135+
&visit::fk_fn_block(*) => {
126136
// Closures are checked as part of their containing fn item.
127137
}
128138

129-
&oldvisit::fk_item_fn(*) |
130-
&oldvisit::fk_method(*) => {
139+
&visit::fk_item_fn(*) |
140+
&visit::fk_method(*) => {
131141
debug!("borrowck_fn(id=%?)", id);
132142

133143
// Check the body of fn items.
@@ -156,7 +166,7 @@ fn borrowck_fn(fk: &oldvisit::fn_kind,
156166
}
157167
}
158168

159-
oldvisit::visit_fn(fk, decl, body, sp, id, (this, v));
169+
visit::walk_fn(v, fk, decl, body, sp, id, this);
160170
}
161171

162172
// ----------------------------------------------------------------------

0 commit comments

Comments
 (0)