Skip to content

Commit 49f1de7

Browse files
committed
---
yaml --- r: 42441 b: refs/heads/try c: bd6536f h: refs/heads/master i: 42439: 7eacc93 v: v3
1 parent 4b9573d commit 49f1de7

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 19dfec2aaf746535de1521f68421f9980dbf25de
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
5-
refs/heads/try: a4eb76abd0b43c3e0d38cebd2c227a06e3b6edc4
5+
refs/heads/try: bd6536f8687b1b4fb166594ed5cf79db0ec1436d
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278

branches/try/src/librustc/front/test.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,24 +86,20 @@ fn strip_test_functions(crate: @ast::crate) -> @ast::crate {
8686

8787
fn fold_mod(cx: test_ctxt, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod {
8888

89-
// Remove any defined main function from the AST so it doesn't clash with
89+
// Remove any #[main] from the AST so it doesn't clash with
9090
// the one we're going to add. Only if compiling an executable.
9191

92-
fn nomain(cx: test_ctxt, item: @ast::item) -> Option<@ast::item> {
93-
match item.node {
94-
ast::item_fn(*) => {
95-
if attrs_contains_name(item.attrs, ~"main")
96-
&& !cx.sess.building_library {
97-
option::None
98-
} else { option::Some(item) }
99-
}
100-
_ => option::Some(item)
101-
}
92+
fn nomain(cx: test_ctxt, item: @ast::item) -> @ast::item {
93+
if !cx.sess.building_library {
94+
@ast::item{attrs: item.attrs.filtered(|attr| {
95+
attr::get_attr_name(*attr) != ~"main"
96+
}),.. copy *item}
97+
} else { item }
10298
}
10399

104100
let mod_nomain =
105101
{view_items: /*bad*/copy m.view_items,
106-
items: vec::filter_map(m.items, |i| nomain(cx, *i))};
102+
items: vec::map(m.items, |i| nomain(cx, *i))};
107103
return fold::noop_fold_mod(mod_nomain, fld);
108104
}
109105

0 commit comments

Comments
 (0)