From 3e3e70d529d8c7d7c4d7bc4fefc9f109393b9245 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:43 +0200 Subject: Merging upstream version 1.69.0+dfsg1. Signed-off-by: Daniel Baumann --- .../ui/attributes/invalid_macro_export_argument.rs | 26 +++++++++++++++++ .../invalid_macro_export_argument.stderr | 16 ++++++++++ tests/ui/attributes/key-value-expansion.stderr | 7 +---- tests/ui/attributes/log-backtrace.rs | 4 +-- tests/ui/attributes/rustc-box.rs | 18 ++++++++++++ tests/ui/attributes/rustc-box.stderr | 34 ++++++++++++++++++++++ 6 files changed, 97 insertions(+), 8 deletions(-) create mode 100644 tests/ui/attributes/invalid_macro_export_argument.rs create mode 100644 tests/ui/attributes/invalid_macro_export_argument.stderr create mode 100644 tests/ui/attributes/rustc-box.rs create mode 100644 tests/ui/attributes/rustc-box.stderr (limited to 'tests/ui/attributes') 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 + -- cgit v1.2.3