summaryrefslogtreecommitdiffstats
path: root/tests/ui/attributes
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/attributes')
-rw-r--r--tests/ui/attributes/invalid_macro_export_argument.rs26
-rw-r--r--tests/ui/attributes/invalid_macro_export_argument.stderr16
-rw-r--r--tests/ui/attributes/key-value-expansion.stderr7
-rw-r--r--tests/ui/attributes/log-backtrace.rs4
-rw-r--r--tests/ui/attributes/rustc-box.rs18
-rw-r--r--tests/ui/attributes/rustc-box.stderr34
6 files changed, 97 insertions, 8 deletions
diff --git a/tests/ui/attributes/invalid_macro_export_argument.rs b/tests/ui/attributes/invalid_macro_export_argument.rs
new file mode 100644
index 000000000..85d009f11
--- /dev/null
+++ b/tests/ui/attributes/invalid_macro_export_argument.rs
@@ -0,0 +1,26 @@
+// check-pass
+#[macro_export(hello, world)] //~ WARN `#[macro_export]` can only take 1 or 0 arguments
+macro_rules! a {
+ () => ()
+}
+
+#[macro_export(not_local_inner_macros)] //~ WARN `not_local_inner_macros` isn't a valid `#[macro_export]` argument
+macro_rules! b {
+ () => ()
+}
+
+#[macro_export]
+macro_rules! c {
+ () => ()
+}
+#[macro_export(local_inner_macros)]
+macro_rules! d {
+ () => ()
+}
+
+#[macro_export()]
+macro_rules! e {
+ () => ()
+}
+
+fn main() {}
diff --git a/tests/ui/attributes/invalid_macro_export_argument.stderr b/tests/ui/attributes/invalid_macro_export_argument.stderr
new file mode 100644
index 000000000..a4e17642c
--- /dev/null
+++ b/tests/ui/attributes/invalid_macro_export_argument.stderr
@@ -0,0 +1,16 @@
+warning: `#[macro_export]` can only take 1 or 0 arguments
+ --> $DIR/invalid_macro_export_argument.rs:2:1
+ |
+LL | #[macro_export(hello, world)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: `#[warn(invalid_macro_export_arguments)]` on by default
+
+warning: `not_local_inner_macros` isn't a valid `#[macro_export]` argument
+ --> $DIR/invalid_macro_export_argument.rs:7:16
+ |
+LL | #[macro_export(not_local_inner_macros)]
+ | ^^^^^^^^^^^^^^^^^^^^^^
+
+warning: 2 warnings emitted
+
diff --git a/tests/ui/attributes/key-value-expansion.stderr b/tests/ui/attributes/key-value-expansion.stderr
index 1b776322a..aaa8b1695 100644
--- a/tests/ui/attributes/key-value-expansion.stderr
+++ b/tests/ui/attributes/key-value-expansion.stderr
@@ -15,12 +15,7 @@ LL | bug!();
|
= note: this error originates in the macro `bug` (in Nightly builds, run with -Z macro-backtrace for more info)
-error: unexpected expression: `{
- let res =
- ::alloc::fmt::format(::core::fmt::Arguments::new_v1(&[""],
- &[::core::fmt::ArgumentV1::new_display(&"u8")]));
- res
- }.as_str()`
+error: unexpected expression: `{ let res = ::alloc::fmt::format(format_args!("{0}", "u8")); res }.as_str()`
--> $DIR/key-value-expansion.rs:48:23
|
LL | doc_comment! {format!("{coor}", coor = stringify!($t1)).as_str()}
diff --git a/tests/ui/attributes/log-backtrace.rs b/tests/ui/attributes/log-backtrace.rs
index 3979d2001..e42edf1d4 100644
--- a/tests/ui/attributes/log-backtrace.rs
+++ b/tests/ui/attributes/log-backtrace.rs
@@ -1,9 +1,9 @@
// run-pass
//
-// This test makes sure that log-backtrace option doesn't give a compilation error.
+// This test makes sure that log-backtrace option at least parses correctly
//
// dont-check-compiler-stdout
// dont-check-compiler-stderr
// rustc-env:RUSTC_LOG=info
-// compile-flags: -Zlog-backtrace=rustc_metadata::creader
+// rustc-env:RUSTC_LOG_BACKTRACE=rustc_metadata::creader
fn main() {}
diff --git a/tests/ui/attributes/rustc-box.rs b/tests/ui/attributes/rustc-box.rs
new file mode 100644
index 000000000..b3726fb38
--- /dev/null
+++ b/tests/ui/attributes/rustc-box.rs
@@ -0,0 +1,18 @@
+#![feature(rustc_attrs, stmt_expr_attributes)]
+
+fn foo(_: u32, _: u32) {}
+fn bar(_: u32) {}
+
+fn main() {
+ #[rustc_box]
+ Box::new(1); // OK
+ #[rustc_box]
+ Box::pin(1); //~ ERROR `#[rustc_box]` attribute used incorrectly
+ #[rustc_box]
+ foo(1, 1); //~ ERROR `#[rustc_box]` attribute used incorrectly
+ #[rustc_box]
+ bar(1); //~ ERROR `#[rustc_box]` attribute used incorrectly
+ #[rustc_box] //~ ERROR `#[rustc_box]` attribute used incorrectly
+ #[rustfmt::skip]
+ Box::new(1);
+}
diff --git a/tests/ui/attributes/rustc-box.stderr b/tests/ui/attributes/rustc-box.stderr
new file mode 100644
index 000000000..073a18c7d
--- /dev/null
+++ b/tests/ui/attributes/rustc-box.stderr
@@ -0,0 +1,34 @@
+error: `#[rustc_box]` attribute used incorrectly
+ --> $DIR/rustc-box.rs:10:5
+ |
+LL | Box::pin(1);
+ | ^^^^^^^^^^^
+ |
+ = note: `#[rustc_box]` may only be applied to a `Box::new()` call
+
+error: `#[rustc_box]` attribute used incorrectly
+ --> $DIR/rustc-box.rs:12:5
+ |
+LL | foo(1, 1);
+ | ^^^^^^^^^
+ |
+ = note: `#[rustc_box]` may only be applied to a `Box::new()` call
+
+error: `#[rustc_box]` attribute used incorrectly
+ --> $DIR/rustc-box.rs:14:5
+ |
+LL | bar(1);
+ | ^^^^^^
+ |
+ = note: `#[rustc_box]` may only be applied to a `Box::new()` call
+
+error: `#[rustc_box]` attribute used incorrectly
+ --> $DIR/rustc-box.rs:15:5
+ |
+LL | #[rustc_box]
+ | ^^^^^^^^^^^^
+ |
+ = note: no other attributes may be applied
+
+error: aborting due to 4 previous errors
+