diff options
| author | Ralf Jung <post@ralfj.de> | 2024-10-07 17:27:37 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-10-25 20:31:40 +0200 |
| commit | 3854e16fa2b2ee004ff2cbc71b28f9de28306942 (patch) | |
| tree | 9d48e29a969e3628f11a8949555641af2c87d526 /compiler/rustc_builtin_macros/src/proc_macro_harness.rs | |
| parent | a0215d8e46aab41219dea0bb1cbaaf97dafe2f89 (diff) | |
| download | rust-3854e16fa2b2ee004ff2cbc71b28f9de28306942.tar.gz rust-3854e16fa2b2ee004ff2cbc71b28f9de28306942.zip | |
proc_macro_harness: adjust the span we use for const fn calls
Diffstat (limited to 'compiler/rustc_builtin_macros/src/proc_macro_harness.rs')
| -rw-r--r-- | compiler/rustc_builtin_macros/src/proc_macro_harness.rs | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/compiler/rustc_builtin_macros/src/proc_macro_harness.rs b/compiler/rustc_builtin_macros/src/proc_macro_harness.rs index d6603af101a..707c36d5046 100644 --- a/compiler/rustc_builtin_macros/src/proc_macro_harness.rs +++ b/compiler/rustc_builtin_macros/src/proc_macro_harness.rs @@ -313,14 +313,23 @@ fn mk_decls(cx: &mut ExtCtxt<'_>, macros: &[ProcMacro]) -> P<ast::Item> { match m { ProcMacro::Derive(cd) => { cx.resolver.declare_proc_macro(cd.id); - cx.expr_call(span, proc_macro_ty_method_path(cx, custom_derive), thin_vec![ - cx.expr_str(span, cd.trait_name), - cx.expr_array_ref( - span, - cd.attrs.iter().map(|&s| cx.expr_str(span, s)).collect::<ThinVec<_>>(), - ), - local_path(cx, cd.function_name), - ]) + // The call needs to use `harness_span` so that the const stability checker + // accepts it. + cx.expr_call( + harness_span, + proc_macro_ty_method_path(cx, custom_derive), + thin_vec![ + cx.expr_str(span, cd.trait_name), + cx.expr_array_ref( + span, + cd.attrs + .iter() + .map(|&s| cx.expr_str(span, s)) + .collect::<ThinVec<_>>(), + ), + local_path(cx, cd.function_name), + ], + ) } ProcMacro::Attr(ca) | ProcMacro::Bang(ca) => { cx.resolver.declare_proc_macro(ca.id); @@ -330,7 +339,9 @@ fn mk_decls(cx: &mut ExtCtxt<'_>, macros: &[ProcMacro]) -> P<ast::Item> { ProcMacro::Derive(_) => unreachable!(), }; - cx.expr_call(span, proc_macro_ty_method_path(cx, ident), thin_vec![ + // The call needs to use `harness_span` so that the const stability checker + // accepts it. + cx.expr_call(harness_span, proc_macro_ty_method_path(cx, ident), thin_vec![ cx.expr_str(span, ca.function_name.name), local_path(cx, ca.function_name), ]) |
