@@ -3,7 +3,7 @@ use crate::errors;
3
3
/// Ideally, this code would be in libtest but for efficiency and error messages it lives here.
4
4
use crate :: util:: { check_builtin_macro_attribute, warn_on_duplicate_attribute} ;
5
5
use rustc_ast:: ptr:: P ;
6
- use rustc_ast:: { self as ast, attr} ;
6
+ use rustc_ast:: { self as ast, attr, GenericParamKind } ;
7
7
use rustc_ast_pretty:: pprust;
8
8
use rustc_errors:: Applicability ;
9
9
use rustc_expand:: base:: * ;
@@ -550,24 +550,21 @@ fn has_test_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool {
550
550
return false ;
551
551
}
552
552
553
- match ( has_output, has_should_panic_attr) {
554
- ( true , true ) => {
555
- sd. span_err ( i. span , "functions using `#[should_panic]` must return `()`" ) ;
556
- false
557
- }
558
- ( true , false ) => {
559
- if !generics. params . is_empty ( ) {
560
- sd. span_err (
561
- i. span ,
562
- "functions used as tests must have signature fn() -> ()" ,
563
- ) ;
564
- false
565
- } else {
566
- true
567
- }
568
- }
569
- ( false , _) => true ,
553
+ if has_should_panic_attr && has_output {
554
+ sd. span_err ( i. span , "functions using `#[should_panic]` must return `()`" ) ;
555
+ return false ;
570
556
}
557
+
558
+ if generics. params . iter ( ) . any ( |param| !matches ! ( param. kind, GenericParamKind :: Lifetime ) )
559
+ {
560
+ sd. span_err (
561
+ i. span ,
562
+ "functions used as tests can not have any non-lifetime generic parameters" ,
563
+ ) ;
564
+ return false ;
565
+ }
566
+
567
+ true
571
568
}
572
569
_ => {
573
570
// should be unreachable because `is_test_fn_item` should catch all non-fn items
0 commit comments