Skip to content

Commit 2d7eb4d

Browse files
committed
---
yaml --- r: 81105 b: refs/heads/snap-stage3 c: 3748164 h: refs/heads/master i: 81103: d38f981 v: v3
1 parent 7371627 commit 2d7eb4d

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 4c6bf4872012c010f84dc7fa2cdfe87522533f89
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 1ce1aae28273ded3be991d1f29339ce08a5fc220
4+
refs/heads/snap-stage3: 37481641b1101108eb394789dd2adf9e095e39d9
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/librustc/middle/check_const.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,9 @@ struct env {
226226
idstack: @mut ~[NodeId]
227227
}
228228

229-
struct CheckItemRecursionVisitor;
229+
struct CheckItemRecursionVisitor {
230+
env: env,
231+
}
230232

231233
// Make sure a const item doesn't recursively refer to itself
232234
// FIXME: Should use the dependency graph when it's available (#1356)
@@ -242,34 +244,34 @@ pub fn check_item_recursion(sess: Session,
242244
idstack: @mut ~[]
243245
};
244246

245-
let mut visitor = CheckItemRecursionVisitor;
246-
visitor.visit_item(it, env);
247+
let mut visitor = CheckItemRecursionVisitor { env: env };
248+
visitor.visit_item(it, ());
247249
}
248250

249-
impl Visitor<env> for CheckItemRecursionVisitor {
250-
fn visit_item(&mut self, it: @item, env: env) {
251-
if env.idstack.iter().any(|x| x == &(it.id)) {
252-
env.sess.span_fatal(env.root_it.span, "recursive constant");
251+
impl Visitor<()> for CheckItemRecursionVisitor {
252+
fn visit_item(&mut self, it: @item, _: ()) {
253+
if self.env.idstack.iter().any(|x| x == &(it.id)) {
254+
self.env.sess.span_fatal(self.env.root_it.span, "recursive constant");
253255
}
254-
env.idstack.push(it.id);
255-
visit::walk_item(self, it, env);
256-
env.idstack.pop();
256+
self.env.idstack.push(it.id);
257+
visit::walk_item(self, it, ());
258+
self.env.idstack.pop();
257259
}
258260

259-
fn visit_expr(&mut self, e: @Expr, env: env) {
261+
fn visit_expr(&mut self, e: @Expr, _: ()) {
260262
match e.node {
261-
ExprPath(*) => match env.def_map.find(&e.id) {
263+
ExprPath(*) => match self.env.def_map.find(&e.id) {
262264
Some(&DefStatic(def_id, _)) if ast_util::is_local(def_id) =>
263-
match env.ast_map.get_copy(&def_id.node) {
265+
match self.env.ast_map.get_copy(&def_id.node) {
264266
ast_map::node_item(it, _) => {
265-
self.visit_item(it, env);
267+
self.visit_item(it, ());
266268
}
267269
_ => fail!("const not bound to an item")
268270
},
269271
_ => ()
270272
},
271273
_ => ()
272274
}
273-
visit::walk_expr(self, e, env);
275+
visit::walk_expr(self, e, ());
274276
}
275277
}

0 commit comments

Comments
 (0)