Skip to content

Commit 164e221

Browse files
committed
Mark proc_macro_decls_static as always used
This would have avoided a bug in #104860. In practice this shouldn't matter since nothing uses the query other than the `dead_code` lint, but this isn't documented as an internal-only query so it seems nice for it to be accurate. I think for `dead_code` it doesn't matter because the relevant code is generated by `rustc_builtin_macros` and isn't linted.
1 parent 2d76a9d commit 164e221

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

compiler/rustc_builtin_macros/src/proc_macro_harness.rs

+2
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
262262
// use proc_macro::bridge::client::ProcMacro;
263263
//
264264
// #[rustc_proc_macro_decls]
265+
// #[used]
265266
// #[allow(deprecated)]
266267
// static DECLS: &[ProcMacro] = &[
267268
// ProcMacro::custom_derive($name_trait1, &[], ::$name1);
@@ -364,6 +365,7 @@ fn mk_decls(cx: &mut ExtCtxt<'_>, macros: &[ProcMacro]) -> P<ast::Item> {
364365
)
365366
.map(|mut i| {
366367
i.attrs.push(cx.attr_word(sym::rustc_proc_macro_decls, span));
368+
i.attrs.push(cx.attr_word(sym::used, span));
367369
i.attrs.push(cx.attr_nested_word(sym::allow, sym::deprecated, span));
368370
i
369371
});

src/test/ui/proc-macro/quote-debug.stdout

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const _: () =
4242
{
4343
extern crate proc_macro;
4444
#[rustc_proc_macro_decls]
45+
#[used]
4546
#[allow(deprecated)]
4647
static _DECLS: &[proc_macro::bridge::client::ProcMacro] = &[];
4748
};

0 commit comments

Comments
 (0)