Skip to content

Commit c525396

Browse files
committed
start tracking proc-macros expansion spans in the self-profiler
1 parent 215b377 commit c525396

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

compiler/rustc_expand/src/proc_macro.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rustc_data_structures::sync::Lrc;
99
use rustc_errors::ErrorGuaranteed;
1010
use rustc_parse::nt_to_tokenstream;
1111
use rustc_parse::parser::ForceCollect;
12+
use rustc_span::profiling::SpannedEventArgRecorder;
1213
use rustc_span::{Span, DUMMY_SP};
1314

1415
const EXEC_STRATEGY: pm::bridge::server::SameThread = pm::bridge::server::SameThread;
@@ -25,7 +26,10 @@ impl base::ProcMacro for BangProcMacro {
2526
input: TokenStream,
2627
) -> Result<TokenStream, ErrorGuaranteed> {
2728
let _timer =
28-
ecx.sess.prof.generic_activity_with_arg("expand_proc_macro", ecx.expansion_descr());
29+
ecx.sess.prof.generic_activity_with_arg_recorder("expand_proc_macro", |recorder| {
30+
recorder.record_arg_with_span(ecx.expansion_descr(), span);
31+
});
32+
2933
let proc_macro_backtrace = ecx.ecfg.proc_macro_backtrace;
3034
let server = proc_macro_server::Rustc::new(ecx);
3135
self.client.run(&EXEC_STRATEGY, server, input, proc_macro_backtrace).map_err(|e| {
@@ -51,7 +55,10 @@ impl base::AttrProcMacro for AttrProcMacro {
5155
annotated: TokenStream,
5256
) -> Result<TokenStream, ErrorGuaranteed> {
5357
let _timer =
54-
ecx.sess.prof.generic_activity_with_arg("expand_proc_macro", ecx.expansion_descr());
58+
ecx.sess.prof.generic_activity_with_arg_recorder("expand_proc_macro", |recorder| {
59+
recorder.record_arg_with_span(ecx.expansion_descr(), span);
60+
});
61+
5562
let proc_macro_backtrace = ecx.ecfg.proc_macro_backtrace;
5663
let server = proc_macro_server::Rustc::new(ecx);
5764
self.client
@@ -103,7 +110,9 @@ impl MultiItemModifier for ProcMacroDerive {
103110

104111
let stream = {
105112
let _timer =
106-
ecx.sess.prof.generic_activity_with_arg("expand_proc_macro", ecx.expansion_descr());
113+
ecx.sess.prof.generic_activity_with_arg_recorder("expand_proc_macro", |recorder| {
114+
recorder.record_arg_with_span(ecx.expansion_descr(), span);
115+
});
107116
let proc_macro_backtrace = ecx.ecfg.proc_macro_backtrace;
108117
let server = proc_macro_server::Rustc::new(ecx);
109118
match self.client.run(&EXEC_STRATEGY, server, input, proc_macro_backtrace) {

0 commit comments

Comments
 (0)