about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-03-19 16:52:58 +0100
committerGitHub <noreply@github.com>2025-03-19 16:52:58 +0100
commit966021d00a191191296814df2acd7becc7d59ad8 (patch)
tree5a5f483f24979ad5512550d6cc2368e15283879a /tests
parent9ab2a0e353f44eaa1df4246006dbc693f8e24899 (diff)
parent6c865c1e14d5bd76b4ffe1e7ed2e60b3261d03a9 (diff)
downloadrust-966021d00a191191296814df2acd7becc7d59ad8.tar.gz
rust-966021d00a191191296814df2acd7becc7d59ad8.zip
Rollup merge of #138613 - m-ou-se:no-more-e0773, r=jdonszelmann,petrochenkov
Remove E0773 "A builtin-macro was defined more than once."

Error E0773 "A builtin-macro was defined more than once" is triggered when using the same `#[rustc_builtin_macro(..)]` twice. However, it can only be triggered in unstable code (using a `rustc_` attribute), and there doesn't seem to be any harm in using the same implementation from `compiler/rustc_builtin_macros/…` for multiple macro definitions.

By changing the Box to an Arc in `SyntaxExtensionKind`, we can throw away the `BuiltinMacroState::{NotYetSeen, AlreadySeen}` logic, simplifying things.
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/macros/duplicate-builtin.rs17
-rw-r--r--tests/ui/macros/duplicate-builtin.stderr21
-rw-r--r--tests/ui/macros/unknown-builtin.rs5
-rw-r--r--tests/ui/macros/unknown-builtin.stderr14
4 files changed, 4 insertions, 53 deletions
diff --git a/tests/ui/macros/duplicate-builtin.rs b/tests/ui/macros/duplicate-builtin.rs
deleted file mode 100644
index c75782128f4..00000000000
--- a/tests/ui/macros/duplicate-builtin.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-//@ compile-flags:--crate-type lib
-#![feature(decl_macro)]
-#![feature(rustc_attrs)]
-
-#[rustc_builtin_macro]
-pub macro test($item:item) {
-//~^ NOTE previously defined
-    /* compiler built-in */
-}
-
-mod inner {
-    #[rustc_builtin_macro]
-    pub macro test($item:item) {
-    //~^ ERROR attempted to define built-in macro more than once [E0773]
-        /* compiler built-in */
-    }
-}
diff --git a/tests/ui/macros/duplicate-builtin.stderr b/tests/ui/macros/duplicate-builtin.stderr
deleted file mode 100644
index 887a4fbbdc8..00000000000
--- a/tests/ui/macros/duplicate-builtin.stderr
+++ /dev/null
@@ -1,21 +0,0 @@
-error[E0773]: attempted to define built-in macro more than once
-  --> $DIR/duplicate-builtin.rs:13:5
-   |
-LL | /     pub macro test($item:item) {
-LL | |
-LL | |         /* compiler built-in */
-LL | |     }
-   | |_____^
-   |
-note: previously defined here
-  --> $DIR/duplicate-builtin.rs:6:1
-   |
-LL | / pub macro test($item:item) {
-LL | |
-LL | |     /* compiler built-in */
-LL | | }
-   | |_^
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0773`.
diff --git a/tests/ui/macros/unknown-builtin.rs b/tests/ui/macros/unknown-builtin.rs
index 048f5d68d34..aa6e04d3fb8 100644
--- a/tests/ui/macros/unknown-builtin.rs
+++ b/tests/ui/macros/unknown-builtin.rs
@@ -1,12 +1,11 @@
-//@ error-pattern: attempted to define built-in macro more than once
-
 #![feature(rustc_attrs)]
 
 #[rustc_builtin_macro]
 macro_rules! unknown { () => () } //~ ERROR cannot find a built-in macro with name `unknown`
 
+// Defining another `line` builtin macro should not cause an error.
 #[rustc_builtin_macro]
-macro_rules! line { () => () } //~ NOTE previously defined here
+macro_rules! line { () => () }
 
 fn main() {
     line!();
diff --git a/tests/ui/macros/unknown-builtin.stderr b/tests/ui/macros/unknown-builtin.stderr
index 22f54e04e54..1a83398891b 100644
--- a/tests/ui/macros/unknown-builtin.stderr
+++ b/tests/ui/macros/unknown-builtin.stderr
@@ -1,18 +1,8 @@
 error: cannot find a built-in macro with name `unknown`
-  --> $DIR/unknown-builtin.rs:6:1
+  --> $DIR/unknown-builtin.rs:4:1
    |
 LL | macro_rules! unknown { () => () }
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-error[E0773]: attempted to define built-in macro more than once
-  --> $SRC_DIR/core/src/macros/mod.rs:LL:COL
-   |
-note: previously defined here
-  --> $DIR/unknown-builtin.rs:9:1
-   |
-LL | macro_rules! line { () => () }
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to 2 previous errors
+error: aborting due to 1 previous error
 
-For more information about this error, try `rustc --explain E0773`.