about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2020-11-26 21:44:09 -0500
committerAaron Hill <aa1ronham@gmail.com>2020-11-26 22:02:35 -0500
commite8564ad5898ad8358f5449e94ab7119fb92a9f80 (patch)
tree085c3c0f0e3c3b66e2ebdafb62a841593a1e6bde
parent6f91c32da68aac9956c894608bd0a85f554d98c6 (diff)
downloadrust-e8564ad5898ad8358f5449e94ab7119fb92a9f80.tar.gz
rust-e8564ad5898ad8358f5449e94ab7119fb92a9f80.zip
Use custom macro instead of println
Loading a macro from libstd causes us to load serialized
`SyntaxContext`s in a platform-dependent way, causing the printed spans
to differ between platforms.
-rw-r--r--src/test/ui/proc-macro/allowed-attr-stmt-expr.rs18
-rw-r--r--src/test/ui/proc-macro/allowed-attr-stmt-expr.stdout130
-rw-r--r--src/test/ui/proc-macro/attr-stmt-expr.rs17
-rw-r--r--src/test/ui/proc-macro/attr-stmt-expr.stderr8
-rw-r--r--src/test/ui/proc-macro/attr-stmt-expr.stdout112
-rw-r--r--src/test/ui/proc-macro/auxiliary/attr-stmt-expr.rs8
6 files changed, 152 insertions, 141 deletions
diff --git a/src/test/ui/proc-macro/allowed-attr-stmt-expr.rs b/src/test/ui/proc-macro/allowed-attr-stmt-expr.rs
index 9e82ccd9bed..25243aeef3b 100644
--- a/src/test/ui/proc-macro/allowed-attr-stmt-expr.rs
+++ b/src/test/ui/proc-macro/allowed-attr-stmt-expr.rs
@@ -13,14 +13,20 @@ extern crate std;
 
 extern crate attr_stmt_expr;
 extern crate test_macros;
-use attr_stmt_expr::{expect_let, expect_print_stmt, expect_expr, expect_print_expr};
+use attr_stmt_expr::{expect_let, expect_my_macro_stmt, expect_expr, expect_my_macro_expr};
 use test_macros::print_attr;
-use std::println;
+
+// We don't use `std::println` so that we avoid loading hygiene
+// information from libstd, which would affect the SyntaxContext ids
+macro_rules! my_macro {
+    ($($tt:tt)*) => { () }
+}
+
 
 fn print_str(string: &'static str) {
     // macros are handled a bit differently
-    #[expect_print_expr]
-    println!("{}", string)
+    #[expect_my_macro_expr]
+    my_macro!("{}", string)
 }
 
 macro_rules! make_stmt {
@@ -51,8 +57,8 @@ fn main() {
     let string = "Hello, world!";
 
     #[print_attr]
-    #[expect_print_stmt]
-    println!("{}", string);
+    #[expect_my_macro_stmt]
+    my_macro!("{}", string);
 
     #[print_attr]
     second_make_stmt!(#[allow(dead_code)] struct Bar {});
diff --git a/src/test/ui/proc-macro/allowed-attr-stmt-expr.stdout b/src/test/ui/proc-macro/allowed-attr-stmt-expr.stdout
index be14e368c04..6cf864f3590 100644
--- a/src/test/ui/proc-macro/allowed-attr-stmt-expr.stdout
+++ b/src/test/ui/proc-macro/allowed-attr-stmt-expr.stdout
@@ -2,16 +2,16 @@ PRINT-ATTR INPUT (DISPLAY): struct ItemWithSemi ;
 PRINT-ATTR INPUT (DEBUG): TokenStream [
     Ident {
         ident: "struct",
-        span: $DIR/allowed-attr-stmt-expr.rs:43:1: 43:7 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:49:1: 49:7 (#0),
     },
     Ident {
         ident: "ItemWithSemi",
-        span: $DIR/allowed-attr-stmt-expr.rs:43:8: 43:20 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:49:8: 49:20 (#0),
     },
     Punct {
         ch: ';',
         spacing: Alone,
-        span: $DIR/allowed-attr-stmt-expr.rs:43:20: 43:21 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:49:20: 49:21 (#0),
     },
 ]
 PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] struct Foo { }
@@ -19,30 +19,30 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
     Punct {
         ch: '#',
         spacing: Alone,
-        span: $DIR/allowed-attr-stmt-expr.rs:29:9: 29:10 (#15),
+        span: $DIR/allowed-attr-stmt-expr.rs:35:9: 35:10 (#11),
     },
     Group {
         delimiter: Bracket,
         stream: TokenStream [
             Ident {
                 ident: "rustc_dummy",
-                span: $DIR/allowed-attr-stmt-expr.rs:29:11: 29:22 (#15),
+                span: $DIR/allowed-attr-stmt-expr.rs:35:11: 35:22 (#11),
             },
         ],
-        span: $DIR/allowed-attr-stmt-expr.rs:29:10: 29:23 (#15),
+        span: $DIR/allowed-attr-stmt-expr.rs:35:10: 35:23 (#11),
     },
     Ident {
         ident: "struct",
-        span: $DIR/allowed-attr-stmt-expr.rs:47:16: 47:22 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:53:16: 53:22 (#0),
     },
     Ident {
         ident: "Foo",
-        span: $DIR/allowed-attr-stmt-expr.rs:47:23: 47:26 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:53:23: 53:26 (#0),
     },
     Group {
         delimiter: Brace,
         stream: TokenStream [],
-        span: $DIR/allowed-attr-stmt-expr.rs:47:27: 47:29 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:53:27: 53:29 (#0),
     },
 ]
 PRINT-ATTR INPUT (DISPLAY): #[expect_let] let string = "Hello, world!" ;
@@ -50,68 +50,68 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
     Punct {
         ch: '#',
         spacing: Alone,
-        span: $DIR/allowed-attr-stmt-expr.rs:50:5: 50:6 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:56:5: 56:6 (#0),
     },
     Group {
         delimiter: Bracket,
         stream: TokenStream [
             Ident {
                 ident: "expect_let",
-                span: $DIR/allowed-attr-stmt-expr.rs:50:7: 50:17 (#0),
+                span: $DIR/allowed-attr-stmt-expr.rs:56:7: 56:17 (#0),
             },
         ],
-        span: $DIR/allowed-attr-stmt-expr.rs:50:6: 50:18 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:56:6: 56:18 (#0),
     },
     Ident {
         ident: "let",
-        span: $DIR/allowed-attr-stmt-expr.rs:51:5: 51:8 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:57:5: 57:8 (#0),
     },
     Ident {
         ident: "string",
-        span: $DIR/allowed-attr-stmt-expr.rs:51:9: 51:15 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:57:9: 57:15 (#0),
     },
     Punct {
         ch: '=',
         spacing: Alone,
-        span: $DIR/allowed-attr-stmt-expr.rs:51:16: 51:17 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:57:16: 57:17 (#0),
     },
     Literal {
         kind: Str,
         symbol: "Hello, world!",
         suffix: None,
-        span: $DIR/allowed-attr-stmt-expr.rs:51:18: 51:33 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:57:18: 57:33 (#0),
     },
     Punct {
         ch: ';',
         spacing: Alone,
-        span: $DIR/allowed-attr-stmt-expr.rs:51:33: 51:34 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:57:33: 57:34 (#0),
     },
 ]
-PRINT-ATTR INPUT (DISPLAY): #[expect_print_stmt] println ! ("{}", string) ;
+PRINT-ATTR INPUT (DISPLAY): #[expect_my_macro_stmt] my_macro ! ("{}", string) ;
 PRINT-ATTR INPUT (DEBUG): TokenStream [
     Punct {
         ch: '#',
         spacing: Alone,
-        span: $DIR/allowed-attr-stmt-expr.rs:54:5: 54:6 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:60:5: 60:6 (#0),
     },
     Group {
         delimiter: Bracket,
         stream: TokenStream [
             Ident {
-                ident: "expect_print_stmt",
-                span: $DIR/allowed-attr-stmt-expr.rs:54:7: 54:24 (#0),
+                ident: "expect_my_macro_stmt",
+                span: $DIR/allowed-attr-stmt-expr.rs:60:7: 60:27 (#0),
             },
         ],
-        span: $DIR/allowed-attr-stmt-expr.rs:54:6: 54:25 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:60:6: 60:28 (#0),
     },
     Ident {
-        ident: "println",
-        span: $DIR/allowed-attr-stmt-expr.rs:55:5: 55:12 (#0),
+        ident: "my_macro",
+        span: $DIR/allowed-attr-stmt-expr.rs:61:5: 61:13 (#0),
     },
     Punct {
         ch: '!',
         spacing: Alone,
-        span: $DIR/allowed-attr-stmt-expr.rs:55:12: 55:13 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:61:13: 61:14 (#0),
     },
     Group {
         delimiter: Parenthesis,
@@ -120,36 +120,36 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
                 kind: Str,
                 symbol: "{}",
                 suffix: None,
-                span: $DIR/allowed-attr-stmt-expr.rs:55:14: 55:18 (#0),
+                span: $DIR/allowed-attr-stmt-expr.rs:61:15: 61:19 (#0),
             },
             Punct {
                 ch: ',',
                 spacing: Alone,
-                span: $DIR/allowed-attr-stmt-expr.rs:55:18: 55:19 (#0),
+                span: $DIR/allowed-attr-stmt-expr.rs:61:19: 61:20 (#0),
             },
             Ident {
                 ident: "string",
-                span: $DIR/allowed-attr-stmt-expr.rs:55:20: 55:26 (#0),
+                span: $DIR/allowed-attr-stmt-expr.rs:61:21: 61:27 (#0),
             },
         ],
-        span: $DIR/allowed-attr-stmt-expr.rs:55:13: 55:27 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:61:14: 61:28 (#0),
     },
     Punct {
         ch: ';',
         spacing: Alone,
-        span: $DIR/allowed-attr-stmt-expr.rs:55:27: 55:28 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:61:28: 61:29 (#0),
     },
 ]
 PRINT-ATTR INPUT (DISPLAY): second_make_stmt ! (#[allow(dead_code)] struct Bar { }) ;
 PRINT-ATTR INPUT (DEBUG): TokenStream [
     Ident {
         ident: "second_make_stmt",
-        span: $DIR/allowed-attr-stmt-expr.rs:58:5: 58:21 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:64:5: 64:21 (#0),
     },
     Punct {
         ch: '!',
         spacing: Alone,
-        span: $DIR/allowed-attr-stmt-expr.rs:58:21: 58:22 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:64:21: 64:22 (#0),
     },
     Group {
         delimiter: Parenthesis,
@@ -157,48 +157,48 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
             Punct {
                 ch: '#',
                 spacing: Alone,
-                span: $DIR/allowed-attr-stmt-expr.rs:58:23: 58:24 (#0),
+                span: $DIR/allowed-attr-stmt-expr.rs:64:23: 64:24 (#0),
             },
             Group {
                 delimiter: Bracket,
                 stream: TokenStream [
                     Ident {
                         ident: "allow",
-                        span: $DIR/allowed-attr-stmt-expr.rs:58:25: 58:30 (#0),
+                        span: $DIR/allowed-attr-stmt-expr.rs:64:25: 64:30 (#0),
                     },
                     Group {
                         delimiter: Parenthesis,
                         stream: TokenStream [
                             Ident {
                                 ident: "dead_code",
-                                span: $DIR/allowed-attr-stmt-expr.rs:58:31: 58:40 (#0),
+                                span: $DIR/allowed-attr-stmt-expr.rs:64:31: 64:40 (#0),
                             },
                         ],
-                        span: $DIR/allowed-attr-stmt-expr.rs:58:30: 58:41 (#0),
+                        span: $DIR/allowed-attr-stmt-expr.rs:64:30: 64:41 (#0),
                     },
                 ],
-                span: $DIR/allowed-attr-stmt-expr.rs:58:24: 58:42 (#0),
+                span: $DIR/allowed-attr-stmt-expr.rs:64:24: 64:42 (#0),
             },
             Ident {
                 ident: "struct",
-                span: $DIR/allowed-attr-stmt-expr.rs:58:43: 58:49 (#0),
+                span: $DIR/allowed-attr-stmt-expr.rs:64:43: 64:49 (#0),
             },
             Ident {
                 ident: "Bar",
-                span: $DIR/allowed-attr-stmt-expr.rs:58:50: 58:53 (#0),
+                span: $DIR/allowed-attr-stmt-expr.rs:64:50: 64:53 (#0),
             },
             Group {
                 delimiter: Brace,
                 stream: TokenStream [],
-                span: $DIR/allowed-attr-stmt-expr.rs:58:54: 58:56 (#0),
+                span: $DIR/allowed-attr-stmt-expr.rs:64:54: 64:56 (#0),
             },
         ],
-        span: $DIR/allowed-attr-stmt-expr.rs:58:22: 58:57 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:64:22: 64:57 (#0),
     },
     Punct {
         ch: ';',
         spacing: Alone,
-        span: $DIR/allowed-attr-stmt-expr.rs:58:57: 58:58 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:64:57: 64:58 (#0),
     },
 ]
 PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] #[allow(dead_code)] struct Bar { }
@@ -206,55 +206,55 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
     Punct {
         ch: '#',
         spacing: Alone,
-        span: $DIR/allowed-attr-stmt-expr.rs:29:9: 29:10 (#37),
+        span: $DIR/allowed-attr-stmt-expr.rs:35:9: 35:10 (#32),
     },
     Group {
         delimiter: Bracket,
         stream: TokenStream [
             Ident {
                 ident: "rustc_dummy",
-                span: $DIR/allowed-attr-stmt-expr.rs:29:11: 29:22 (#37),
+                span: $DIR/allowed-attr-stmt-expr.rs:35:11: 35:22 (#32),
             },
         ],
-        span: $DIR/allowed-attr-stmt-expr.rs:29:10: 29:23 (#37),
+        span: $DIR/allowed-attr-stmt-expr.rs:35:10: 35:23 (#32),
     },
     Punct {
         ch: '#',
         spacing: Alone,
-        span: $DIR/allowed-attr-stmt-expr.rs:58:23: 58:24 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:64:23: 64:24 (#0),
     },
     Group {
         delimiter: Bracket,
         stream: TokenStream [
             Ident {
                 ident: "allow",
-                span: $DIR/allowed-attr-stmt-expr.rs:58:25: 58:30 (#0),
+                span: $DIR/allowed-attr-stmt-expr.rs:64:25: 64:30 (#0),
             },
             Group {
                 delimiter: Parenthesis,
                 stream: TokenStream [
                     Ident {
                         ident: "dead_code",
-                        span: $DIR/allowed-attr-stmt-expr.rs:58:31: 58:40 (#0),
+                        span: $DIR/allowed-attr-stmt-expr.rs:64:31: 64:40 (#0),
                     },
                 ],
-                span: $DIR/allowed-attr-stmt-expr.rs:58:30: 58:41 (#0),
+                span: $DIR/allowed-attr-stmt-expr.rs:64:30: 64:41 (#0),
             },
         ],
-        span: $DIR/allowed-attr-stmt-expr.rs:58:24: 58:42 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:64:24: 64:42 (#0),
     },
     Ident {
         ident: "struct",
-        span: $DIR/allowed-attr-stmt-expr.rs:58:43: 58:49 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:64:43: 64:49 (#0),
     },
     Ident {
         ident: "Bar",
-        span: $DIR/allowed-attr-stmt-expr.rs:58:50: 58:53 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:64:50: 64:53 (#0),
     },
     Group {
         delimiter: Brace,
         stream: TokenStream [],
-        span: $DIR/allowed-attr-stmt-expr.rs:58:54: 58:56 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:64:54: 64:56 (#0),
     },
 ]
 PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] struct Other { }
@@ -262,30 +262,30 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
     Punct {
         ch: '#',
         spacing: Alone,
-        span: $DIR/allowed-attr-stmt-expr.rs:61:5: 61:6 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:67:5: 67:6 (#0),
     },
     Group {
         delimiter: Bracket,
         stream: TokenStream [
             Ident {
                 ident: "rustc_dummy",
-                span: $DIR/allowed-attr-stmt-expr.rs:61:7: 61:18 (#0),
+                span: $DIR/allowed-attr-stmt-expr.rs:67:7: 67:18 (#0),
             },
         ],
-        span: $DIR/allowed-attr-stmt-expr.rs:61:6: 61:19 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:67:6: 67:19 (#0),
     },
     Ident {
         ident: "struct",
-        span: $DIR/allowed-attr-stmt-expr.rs:62:5: 62:11 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:68:5: 68:11 (#0),
     },
     Ident {
         ident: "Other",
-        span: $DIR/allowed-attr-stmt-expr.rs:62:12: 62:17 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:68:12: 68:17 (#0),
     },
     Group {
         delimiter: Brace,
         stream: TokenStream [],
-        span: $DIR/allowed-attr-stmt-expr.rs:62:18: 62:20 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:68:18: 68:20 (#0),
     },
 ]
 PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] struct NonBracedStruct ;
@@ -293,29 +293,29 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
     Punct {
         ch: '#',
         spacing: Alone,
-        span: $DIR/allowed-attr-stmt-expr.rs:67:5: 67:6 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:73:5: 73:6 (#0),
     },
     Group {
         delimiter: Bracket,
         stream: TokenStream [
             Ident {
                 ident: "rustc_dummy",
-                span: $DIR/allowed-attr-stmt-expr.rs:67:7: 67:18 (#0),
+                span: $DIR/allowed-attr-stmt-expr.rs:73:7: 73:18 (#0),
             },
         ],
-        span: $DIR/allowed-attr-stmt-expr.rs:67:6: 67:19 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:73:6: 73:19 (#0),
     },
     Ident {
         ident: "struct",
-        span: $DIR/allowed-attr-stmt-expr.rs:68:5: 68:11 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:74:5: 74:11 (#0),
     },
     Ident {
         ident: "NonBracedStruct",
-        span: $DIR/allowed-attr-stmt-expr.rs:68:12: 68:27 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:74:12: 74:27 (#0),
     },
     Punct {
         ch: ';',
         spacing: Alone,
-        span: $DIR/allowed-attr-stmt-expr.rs:68:27: 68:28 (#0),
+        span: $DIR/allowed-attr-stmt-expr.rs:74:27: 74:28 (#0),
     },
 ]
diff --git a/src/test/ui/proc-macro/attr-stmt-expr.rs b/src/test/ui/proc-macro/attr-stmt-expr.rs
index 4f18ce9bf48..0403684cda0 100644
--- a/src/test/ui/proc-macro/attr-stmt-expr.rs
+++ b/src/test/ui/proc-macro/attr-stmt-expr.rs
@@ -11,15 +11,20 @@ extern crate test_macros;
 extern crate attr_stmt_expr;
 
 use test_macros::print_attr;
-use std::println;
-use attr_stmt_expr::{expect_let, expect_print_stmt, expect_expr, expect_print_expr};
+use attr_stmt_expr::{expect_let, expect_my_macro_stmt, expect_expr, expect_my_macro_expr};
+
+// We don't use `std::println` so that we avoid loading hygiene
+// information from libstd, which would affect the SyntaxContext ids
+macro_rules! my_macro {
+    ($($tt:tt)*) => { () }
+}
 
 fn print_str(string: &'static str) {
     // macros are handled a bit differently
-    #[expect_print_expr]
+    #[expect_my_macro_expr]
     //~^ ERROR attributes on expressions are experimental
     //~| HELP add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
-    println!("{}", string)
+    my_macro!("{}", string)
 }
 
 macro_rules! make_stmt {
@@ -44,8 +49,8 @@ fn main() {
     let string = "Hello, world!";
 
     #[print_attr]
-    #[expect_print_stmt]
-    println!("{}", string);
+    #[expect_my_macro_stmt]
+    my_macro!("{}", string);
 
     #[print_attr]
     second_make_stmt!(#[allow(dead_code)] struct Bar {});
diff --git a/src/test/ui/proc-macro/attr-stmt-expr.stderr b/src/test/ui/proc-macro/attr-stmt-expr.stderr
index 1cc7d474fcf..56178259d43 100644
--- a/src/test/ui/proc-macro/attr-stmt-expr.stderr
+++ b/src/test/ui/proc-macro/attr-stmt-expr.stderr
@@ -1,14 +1,14 @@
 error[E0658]: attributes on expressions are experimental
-  --> $DIR/attr-stmt-expr.rs:19:5
+  --> $DIR/attr-stmt-expr.rs:24:5
    |
-LL |     #[expect_print_expr]
-   |     ^^^^^^^^^^^^^^^^^^^^
+LL |     #[expect_my_macro_expr]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
    = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
 
 error[E0658]: attributes on expressions are experimental
-  --> $DIR/attr-stmt-expr.rs:57:5
+  --> $DIR/attr-stmt-expr.rs:62:5
    |
 LL |     #[expect_expr]
    |     ^^^^^^^^^^^^^^
diff --git a/src/test/ui/proc-macro/attr-stmt-expr.stdout b/src/test/ui/proc-macro/attr-stmt-expr.stdout
index ed8af761a55..f75309e6872 100644
--- a/src/test/ui/proc-macro/attr-stmt-expr.stdout
+++ b/src/test/ui/proc-macro/attr-stmt-expr.stdout
@@ -3,30 +3,30 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
     Punct {
         ch: '#',
         spacing: Alone,
-        span: $DIR/attr-stmt-expr.rs:28:9: 28:10 (#12),
+        span: $DIR/attr-stmt-expr.rs:33:9: 33:10 (#8),
     },
     Group {
         delimiter: Bracket,
         stream: TokenStream [
             Ident {
                 ident: "rustc_dummy",
-                span: $DIR/attr-stmt-expr.rs:28:11: 28:22 (#12),
+                span: $DIR/attr-stmt-expr.rs:33:11: 33:22 (#8),
             },
         ],
-        span: $DIR/attr-stmt-expr.rs:28:10: 28:23 (#12),
+        span: $DIR/attr-stmt-expr.rs:33:10: 33:23 (#8),
     },
     Ident {
         ident: "struct",
-        span: $DIR/attr-stmt-expr.rs:40:16: 40:22 (#0),
+        span: $DIR/attr-stmt-expr.rs:45:16: 45:22 (#0),
     },
     Ident {
         ident: "Foo",
-        span: $DIR/attr-stmt-expr.rs:40:23: 40:26 (#0),
+        span: $DIR/attr-stmt-expr.rs:45:23: 45:26 (#0),
     },
     Group {
         delimiter: Brace,
         stream: TokenStream [],
-        span: $DIR/attr-stmt-expr.rs:40:27: 40:29 (#0),
+        span: $DIR/attr-stmt-expr.rs:45:27: 45:29 (#0),
     },
 ]
 PRINT-ATTR INPUT (DISPLAY): #[expect_let] let string = "Hello, world!" ;
@@ -34,68 +34,68 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
     Punct {
         ch: '#',
         spacing: Alone,
-        span: $DIR/attr-stmt-expr.rs:43:5: 43:6 (#0),
+        span: $DIR/attr-stmt-expr.rs:48:5: 48:6 (#0),
     },
     Group {
         delimiter: Bracket,
         stream: TokenStream [
             Ident {
                 ident: "expect_let",
-                span: $DIR/attr-stmt-expr.rs:43:7: 43:17 (#0),
+                span: $DIR/attr-stmt-expr.rs:48:7: 48:17 (#0),
             },
         ],
-        span: $DIR/attr-stmt-expr.rs:43:6: 43:18 (#0),
+        span: $DIR/attr-stmt-expr.rs:48:6: 48:18 (#0),
     },
     Ident {
         ident: "let",
-        span: $DIR/attr-stmt-expr.rs:44:5: 44:8 (#0),
+        span: $DIR/attr-stmt-expr.rs:49:5: 49:8 (#0),
     },
     Ident {
         ident: "string",
-        span: $DIR/attr-stmt-expr.rs:44:9: 44:15 (#0),
+        span: $DIR/attr-stmt-expr.rs:49:9: 49:15 (#0),
     },
     Punct {
         ch: '=',
         spacing: Alone,
-        span: $DIR/attr-stmt-expr.rs:44:16: 44:17 (#0),
+        span: $DIR/attr-stmt-expr.rs:49:16: 49:17 (#0),
     },
     Literal {
         kind: Str,
         symbol: "Hello, world!",
         suffix: None,
-        span: $DIR/attr-stmt-expr.rs:44:18: 44:33 (#0),
+        span: $DIR/attr-stmt-expr.rs:49:18: 49:33 (#0),
     },
     Punct {
         ch: ';',
         spacing: Alone,
-        span: $DIR/attr-stmt-expr.rs:44:33: 44:34 (#0),
+        span: $DIR/attr-stmt-expr.rs:49:33: 49:34 (#0),
     },
 ]
-PRINT-ATTR INPUT (DISPLAY): #[expect_print_stmt] println ! ("{}", string) ;
+PRINT-ATTR INPUT (DISPLAY): #[expect_my_macro_stmt] my_macro ! ("{}", string) ;
 PRINT-ATTR INPUT (DEBUG): TokenStream [
     Punct {
         ch: '#',
         spacing: Alone,
-        span: $DIR/attr-stmt-expr.rs:47:5: 47:6 (#0),
+        span: $DIR/attr-stmt-expr.rs:52:5: 52:6 (#0),
     },
     Group {
         delimiter: Bracket,
         stream: TokenStream [
             Ident {
-                ident: "expect_print_stmt",
-                span: $DIR/attr-stmt-expr.rs:47:7: 47:24 (#0),
+                ident: "expect_my_macro_stmt",
+                span: $DIR/attr-stmt-expr.rs:52:7: 52:27 (#0),
             },
         ],
-        span: $DIR/attr-stmt-expr.rs:47:6: 47:25 (#0),
+        span: $DIR/attr-stmt-expr.rs:52:6: 52:28 (#0),
     },
     Ident {
-        ident: "println",
-        span: $DIR/attr-stmt-expr.rs:48:5: 48:12 (#0),
+        ident: "my_macro",
+        span: $DIR/attr-stmt-expr.rs:53:5: 53:13 (#0),
     },
     Punct {
         ch: '!',
         spacing: Alone,
-        span: $DIR/attr-stmt-expr.rs:48:12: 48:13 (#0),
+        span: $DIR/attr-stmt-expr.rs:53:13: 53:14 (#0),
     },
     Group {
         delimiter: Parenthesis,
@@ -104,36 +104,36 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
                 kind: Str,
                 symbol: "{}",
                 suffix: None,
-                span: $DIR/attr-stmt-expr.rs:48:14: 48:18 (#0),
+                span: $DIR/attr-stmt-expr.rs:53:15: 53:19 (#0),
             },
             Punct {
                 ch: ',',
                 spacing: Alone,
-                span: $DIR/attr-stmt-expr.rs:48:18: 48:19 (#0),
+                span: $DIR/attr-stmt-expr.rs:53:19: 53:20 (#0),
             },
             Ident {
                 ident: "string",
-                span: $DIR/attr-stmt-expr.rs:48:20: 48:26 (#0),
+                span: $DIR/attr-stmt-expr.rs:53:21: 53:27 (#0),
             },
         ],
-        span: $DIR/attr-stmt-expr.rs:48:13: 48:27 (#0),
+        span: $DIR/attr-stmt-expr.rs:53:14: 53:28 (#0),
     },
     Punct {
         ch: ';',
         spacing: Alone,
-        span: $DIR/attr-stmt-expr.rs:48:27: 48:28 (#0),
+        span: $DIR/attr-stmt-expr.rs:53:28: 53:29 (#0),
     },
 ]
 PRINT-ATTR INPUT (DISPLAY): second_make_stmt ! (#[allow(dead_code)] struct Bar { }) ;
 PRINT-ATTR INPUT (DEBUG): TokenStream [
     Ident {
         ident: "second_make_stmt",
-        span: $DIR/attr-stmt-expr.rs:51:5: 51:21 (#0),
+        span: $DIR/attr-stmt-expr.rs:56:5: 56:21 (#0),
     },
     Punct {
         ch: '!',
         spacing: Alone,
-        span: $DIR/attr-stmt-expr.rs:51:21: 51:22 (#0),
+        span: $DIR/attr-stmt-expr.rs:56:21: 56:22 (#0),
     },
     Group {
         delimiter: Parenthesis,
@@ -141,48 +141,48 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
             Punct {
                 ch: '#',
                 spacing: Alone,
-                span: $DIR/attr-stmt-expr.rs:51:23: 51:24 (#0),
+                span: $DIR/attr-stmt-expr.rs:56:23: 56:24 (#0),
             },
             Group {
                 delimiter: Bracket,
                 stream: TokenStream [
                     Ident {
                         ident: "allow",
-                        span: $DIR/attr-stmt-expr.rs:51:25: 51:30 (#0),
+                        span: $DIR/attr-stmt-expr.rs:56:25: 56:30 (#0),
                     },
                     Group {
                         delimiter: Parenthesis,
                         stream: TokenStream [
                             Ident {
                                 ident: "dead_code",
-                                span: $DIR/attr-stmt-expr.rs:51:31: 51:40 (#0),
+                                span: $DIR/attr-stmt-expr.rs:56:31: 56:40 (#0),
                             },
                         ],
-                        span: $DIR/attr-stmt-expr.rs:51:30: 51:41 (#0),
+                        span: $DIR/attr-stmt-expr.rs:56:30: 56:41 (#0),
                     },
                 ],
-                span: $DIR/attr-stmt-expr.rs:51:24: 51:42 (#0),
+                span: $DIR/attr-stmt-expr.rs:56:24: 56:42 (#0),
             },
             Ident {
                 ident: "struct",
-                span: $DIR/attr-stmt-expr.rs:51:43: 51:49 (#0),
+                span: $DIR/attr-stmt-expr.rs:56:43: 56:49 (#0),
             },
             Ident {
                 ident: "Bar",
-                span: $DIR/attr-stmt-expr.rs:51:50: 51:53 (#0),
+                span: $DIR/attr-stmt-expr.rs:56:50: 56:53 (#0),
             },
             Group {
                 delimiter: Brace,
                 stream: TokenStream [],
-                span: $DIR/attr-stmt-expr.rs:51:54: 51:56 (#0),
+                span: $DIR/attr-stmt-expr.rs:56:54: 56:56 (#0),
             },
         ],
-        span: $DIR/attr-stmt-expr.rs:51:22: 51:57 (#0),
+        span: $DIR/attr-stmt-expr.rs:56:22: 56:57 (#0),
     },
     Punct {
         ch: ';',
         spacing: Alone,
-        span: $DIR/attr-stmt-expr.rs:51:57: 51:58 (#0),
+        span: $DIR/attr-stmt-expr.rs:56:57: 56:58 (#0),
     },
 ]
 PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] #[allow(dead_code)] struct Bar { }
@@ -190,55 +190,55 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
     Punct {
         ch: '#',
         spacing: Alone,
-        span: $DIR/attr-stmt-expr.rs:28:9: 28:10 (#34),
+        span: $DIR/attr-stmt-expr.rs:33:9: 33:10 (#29),
     },
     Group {
         delimiter: Bracket,
         stream: TokenStream [
             Ident {
                 ident: "rustc_dummy",
-                span: $DIR/attr-stmt-expr.rs:28:11: 28:22 (#34),
+                span: $DIR/attr-stmt-expr.rs:33:11: 33:22 (#29),
             },
         ],
-        span: $DIR/attr-stmt-expr.rs:28:10: 28:23 (#34),
+        span: $DIR/attr-stmt-expr.rs:33:10: 33:23 (#29),
     },
     Punct {
         ch: '#',
         spacing: Alone,
-        span: $DIR/attr-stmt-expr.rs:51:23: 51:24 (#0),
+        span: $DIR/attr-stmt-expr.rs:56:23: 56:24 (#0),
     },
     Group {
         delimiter: Bracket,
         stream: TokenStream [
             Ident {
                 ident: "allow",
-                span: $DIR/attr-stmt-expr.rs:51:25: 51:30 (#0),
+                span: $DIR/attr-stmt-expr.rs:56:25: 56:30 (#0),
             },
             Group {
                 delimiter: Parenthesis,
                 stream: TokenStream [
                     Ident {
                         ident: "dead_code",
-                        span: $DIR/attr-stmt-expr.rs:51:31: 51:40 (#0),
+                        span: $DIR/attr-stmt-expr.rs:56:31: 56:40 (#0),
                     },
                 ],
-                span: $DIR/attr-stmt-expr.rs:51:30: 51:41 (#0),
+                span: $DIR/attr-stmt-expr.rs:56:30: 56:41 (#0),
             },
         ],
-        span: $DIR/attr-stmt-expr.rs:51:24: 51:42 (#0),
+        span: $DIR/attr-stmt-expr.rs:56:24: 56:42 (#0),
     },
     Ident {
         ident: "struct",
-        span: $DIR/attr-stmt-expr.rs:51:43: 51:49 (#0),
+        span: $DIR/attr-stmt-expr.rs:56:43: 56:49 (#0),
     },
     Ident {
         ident: "Bar",
-        span: $DIR/attr-stmt-expr.rs:51:50: 51:53 (#0),
+        span: $DIR/attr-stmt-expr.rs:56:50: 56:53 (#0),
     },
     Group {
         delimiter: Brace,
         stream: TokenStream [],
-        span: $DIR/attr-stmt-expr.rs:51:54: 51:56 (#0),
+        span: $DIR/attr-stmt-expr.rs:56:54: 56:56 (#0),
     },
 ]
 PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] struct Other { }
@@ -246,29 +246,29 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
     Punct {
         ch: '#',
         spacing: Alone,
-        span: $DIR/attr-stmt-expr.rs:54:5: 54:6 (#0),
+        span: $DIR/attr-stmt-expr.rs:59:5: 59:6 (#0),
     },
     Group {
         delimiter: Bracket,
         stream: TokenStream [
             Ident {
                 ident: "rustc_dummy",
-                span: $DIR/attr-stmt-expr.rs:54:7: 54:18 (#0),
+                span: $DIR/attr-stmt-expr.rs:59:7: 59:18 (#0),
             },
         ],
-        span: $DIR/attr-stmt-expr.rs:54:6: 54:19 (#0),
+        span: $DIR/attr-stmt-expr.rs:59:6: 59:19 (#0),
     },
     Ident {
         ident: "struct",
-        span: $DIR/attr-stmt-expr.rs:55:5: 55:11 (#0),
+        span: $DIR/attr-stmt-expr.rs:60:5: 60:11 (#0),
     },
     Ident {
         ident: "Other",
-        span: $DIR/attr-stmt-expr.rs:55:12: 55:17 (#0),
+        span: $DIR/attr-stmt-expr.rs:60:12: 60:17 (#0),
     },
     Group {
         delimiter: Brace,
         stream: TokenStream [],
-        span: $DIR/attr-stmt-expr.rs:55:18: 55:20 (#0),
+        span: $DIR/attr-stmt-expr.rs:60:18: 60:20 (#0),
     },
 ]
diff --git a/src/test/ui/proc-macro/auxiliary/attr-stmt-expr.rs b/src/test/ui/proc-macro/auxiliary/attr-stmt-expr.rs
index 213f999e9d0..19183c61651 100644
--- a/src/test/ui/proc-macro/auxiliary/attr-stmt-expr.rs
+++ b/src/test/ui/proc-macro/auxiliary/attr-stmt-expr.rs
@@ -15,9 +15,9 @@ pub fn expect_let(attr: TokenStream, item: TokenStream) -> TokenStream {
 }
 
 #[proc_macro_attribute]
-pub fn expect_print_stmt(attr: TokenStream, item: TokenStream) -> TokenStream {
+pub fn expect_my_macro_stmt(attr: TokenStream, item: TokenStream) -> TokenStream {
     assert!(attr.to_string().is_empty());
-    assert_eq!(item.to_string(), "println ! (\"{}\", string) ;");
+    assert_eq!(item.to_string(), "my_macro ! (\"{}\", string) ;");
     item
 }
 
@@ -29,9 +29,9 @@ pub fn expect_expr(attr: TokenStream, item: TokenStream) -> TokenStream {
 }
 
 #[proc_macro_attribute]
-pub fn expect_print_expr(attr: TokenStream, item: TokenStream) -> TokenStream {
+pub fn expect_my_macro_expr(attr: TokenStream, item: TokenStream) -> TokenStream {
     assert!(attr.to_string().is_empty());
-    assert_eq!(item.to_string(), "println ! (\"{}\", string)");
+    assert_eq!(item.to_string(), "my_macro ! (\"{}\", string)");
     item
 }