Skip to content

Commit 6a62f9b

Browse files
committed
refactor: Only call invoc_id.expn_data() once, inline some res
1 parent 9352678 commit 6a62f9b

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

compiler/rustc_expand/src/derive_macro_expansion.rs

+10-13
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ pub(super) fn provide_derive_macro_expansion<'tcx>(
1616
) -> Result<&'tcx TokenStream, ()> {
1717
let (invoc_id, _macro_crate_hash, input) = key;
1818

19-
let res = with_context(|(ecx, client)| {
20-
let span = invoc_id.expn_data().call_site;
19+
with_context(|(ecx, client)| {
20+
let invoc_expn_data = invoc_id.expn_data();
21+
let span = invoc_expn_data.call_site;
22+
let event_arg = invoc_expn_data.kind.descr();
2123
let _timer = tcx.sess.prof.generic_activity_with_arg_recorder(
2224
"expand_derive_proc_macro_inner",
2325
|recorder| {
24-
recorder.record_arg_with_span(
25-
tcx.sess.source_map(),
26-
invoc_id.expn_data().kind.descr(),
27-
span,
28-
);
26+
recorder.record_arg_with_span(tcx.sess.source_map(), event_arg.clone(), span);
2927
},
3028
);
29+
3130
let proc_macro_backtrace = ecx.ecfg.proc_macro_backtrace;
3231
let strategy = crate::proc_macro::exec_strategy(tcx.sess);
3332
let server = crate::proc_macro_server::Rustc::new(ecx);
34-
let res = match client.run(&strategy, server, input.clone(), proc_macro_backtrace) {
33+
34+
match client.run(&strategy, server, input.clone(), proc_macro_backtrace) {
3535
Ok(stream) => Ok(tcx.arena.alloc(stream) as &TokenStream),
3636
Err(e) => {
3737
tcx.dcx().emit_err({
@@ -44,11 +44,8 @@ pub(super) fn provide_derive_macro_expansion<'tcx>(
4444
});
4545
Err(())
4646
}
47-
};
48-
res
49-
});
50-
51-
res
47+
}
48+
})
5249
}
5350

5451
type CLIENT = pm::bridge::client::Client<pm::TokenStream, pm::TokenStream>;

0 commit comments

Comments
 (0)