@@ -274,30 +274,43 @@ fn strip_test_functions(krate: ast::Crate) -> ast::Crate {
274274fn is_test_fn ( cx : & TestCtxt , i : & ast:: Item ) -> bool {
275275 let has_test_attr = attr:: contains_name ( i. attrs . as_slice ( ) , "test" ) ;
276276
277- fn has_test_signature ( i : & ast:: Item ) -> bool {
277+ #[ deriving( PartialEq ) ]
278+ enum HasTestSignature {
279+ Yes ,
280+ No ,
281+ NotEvenAFunction ,
282+ }
283+
284+ fn has_test_signature ( i : & ast:: Item ) -> HasTestSignature {
278285 match & i. node {
279286 & ast:: ItemFn ( ref decl, _, _, ref generics, _) => {
280287 let no_output = match decl. output . node {
281288 ast:: TyNil => true ,
282- _ => false
289+ _ => false ,
283290 } ;
284- decl. inputs . is_empty ( )
285- && no_output
286- && !generics. is_parameterized ( )
291+ if decl. inputs . is_empty ( )
292+ && no_output
293+ && !generics. is_parameterized ( ) {
294+ Yes
295+ } else {
296+ No
297+ }
287298 }
288- _ => false
299+ _ => NotEvenAFunction ,
289300 }
290301 }
291302
292- if has_test_attr && ! has_test_signature ( i ) {
303+ if has_test_attr {
293304 let diag = cx. span_diagnostic ;
294- diag. span_err (
295- i. span ,
296- "functions used as tests must have signature fn() -> ()."
297- ) ;
305+ match has_test_signature ( i) {
306+ Yes => { } ,
307+ No => diag. span_err ( i. span , "functions used as tests must have signature fn() -> ()" ) ,
308+ NotEvenAFunction => diag. span_err ( i. span ,
309+ "only functions may be used as tests" ) ,
310+ }
298311 }
299312
300- return has_test_attr && has_test_signature ( i) ;
313+ return has_test_attr && has_test_signature ( i) == Yes ;
301314}
302315
303316fn is_bench_fn ( cx : & TestCtxt , i : & ast:: Item ) -> bool {
0 commit comments