Skip to content

Commit fe38ed6

Browse files
committed
---
yaml --- r: 13166 b: refs/heads/master c: af22871 h: refs/heads/master v: v3
1 parent 4a5efe3 commit fe38ed6

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 84adcb9806044c118f987aca05e627682b956eac
2+
refs/heads/master: af228711e5f7a3aa5db5cdcefcc5a8f7a91ff675
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rustc/middle/lint.rs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ fn time(do_it: bool, what: str, thunk: fn()) {
210210
end - start, what));
211211
}
212212

213-
fn check_item(cx: ctxt, i: @ast::item) {
213+
fn check_item(i: @ast::item, &&cx: ctxt, v: visit::vt<ctxt>) {
214214
cx.with_warn_attrs(i.attrs) {|cx|
215215
for cx.curr.each {|lint, level|
216216
alt int_to_lint(lint as int) {
@@ -221,11 +221,20 @@ fn check_item(cx: ctxt, i: @ast::item) {
221221
old_vecs { check_item_old_vecs(cx, level, i); }
222222
}
223223
}
224+
visit::visit_item(i, cx, v);
224225
}
225226
}
226227

228+
// Take a visitor, and modify it so that it will not proceed past subitems.
229+
// This is used to make the simple visitors used for the lint passes
230+
// not traverse into subitems, since that is handled by the outer
231+
// lint visitor.
232+
fn item_stopping_visitor<E>(v: visit::vt<E>) -> visit::vt<E> {
233+
visit::mk_vt(@{visit_item: {|_i, _e, _v| } with **v})
234+
}
235+
227236
fn check_item_while_true(cx: ctxt, level: level, it: @ast::item) {
228-
let visit = visit::mk_simple_visitor(@{
237+
let visit = item_stopping_visitor(visit::mk_simple_visitor(@{
229238
visit_expr: fn@(e: @ast::expr) {
230239
alt e.node {
231240
ast::expr_while(cond, _) {
@@ -242,7 +251,7 @@ fn check_item_while_true(cx: ctxt, level: level, it: @ast::item) {
242251
}
243252
}
244253
with *visit::default_simple_visitor()
245-
});
254+
}));
246255
visit::visit_item(it, (), visit);
247256
}
248257

@@ -295,7 +304,7 @@ fn check_item_ctypes(cx: ctxt, level: level, it: @ast::item) {
295304
}
296305

297306
fn check_item_path_statement(cx: ctxt, level: level, it: @ast::item) {
298-
let visit = visit::mk_simple_visitor(@{
307+
let visit = item_stopping_visitor(visit::mk_simple_visitor(@{
299308
visit_stmt: fn@(s: @ast::stmt) {
300309
alt s.node {
301310
ast::stmt_semi(@{id: _,
@@ -309,14 +318,14 @@ fn check_item_path_statement(cx: ctxt, level: level, it: @ast::item) {
309318
}
310319
}
311320
with *visit::default_simple_visitor()
312-
});
321+
}));
313322
visit::visit_item(it, (), visit);
314323
}
315324

316325
fn check_item_old_vecs(cx: ctxt, level: level, it: @ast::item) {
317326
let uses_vstore = int_hash();
318327

319-
let visit = visit::mk_simple_visitor(@{
328+
let visit = item_stopping_visitor(visit::mk_simple_visitor(@{
320329

321330
visit_expr:fn@(e: @ast::expr) {
322331
alt e.node {
@@ -353,7 +362,7 @@ fn check_item_old_vecs(cx: ctxt, level: level, it: @ast::item) {
353362
}
354363

355364
with *visit::default_simple_visitor()
356-
});
365+
}));
357366
visit::visit_item(it, (), visit);
358367
}
359368

@@ -379,11 +388,11 @@ fn check_crate(tcx: ty::ctxt, crate: @ast::crate,
379388

380389
time(time_pass, "lint checking") {||
381390
cx.with_warn_attrs(crate.node.attrs) {|cx|
382-
let visit = visit::mk_simple_visitor(@{
383-
visit_item: fn@(i: @ast::item) { check_item(cx, i); }
384-
with *visit::default_simple_visitor()
391+
let visit = visit::mk_vt(@{
392+
visit_item: check_item
393+
with *visit::default_visitor()
385394
});
386-
visit::visit_crate(*crate, (), visit);
395+
visit::visit_crate(*crate, cx, visit);
387396
}
388397
}
389398

0 commit comments

Comments
 (0)