Do not suggest using -Zmacro-backtrace
for builtin macros
For macros that are implemented on the compiler, we do *not* mention the `-Zmacro-backtrace` flag. This includes `derive`s and standard macros.
This commit is contained in:
parent
f7b4354283
commit
f0b8e13b59
205 changed files with 27 additions and 495 deletions
|
@ -297,7 +297,9 @@ pub trait Emitter: Translate {
|
|||
// are some which do actually involve macros.
|
||||
ExpnKind::Desugaring(..) | ExpnKind::AstPass(..) => None,
|
||||
|
||||
ExpnKind::Macro(macro_kind, name) => Some((macro_kind, name)),
|
||||
ExpnKind::Macro(macro_kind, name) => {
|
||||
Some((macro_kind, name, expn_data.hide_backtrace))
|
||||
}
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
@ -309,13 +311,17 @@ pub trait Emitter: Translate {
|
|||
self.render_multispans_macro_backtrace(span, children, backtrace);
|
||||
|
||||
if !backtrace {
|
||||
if let Some((macro_kind, name)) = has_macro_spans.first() {
|
||||
// Skip builtin macros, as their expansion isn't relevant to the end user. This includes
|
||||
// actual intrinsics, like `asm!`.
|
||||
if let Some((macro_kind, name, _)) = has_macro_spans.first()
|
||||
&& let Some((_, _, false)) = has_macro_spans.last()
|
||||
{
|
||||
// Mark the actual macro this originates from
|
||||
let and_then = if let Some((macro_kind, last_name)) = has_macro_spans.last()
|
||||
let and_then = if let Some((macro_kind, last_name, _)) = has_macro_spans.last()
|
||||
&& last_name != name
|
||||
{
|
||||
let descr = macro_kind.descr();
|
||||
format!(" which comes from the expansion of the {descr} `{last_name}`",)
|
||||
format!(" which comes from the expansion of the {descr} `{last_name}`")
|
||||
} else {
|
||||
"".to_string()
|
||||
};
|
||||
|
|
|
@ -889,16 +889,16 @@ impl SyntaxExtension {
|
|||
})
|
||||
.unwrap_or_else(|| (None, helper_attrs));
|
||||
|
||||
let stability = find_attr!(attrs, AttributeKind::Stability{stability, ..} => *stability);
|
||||
let stability = find_attr!(attrs, AttributeKind::Stability { stability, .. } => *stability);
|
||||
|
||||
// FIXME(jdonszelmann): make it impossible to miss the or_else in the typesystem
|
||||
if let Some(sp) = find_attr!(attrs, AttributeKind::ConstStability{span, ..} => *span) {
|
||||
if let Some(sp) = find_attr!(attrs, AttributeKind::ConstStability { span, .. } => *span) {
|
||||
sess.dcx().emit_err(errors::MacroConstStability {
|
||||
span: sp,
|
||||
head_span: sess.source_map().guess_head_span(span),
|
||||
});
|
||||
}
|
||||
if let Some(sp) = find_attr!(attrs, AttributeKind::BodyStability{span, ..} => *span) {
|
||||
if let Some(sp) = find_attr!(attrs, AttributeKind::BodyStability{ span, .. } => *span) {
|
||||
sess.dcx().emit_err(errors::MacroBodyStability {
|
||||
span: sp,
|
||||
head_span: sess.source_map().guess_head_span(span),
|
||||
|
@ -912,7 +912,10 @@ impl SyntaxExtension {
|
|||
// FIXME(jdonszelmann): avoid the into_iter/collect?
|
||||
.then(|| allow_internal_unstable.iter().map(|i| i.0).collect::<Vec<_>>().into()),
|
||||
stability,
|
||||
deprecation: find_attr!(attrs, AttributeKind::Deprecation{deprecation, ..} => *deprecation),
|
||||
deprecation: find_attr!(
|
||||
attrs,
|
||||
AttributeKind::Deprecation { deprecation, .. } => *deprecation
|
||||
),
|
||||
helper_attrs,
|
||||
edition,
|
||||
builtin_name,
|
||||
|
@ -1000,6 +1003,7 @@ impl SyntaxExtension {
|
|||
self.allow_internal_unsafe,
|
||||
self.local_inner_macros,
|
||||
self.collapse_debuginfo,
|
||||
self.builtin_name.is_some(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -982,6 +982,8 @@ pub struct ExpnData {
|
|||
/// Should debuginfo for the macro be collapsed to the outermost expansion site (in other
|
||||
/// words, was the macro definition annotated with `#[collapse_debuginfo]`)?
|
||||
pub(crate) collapse_debuginfo: bool,
|
||||
/// When true, we do not display the note telling people to use the `-Zmacro-backtrace` flag.
|
||||
pub hide_backtrace: bool,
|
||||
}
|
||||
|
||||
impl !PartialEq for ExpnData {}
|
||||
|
@ -1000,6 +1002,7 @@ impl ExpnData {
|
|||
allow_internal_unsafe: bool,
|
||||
local_inner_macros: bool,
|
||||
collapse_debuginfo: bool,
|
||||
hide_backtrace: bool,
|
||||
) -> ExpnData {
|
||||
ExpnData {
|
||||
kind,
|
||||
|
@ -1014,6 +1017,7 @@ impl ExpnData {
|
|||
allow_internal_unsafe,
|
||||
local_inner_macros,
|
||||
collapse_debuginfo,
|
||||
hide_backtrace,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1038,6 +1042,7 @@ impl ExpnData {
|
|||
allow_internal_unsafe: false,
|
||||
local_inner_macros: false,
|
||||
collapse_debuginfo: false,
|
||||
hide_backtrace: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue