File tree Expand file tree Collapse file tree 2 files changed +70
-0
lines changed Expand file tree Collapse file tree 2 files changed +70
-0
lines changed Original file line number Diff line number Diff line change 1+ // compile-flags: --test
2+
3+ #[ test]
4+ fn foo ( ) -> Result < ( ) , ( ) > {
5+ Ok ( ( ) )
6+ }
7+
8+ #[ test]
9+ fn bar ( ) -> i32 { //~ ERROR the trait bound `i32: Termination` is not satisfied
10+ 0
11+ }
12+
13+ #[ test]
14+ fn baz ( val : i32 ) { } //~ ERROR functions used as tests can not have any arguments
15+
16+ #[ test]
17+ fn lifetime_generic < ' a > ( ) -> Result < ( ) , & ' a str > {
18+ Err ( "coerce me to any lifetime" )
19+ }
20+
21+ #[ test]
22+ fn type_generic < T > ( ) { } //~ ERROR functions used as tests can not have any non-lifetime generic parameters
23+
24+ #[ test]
25+ fn const_generic < const N : usize > ( ) { } //~ ERROR functions used as tests can not have any non-lifetime generic parameters
26+
27+ // Regression test for <https://github.com/rust-lang/rust/issues/112360>. This used to ICE.
28+ fn nested ( ) {
29+ #[ test]
30+ fn foo ( arg : ( ) ) { } //~ ERROR functions used as tests can not have any arguments
31+ }
Original file line number Diff line number Diff line change 1+ error: functions used as tests can not have any arguments
2+ --> $DIR/test-function-signature.rs:14:1
3+ |
4+ LL | fn baz(val: i32) {}
5+ | ^^^^^^^^^^^^^^^^^^^
6+
7+ error: functions used as tests can not have any non-lifetime generic parameters
8+ --> $DIR/test-function-signature.rs:22:1
9+ |
10+ LL | fn type_generic<T>() {}
11+ | ^^^^^^^^^^^^^^^^^^^^^^^
12+
13+ error: functions used as tests can not have any non-lifetime generic parameters
14+ --> $DIR/test-function-signature.rs:25:1
15+ |
16+ LL | fn const_generic<const N: usize>() {}
17+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18+
19+ error: functions used as tests can not have any arguments
20+ --> $DIR/test-function-signature.rs:30:5
21+ |
22+ LL | fn foo(arg: ()) {}
23+ | ^^^^^^^^^^^^^^^^^^
24+
25+ error[E0277]: the trait bound `i32: Termination` is not satisfied
26+ --> $DIR/test-function-signature.rs:9:13
27+ |
28+ LL | #[test]
29+ | ------- in this procedural macro expansion
30+ LL | fn bar() -> i32 {
31+ | ^^^ the trait `Termination` is not implemented for `i32`
32+ |
33+ note: required by a bound in `assert_test_result`
34+ --> $SRC_DIR/test/src/lib.rs:LL:COL
35+ = note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
36+
37+ error: aborting due to 5 previous errors
38+
39+ For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments