Skip to content

Commit bbe9d27

Browse files
committedApr 5, 2022
Auto merge of rust-lang#95702 - Dylan-DPC:rollup-793rz6v, r=Dylan-DPC
Rollup of 8 pull requests Successful merges: - rust-lang#88025 (ScmCredentials netbsd implementation.) - rust-lang#95473 (track individual proc-macro expansions in the self-profiler) - rust-lang#95547 (caution against ptr-to-int transmutes) - rust-lang#95585 (Explain why `&T` is cloned when `T` is not `Clone`) - rust-lang#95591 (Use revisions to track NLL test output (part 1)) - rust-lang#95663 (diagnostics: give a special note for unsafe fn / Fn/FnOnce/FnMut) - rust-lang#95673 (:arrow_up: rust-analyzer) - rust-lang#95681 (resolve: Fix resolution of empty paths passed from rustdoc) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 306ba83 + 728f263 commit bbe9d27

File tree

132 files changed

+877
-369
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+877
-369
lines changed
 

‎compiler/rustc_expand/src/base.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,12 @@ impl<'a> ExtCtxt<'a> {
10471047
self.current_expansion.id.expn_data().call_site
10481048
}
10491049

1050+
/// Returns the current expansion kind's description.
1051+
pub(crate) fn expansion_descr(&self) -> String {
1052+
let expn_data = self.current_expansion.id.expn_data();
1053+
expn_data.kind.descr()
1054+
}
1055+
10501056
/// Equivalent of `Span::def_site` from the proc macro API,
10511057
/// except that the location is taken from the span passed as an argument.
10521058
pub fn with_def_site_ctxt(&self, span: Span) -> Span {

‎compiler/rustc_expand/src/proc_macro.rs

+18-10
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ impl base::ProcMacro for BangProcMacro {
2424
span: Span,
2525
input: TokenStream,
2626
) -> Result<TokenStream, ErrorGuaranteed> {
27+
let _timer =
28+
ecx.sess.prof.generic_activity_with_arg("expand_proc_macro", ecx.expansion_descr());
2729
let proc_macro_backtrace = ecx.ecfg.proc_macro_backtrace;
2830
let server = proc_macro_server::Rustc::new(ecx);
2931
self.client.run(&EXEC_STRATEGY, server, input, proc_macro_backtrace).map_err(|e| {
@@ -48,6 +50,8 @@ impl base::AttrProcMacro for AttrProcMacro {
4850
annotation: TokenStream,
4951
annotated: TokenStream,
5052
) -> Result<TokenStream, ErrorGuaranteed> {
53+
let _timer =
54+
ecx.sess.prof.generic_activity_with_arg("expand_proc_macro", ecx.expansion_descr());
5155
let proc_macro_backtrace = ecx.ecfg.proc_macro_backtrace;
5256
let server = proc_macro_server::Rustc::new(ecx);
5357
self.client
@@ -97,17 +101,21 @@ impl MultiItemModifier for ProcMacroDerive {
97101
nt_to_tokenstream(&item, &ecx.sess.parse_sess, CanSynthesizeMissingTokens::No)
98102
};
99103

100-
let proc_macro_backtrace = ecx.ecfg.proc_macro_backtrace;
101-
let server = proc_macro_server::Rustc::new(ecx);
102-
let stream = match self.client.run(&EXEC_STRATEGY, server, input, proc_macro_backtrace) {
103-
Ok(stream) => stream,
104-
Err(e) => {
105-
let mut err = ecx.struct_span_err(span, "proc-macro derive panicked");
106-
if let Some(s) = e.as_str() {
107-
err.help(&format!("message: {}", s));
104+
let stream = {
105+
let _timer =
106+
ecx.sess.prof.generic_activity_with_arg("expand_proc_macro", ecx.expansion_descr());
107+
let proc_macro_backtrace = ecx.ecfg.proc_macro_backtrace;
108+
let server = proc_macro_server::Rustc::new(ecx);
109+
match self.client.run(&EXEC_STRATEGY, server, input, proc_macro_backtrace) {
110+
Ok(stream) => stream,
111+
Err(e) => {
112+
let mut err = ecx.struct_span_err(span, "proc-macro derive panicked");
113+
if let Some(s) = e.as_str() {
114+
err.help(&format!("message: {}", s));
115+
}
116+
err.emit();
117+
return ExpandResult::Ready(vec![]);
108118
}
109-
err.emit();
110-
return ExpandResult::Ready(vec![]);
111119
}
112120
};
113121

0 commit comments

Comments
 (0)