Skip to content

Commit a8648c8

Browse files
Rollup merge of rust-lang#87027 - petrochenkov:builderhelp, r=oli-obk
expand: Support helper attributes for built-in derive macros This is needed for rust-lang#86735 (derive macro `Default` should have a helper attribute `default`). With this PR we can specify helper attributes for built-in derives using syntax `#[rustc_builtin_macro(MacroName, attributes(attr1, attr2, ...))]` which mirrors equivalent syntax for proc macros `#[proc_macro_derive(MacroName, attributes(attr1, attr2, ...))]`. Otherwise expansion infra was already ready for this. The attribute parsing code is shared between proc macro derives and built-in macros (`fn parse_macro_name_and_helper_attrs`).
2 parents 4d9b37c + 5164db7 commit a8648c8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

core/src/macros/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#[doc = include_str!("panic.md")]
22
#[macro_export]
3-
#[rustc_builtin_macro = "core_panic"]
3+
#[cfg_attr(bootstrap, rustc_builtin_macro = "core_panic")]
4+
#[cfg_attr(not(bootstrap), rustc_builtin_macro(core_panic))]
45
#[allow_internal_unstable(edition_panic)]
56
#[stable(feature = "core", since = "1.6.0")]
67
#[rustc_diagnostic_item = "core_panic_macro"]

std/src/macros.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
77
#[doc = include_str!("../../core/src/macros/panic.md")]
88
#[macro_export]
9-
#[rustc_builtin_macro = "std_panic"]
9+
#[cfg_attr(bootstrap, rustc_builtin_macro = "std_panic")]
10+
#[cfg_attr(not(bootstrap), rustc_builtin_macro(std_panic))]
1011
#[stable(feature = "rust1", since = "1.0.0")]
1112
#[allow_internal_unstable(edition_panic)]
1213
#[cfg_attr(not(test), rustc_diagnostic_item = "std_panic_macro")]

0 commit comments

Comments
 (0)