about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorFelix S. Klock II <pnkfelix@pnkfx.org>2013-04-29 16:25:40 +0200
committerFelix S. Klock II <pnkfelix@pnkfx.org>2013-05-02 08:55:08 +0200
commit5f1a90ebe7ea3d3102dbffcaabaf8803d650db80 (patch)
tree9c4d2d67ac77c301529ff78b4e154c9377cbe6fe /src
parentb42ea7f9ef06be9a623a8a007ae3aecbb7d961a3 (diff)
downloadrust-5f1a90ebe7ea3d3102dbffcaabaf8803d650db80.tar.gz
rust-5f1a90ebe7ea3d3102dbffcaabaf8803d650db80.zip
Issue 4391: rustc should not silently skip tests with erroneous signature.
Diffstat (limited to 'src')
-rw-r--r--src/librustc/front/test.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs
index 4506feece2b..94eade675e7 100644
--- a/src/librustc/front/test.rs
+++ b/src/librustc/front/test.rs
@@ -141,7 +141,7 @@ fn fold_item(cx: @mut TestCtxt, i: @ast::item, fld: @fold::ast_fold)
     debug!("current path: %s",
            ast_util::path_name_i(copy cx.path, cx.sess.parse_sess.interner));
 
-    if is_test_fn(i) || is_bench_fn(i) {
+    if is_test_fn(cx, i) || is_bench_fn(i) {
         match i.node {
           ast::item_fn(_, purity, _, _, _) if purity == ast::unsafe_fn => {
             let sess = cx.sess;
@@ -169,7 +169,7 @@ fn fold_item(cx: @mut TestCtxt, i: @ast::item, fld: @fold::ast_fold)
     return res;
 }
 
-fn is_test_fn(i: @ast::item) -> bool {
+fn is_test_fn(cx: @mut TestCtxt, i: @ast::item) -> bool {
     let has_test_attr = !attr::find_attrs_by_name(i.attrs,
                                                   ~"test").is_empty();
 
@@ -188,6 +188,13 @@ fn is_test_fn(i: @ast::item) -> bool {
         }
     }
 
+    if has_test_attr && !has_test_signature(i) {
+        let sess = cx.sess;
+        sess.span_fatal(
+            i.span,
+            ~"functions used as tests must have signature fn() -> ()."
+        );
+    }
     return has_test_attr && has_test_signature(i);
 }