Skip to content

Commit 5f1a90e

Browse files
committed
Issue 4391: rustc should not silently skip tests with erroneous signature.
1 parent b42ea7f commit 5f1a90e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/librustc/front/test.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ fn fold_item(cx: @mut TestCtxt, i: @ast::item, fld: @fold::ast_fold)
141141
debug!("current path: %s",
142142
ast_util::path_name_i(copy cx.path, cx.sess.parse_sess.interner));
143143

144-
if is_test_fn(i) || is_bench_fn(i) {
144+
if is_test_fn(cx, i) || is_bench_fn(i) {
145145
match i.node {
146146
ast::item_fn(_, purity, _, _, _) if purity == ast::unsafe_fn => {
147147
let sess = cx.sess;
@@ -169,7 +169,7 @@ fn fold_item(cx: @mut TestCtxt, i: @ast::item, fld: @fold::ast_fold)
169169
return res;
170170
}
171171

172-
fn is_test_fn(i: @ast::item) -> bool {
172+
fn is_test_fn(cx: @mut TestCtxt, i: @ast::item) -> bool {
173173
let has_test_attr = !attr::find_attrs_by_name(i.attrs,
174174
~"test").is_empty();
175175

@@ -188,6 +188,13 @@ fn is_test_fn(i: @ast::item) -> bool {
188188
}
189189
}
190190

191+
if has_test_attr && !has_test_signature(i) {
192+
let sess = cx.sess;
193+
sess.span_fatal(
194+
i.span,
195+
~"functions used as tests must have signature fn() -> ()."
196+
);
197+
}
191198
return has_test_attr && has_test_signature(i);
192199
}
193200

0 commit comments

Comments
 (0)