summaryrefslogtreecommitdiffstats
path: root/tests/ui/test-attrs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/test-attrs')
-rw-r--r--tests/ui/test-attrs/test-fn-signature-verification-for-explicit-return-type.rs2
-rw-r--r--tests/ui/test-attrs/test-function-signature.rs31
-rw-r--r--tests/ui/test-attrs/test-function-signature.stderr39
-rw-r--r--tests/ui/test-attrs/test-panic-abort-disabled.rs1
-rw-r--r--tests/ui/test-attrs/test-panic-abort.rs9
-rw-r--r--tests/ui/test-attrs/test-panic-abort.run.stdout7
-rw-r--r--tests/ui/test-attrs/test-type.rs3
7 files changed, 86 insertions, 6 deletions
diff --git a/tests/ui/test-attrs/test-fn-signature-verification-for-explicit-return-type.rs b/tests/ui/test-attrs/test-fn-signature-verification-for-explicit-return-type.rs
index 585874e27..02fee1a00 100644
--- a/tests/ui/test-attrs/test-fn-signature-verification-for-explicit-return-type.rs
+++ b/tests/ui/test-attrs/test-fn-signature-verification-for-explicit-return-type.rs
@@ -1,5 +1,5 @@
// run-pass
-// needs-unwind (#73509)
+// ignore-fuchsia Test must be run out-of-process
#![feature(test)]
diff --git a/tests/ui/test-attrs/test-function-signature.rs b/tests/ui/test-attrs/test-function-signature.rs
new file mode 100644
index 000000000..9e86e9209
--- /dev/null
+++ b/tests/ui/test-attrs/test-function-signature.rs
@@ -0,0 +1,31 @@
+// compile-flags: --test
+
+#[test]
+fn foo() -> Result<(), ()> {
+ Ok(())
+}
+
+#[test]
+fn bar() -> i32 { //~ ERROR the trait bound `i32: Termination` is not satisfied
+ 0
+}
+
+#[test]
+fn baz(val: i32) {} //~ ERROR functions used as tests can not have any arguments
+
+#[test]
+fn lifetime_generic<'a>() -> Result<(), &'a str> {
+ Err("coerce me to any lifetime")
+}
+
+#[test]
+fn type_generic<T>() {} //~ ERROR functions used as tests can not have any non-lifetime generic parameters
+
+#[test]
+fn const_generic<const N: usize>() {} //~ ERROR functions used as tests can not have any non-lifetime generic parameters
+
+// Regression test for <https://github.com/rust-lang/rust/issues/112360>. This used to ICE.
+fn nested() {
+ #[test]
+ fn foo(arg: ()) {} //~ ERROR functions used as tests can not have any arguments
+}
diff --git a/tests/ui/test-attrs/test-function-signature.stderr b/tests/ui/test-attrs/test-function-signature.stderr
new file mode 100644
index 000000000..abdb30dc9
--- /dev/null
+++ b/tests/ui/test-attrs/test-function-signature.stderr
@@ -0,0 +1,39 @@
+error: functions used as tests can not have any arguments
+ --> $DIR/test-function-signature.rs:14:1
+ |
+LL | fn baz(val: i32) {}
+ | ^^^^^^^^^^^^^^^^^^^
+
+error: functions used as tests can not have any non-lifetime generic parameters
+ --> $DIR/test-function-signature.rs:22:1
+ |
+LL | fn type_generic<T>() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+
+error: functions used as tests can not have any non-lifetime generic parameters
+ --> $DIR/test-function-signature.rs:25:1
+ |
+LL | fn const_generic<const N: usize>() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: functions used as tests can not have any arguments
+ --> $DIR/test-function-signature.rs:30:5
+ |
+LL | fn foo(arg: ()) {}
+ | ^^^^^^^^^^^^^^^^^^
+
+error[E0277]: the trait bound `i32: Termination` is not satisfied
+ --> $DIR/test-function-signature.rs:9:13
+ |
+LL | #[test]
+ | ------- in this procedural macro expansion
+LL | fn bar() -> i32 {
+ | ^^^ the trait `Termination` is not implemented for `i32`
+ |
+note: required by a bound in `assert_test_result`
+ --> $SRC_DIR/test/src/lib.rs:LL:COL
+ = note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/test-attrs/test-panic-abort-disabled.rs b/tests/ui/test-attrs/test-panic-abort-disabled.rs
index 874dbdb42..fa67a784d 100644
--- a/tests/ui/test-attrs/test-panic-abort-disabled.rs
+++ b/tests/ui/test-attrs/test-panic-abort-disabled.rs
@@ -3,6 +3,7 @@
// compile-flags: --test -Cpanic=abort -Zpanic-abort-tests=no
// run-flags: --test-threads=1
+// needs-unwind
// ignore-wasm no panic or subprocess support
// ignore-emscripten no panic or subprocess support
diff --git a/tests/ui/test-attrs/test-panic-abort.rs b/tests/ui/test-attrs/test-panic-abort.rs
index 931b7993c..08e5242af 100644
--- a/tests/ui/test-attrs/test-panic-abort.rs
+++ b/tests/ui/test-attrs/test-panic-abort.rs
@@ -11,9 +11,13 @@
// ignore-sgx no subprocess support
#![cfg(test)]
+#![feature(test)]
+
+extern crate test;
use std::io::Write;
use std::env;
+use test::Bencher;
#[test]
fn it_works() {
@@ -48,3 +52,8 @@ fn no_residual_environment() {
}
}
}
+
+#[bench]
+fn benchmark(b: &mut Bencher) {
+ b.iter(|| assert_eq!(1 + 1, 2));
+}
diff --git a/tests/ui/test-attrs/test-panic-abort.run.stdout b/tests/ui/test-attrs/test-panic-abort.run.stdout
index f608a8cdc..b6b9c2560 100644
--- a/tests/ui/test-attrs/test-panic-abort.run.stdout
+++ b/tests/ui/test-attrs/test-panic-abort.run.stdout
@@ -1,5 +1,6 @@
-running 5 tests
+running 6 tests
+test benchmark ... ok
test it_exits ... FAILED
test it_fails ... FAILED
test it_panics - should panic ... ok
@@ -18,7 +19,7 @@ testing123
testing321
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `2`,
- right: `5`', $DIR/test-panic-abort.rs:34:5
+ right: `5`', $DIR/test-panic-abort.rs:38:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@@ -26,5 +27,5 @@ failures:
it_exits
it_fails
-test result: FAILED. 3 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
+test result: FAILED. 4 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
diff --git a/tests/ui/test-attrs/test-type.rs b/tests/ui/test-attrs/test-type.rs
index 8416270fd..d6d44a6b4 100644
--- a/tests/ui/test-attrs/test-type.rs
+++ b/tests/ui/test-attrs/test-type.rs
@@ -1,9 +1,8 @@
-// compile-flags: --test
+// compile-flags: --test -Zpanic-abort-tests
// run-flags: --test-threads=1
// check-run-results
// normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
// ignore-emscripten no threads support
-// needs-unwind
// run-pass
#[test]