about summary refs log tree commit diff
path: root/tests/ui/lint
diff options
context:
space:
mode:
authorJonathan Brouwer <jonathantbrouwer@gmail.com>2025-08-23 13:12:01 +0200
committerJonathan Brouwer <jonathantbrouwer@gmail.com>2025-08-24 14:54:15 +0200
commitfe81a79e590ed73a931ea28b7dcc05e0b34a6420 (patch)
tree7186a2f0584f96ea4508359fc80fa94b7db3d154 /tests/ui/lint
parent3851e6c7b60294de337584e5bd8406225174af07 (diff)
downloadrust-fe81a79e590ed73a931ea28b7dcc05e0b34a6420.tar.gz
rust-fe81a79e590ed73a931ea28b7dcc05e0b34a6420.zip
Regression test for attributes on macro calls
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
Diffstat (limited to 'tests/ui/lint')
-rw-r--r--tests/ui/lint/inert-attr-macro.rs11
-rw-r--r--tests/ui/lint/inert-attr-macro.stderr38
-rw-r--r--tests/ui/lint/unused/unused_attributes-must_use.fixed1
-rw-r--r--tests/ui/lint/unused/unused_attributes-must_use.rs2
-rw-r--r--tests/ui/lint/unused/unused_attributes-must_use.stderr14
5 files changed, 24 insertions, 42 deletions
diff --git a/tests/ui/lint/inert-attr-macro.rs b/tests/ui/lint/inert-attr-macro.rs
index d345cbc0f07..c2ccba7f9ba 100644
--- a/tests/ui/lint/inert-attr-macro.rs
+++ b/tests/ui/lint/inert-attr-macro.rs
@@ -1,6 +1,5 @@
 //@ check-pass
 
-#![feature(rustc_attrs)]
 #![warn(unused)]
 
 macro_rules! foo {
@@ -8,16 +7,18 @@ macro_rules! foo {
 }
 
 fn main() {
-    #[rustc_dummy] foo!(); //~ WARN unused attribute `rustc_dummy`
+    #[inline] foo!(); //~ WARN `#[inline]` attribute cannot be used on macro calls
+    //~^ WARN previously accepted
 
     // This does nothing, since `#[allow(warnings)]` is itself
     // an inert attribute on a macro call
-    #[allow(warnings)] #[rustc_dummy] foo!(); //~ WARN unused attribute `allow`
-    //~^ WARN unused attribute `rustc_dummy`
+    #[allow(warnings)] #[inline] foo!(); //~ WARN unused attribute `allow`
+    //~^ WARN `#[inline]` attribute cannot be used on macro calls
+    //~| WARN previously accepted
 
     // This does work, since the attribute is on a parent
     // of the macro invocation.
-    #[allow(warnings)] { #[rustc_dummy] foo!(); }
+    #[allow(warnings)] { #[inline] foo!(); }
 
     // Ok, `cfg` and `cfg_attr` are expanded eagerly and do not warn.
     #[cfg(true)] foo!();
diff --git a/tests/ui/lint/inert-attr-macro.stderr b/tests/ui/lint/inert-attr-macro.stderr
index fc02ee34ae6..9ab6e3ddc74 100644
--- a/tests/ui/lint/inert-attr-macro.stderr
+++ b/tests/ui/lint/inert-attr-macro.stderr
@@ -1,16 +1,13 @@
-warning: unused attribute `rustc_dummy`
-  --> $DIR/inert-attr-macro.rs:11:5
+warning: `#[inline]` attribute cannot be used on macro calls
+  --> $DIR/inert-attr-macro.rs:10:5
    |
-LL |     #[rustc_dummy] foo!();
-   |     ^^^^^^^^^^^^^^
+LL |     #[inline] foo!();
+   |     ^^^^^^^^^
    |
-note: the built-in attribute `rustc_dummy` will be ignored, since it's applied to the macro invocation `foo`
-  --> $DIR/inert-attr-macro.rs:11:20
-   |
-LL |     #[rustc_dummy] foo!();
-   |                    ^^^
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[inline]` can only be applied to functions
 note: the lint level is defined here
-  --> $DIR/inert-attr-macro.rs:4:9
+  --> $DIR/inert-attr-macro.rs:3:9
    |
 LL | #![warn(unused)]
    |         ^^^^^^
@@ -19,26 +16,23 @@ LL | #![warn(unused)]
 warning: unused attribute `allow`
   --> $DIR/inert-attr-macro.rs:15:5
    |
-LL |     #[allow(warnings)] #[rustc_dummy] foo!();
+LL |     #[allow(warnings)] #[inline] foo!();
    |     ^^^^^^^^^^^^^^^^^^
    |
 note: the built-in attribute `allow` will be ignored, since it's applied to the macro invocation `foo`
-  --> $DIR/inert-attr-macro.rs:15:39
+  --> $DIR/inert-attr-macro.rs:15:34
    |
-LL |     #[allow(warnings)] #[rustc_dummy] foo!();
-   |                                       ^^^
+LL |     #[allow(warnings)] #[inline] foo!();
+   |                                  ^^^
 
-warning: unused attribute `rustc_dummy`
+warning: `#[inline]` attribute cannot be used on macro calls
   --> $DIR/inert-attr-macro.rs:15:24
    |
-LL |     #[allow(warnings)] #[rustc_dummy] foo!();
-   |                        ^^^^^^^^^^^^^^
-   |
-note: the built-in attribute `rustc_dummy` will be ignored, since it's applied to the macro invocation `foo`
-  --> $DIR/inert-attr-macro.rs:15:39
+LL |     #[allow(warnings)] #[inline] foo!();
+   |                        ^^^^^^^^^
    |
-LL |     #[allow(warnings)] #[rustc_dummy] foo!();
-   |                                       ^^^
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[inline]` can only be applied to functions
 
 warning: 3 warnings emitted
 
diff --git a/tests/ui/lint/unused/unused_attributes-must_use.fixed b/tests/ui/lint/unused/unused_attributes-must_use.fixed
index 6bc63c8ee5b..fa596da95cc 100644
--- a/tests/ui/lint/unused/unused_attributes-must_use.fixed
+++ b/tests/ui/lint/unused/unused_attributes-must_use.fixed
@@ -65,7 +65,6 @@ extern "Rust" {
     fn foreign_foo() -> i64;
 }
 
- //~ ERROR unused attribute
 //~^ ERROR `#[must_use]` attribute cannot be used on macro calls
 //~| WARN this was previously accepted by the compiler but is being phased out
 global_asm!("");
diff --git a/tests/ui/lint/unused/unused_attributes-must_use.rs b/tests/ui/lint/unused/unused_attributes-must_use.rs
index 3c0d76e619f..3e72dd1e438 100644
--- a/tests/ui/lint/unused/unused_attributes-must_use.rs
+++ b/tests/ui/lint/unused/unused_attributes-must_use.rs
@@ -65,7 +65,7 @@ extern "Rust" {
     fn foreign_foo() -> i64;
 }
 
-#[must_use] //~ ERROR unused attribute
+#[must_use]
 //~^ ERROR `#[must_use]` attribute cannot be used on macro calls
 //~| WARN this was previously accepted by the compiler but is being phased out
 global_asm!("");
diff --git a/tests/ui/lint/unused/unused_attributes-must_use.stderr b/tests/ui/lint/unused/unused_attributes-must_use.stderr
index 231d799057c..001ec52ddd9 100644
--- a/tests/ui/lint/unused/unused_attributes-must_use.stderr
+++ b/tests/ui/lint/unused/unused_attributes-must_use.stderr
@@ -12,18 +12,6 @@ note: the lint level is defined here
 LL | #![deny(unused_attributes, unused_must_use)]
    |         ^^^^^^^^^^^^^^^^^
 
-error: unused attribute `must_use`
-  --> $DIR/unused_attributes-must_use.rs:68:1
-   |
-LL | #[must_use]
-   | ^^^^^^^^^^^
-   |
-note: the built-in attribute `must_use` will be ignored, since it's applied to the macro invocation `global_asm`
-  --> $DIR/unused_attributes-must_use.rs:71:1
-   |
-LL | global_asm!("");
-   | ^^^^^^^^^^
-
 error: `#[must_use]` attribute cannot be used on extern crates
   --> $DIR/unused_attributes-must_use.rs:7:1
    |
@@ -295,5 +283,5 @@ help: use `let _ = ...` to ignore the resulting value
 LL |     let _ = ().get_four();
    |     +++++++
 
-error: aborting due to 30 previous errors
+error: aborting due to 29 previous errors