summaryrefslogtreecommitdiffstats
path: root/tests/ui/test-attrs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /tests/ui/test-attrs
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/test-attrs')
-rw-r--r--tests/ui/test-attrs/issue-12997-1.rs11
-rw-r--r--tests/ui/test-attrs/issue-12997-1.stderr14
-rw-r--r--tests/ui/test-attrs/issue-12997-2.rs9
-rw-r--r--tests/ui/test-attrs/issue-12997-2.stderr21
-rw-r--r--tests/ui/test-attrs/issue-34932.rs11
-rw-r--r--tests/ui/test-attrs/test-type.rs1
-rw-r--r--tests/ui/test-attrs/tests-listing-format-json-without-unstableopts.run.stderr2
-rw-r--r--tests/ui/test-attrs/tests-listing-format-json.run.stdout6
8 files changed, 71 insertions, 4 deletions
diff --git a/tests/ui/test-attrs/issue-12997-1.rs b/tests/ui/test-attrs/issue-12997-1.rs
new file mode 100644
index 000000000..9f808dac3
--- /dev/null
+++ b/tests/ui/test-attrs/issue-12997-1.rs
@@ -0,0 +1,11 @@
+// compile-flags: --test
+
+//! Test that makes sure wrongly-typed bench functions aren't ignored
+
+#![feature(test)]
+
+#[bench]
+fn foo() { } //~ ERROR functions used as benches
+
+#[bench]
+fn bar(x: isize, y: isize) { } //~ ERROR functions used as benches
diff --git a/tests/ui/test-attrs/issue-12997-1.stderr b/tests/ui/test-attrs/issue-12997-1.stderr
new file mode 100644
index 000000000..00c605174
--- /dev/null
+++ b/tests/ui/test-attrs/issue-12997-1.stderr
@@ -0,0 +1,14 @@
+error: functions used as benches must have signature `fn(&mut Bencher) -> impl Termination`
+ --> $DIR/issue-12997-1.rs:8:1
+ |
+LL | fn foo() { }
+ | ^^^^^^^^^^^^
+
+error: functions used as benches must have signature `fn(&mut Bencher) -> impl Termination`
+ --> $DIR/issue-12997-1.rs:11:1
+ |
+LL | fn bar(x: isize, y: isize) { }
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/test-attrs/issue-12997-2.rs b/tests/ui/test-attrs/issue-12997-2.rs
new file mode 100644
index 000000000..9df965315
--- /dev/null
+++ b/tests/ui/test-attrs/issue-12997-2.rs
@@ -0,0 +1,9 @@
+// compile-flags: --test
+
+//! Test that makes sure wrongly-typed bench functions are rejected
+
+#![feature(test)]
+
+#[bench]
+fn bar(x: isize) { }
+//~^ ERROR mismatched types
diff --git a/tests/ui/test-attrs/issue-12997-2.stderr b/tests/ui/test-attrs/issue-12997-2.stderr
new file mode 100644
index 000000000..2a3d0e345
--- /dev/null
+++ b/tests/ui/test-attrs/issue-12997-2.stderr
@@ -0,0 +1,21 @@
+error[E0308]: mismatched types
+ --> $DIR/issue-12997-2.rs:8:1
+ |
+LL | #[bench]
+ | -------- in this procedural macro expansion
+LL | fn bar(x: isize) { }
+ | ^^^^^^^^^^^^^^^^^^^^
+ | |
+ | expected `isize`, found `&mut Bencher`
+ | arguments to this function are incorrect
+ |
+note: function defined here
+ --> $DIR/issue-12997-2.rs:8:4
+ |
+LL | fn bar(x: isize) { }
+ | ^^^ --------
+ = note: this error originates in the attribute macro `bench` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/test-attrs/issue-34932.rs b/tests/ui/test-attrs/issue-34932.rs
new file mode 100644
index 000000000..ab568fd01
--- /dev/null
+++ b/tests/ui/test-attrs/issue-34932.rs
@@ -0,0 +1,11 @@
+// run-pass
+// compile-flags:--test
+#![cfg(any())] // This test should be configured away
+#![feature(rustc_attrs)] // Test that this is allowed on stable/beta
+#![feature(iter_arith_traits)] // Test that this is not unused
+#![deny(unused_features)]
+
+#[test]
+fn dummy() {
+ let () = "this should not reach type-checking";
+}
diff --git a/tests/ui/test-attrs/test-type.rs b/tests/ui/test-attrs/test-type.rs
index f99e476ea..8416270fd 100644
--- a/tests/ui/test-attrs/test-type.rs
+++ b/tests/ui/test-attrs/test-type.rs
@@ -3,6 +3,7 @@
// check-run-results
// normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
// ignore-emscripten no threads support
+// needs-unwind
// run-pass
#[test]
diff --git a/tests/ui/test-attrs/tests-listing-format-json-without-unstableopts.run.stderr b/tests/ui/test-attrs/tests-listing-format-json-without-unstableopts.run.stderr
index 9f6276300..5d8b37554 100644
--- a/tests/ui/test-attrs/tests-listing-format-json-without-unstableopts.run.stderr
+++ b/tests/ui/test-attrs/tests-listing-format-json-without-unstableopts.run.stderr
@@ -1 +1 @@
-error: The "json" format is only accepted on the nightly compiler
+error: The "json" format is only accepted on the nightly compiler with -Z unstable-options
diff --git a/tests/ui/test-attrs/tests-listing-format-json.run.stdout b/tests/ui/test-attrs/tests-listing-format-json.run.stdout
index b4131e97c..33cc939b5 100644
--- a/tests/ui/test-attrs/tests-listing-format-json.run.stdout
+++ b/tests/ui/test-attrs/tests-listing-format-json.run.stdout
@@ -1,5 +1,5 @@
{ "type": "suite", "event": "discovery" }
-{ "type": "test", "event": "discovered", "name": "a_test", "ignore": false, "ignore_message": "", "source_path": "$DIR/tests-listing-format-json.rs", "start_line": 20, "start_col": 4, "end_line": 20, "end_col": 10 }
-{ "type": "test", "event": "discovered", "name": "m_test", "ignore": false, "ignore_message": "", "source_path": "$DIR/tests-listing-format-json.rs", "start_line": 13, "start_col": 4, "end_line": 13, "end_col": 10 }
-{ "type": "test", "event": "discovered", "name": "z_test", "ignore": true, "ignore_message": "not yet implemented", "source_path": "$DIR/tests-listing-format-json.rs", "start_line": 17, "start_col": 4, "end_line": 17, "end_col": 10 }
+{ "type": "test", "event": "discovered", "name": "a_test", "ignore": false, "ignore_message": "", "source_path": "$DIR/tests-listing-format-json.rs", "start_line": 21, "start_col": 4, "end_line": 21, "end_col": 10 }
+{ "type": "test", "event": "discovered", "name": "m_test", "ignore": false, "ignore_message": "", "source_path": "$DIR/tests-listing-format-json.rs", "start_line": 14, "start_col": 4, "end_line": 14, "end_col": 10 }
+{ "type": "test", "event": "discovered", "name": "z_test", "ignore": true, "ignore_message": "not yet implemented", "source_path": "$DIR/tests-listing-format-json.rs", "start_line": 18, "start_col": 4, "end_line": 18, "end_col": 10 }
{ "type": "suite", "event": "completed", "tests": 3, "benchmarks": 0, "total": 3, "ignored": 1 }