@@ -851,6 +851,7 @@ pub struct SyntaxExtension {
851851 /// Should debuginfo for the macro be collapsed to the outermost expansion site (in other
852852 /// words, was the macro definition annotated with `#[collapse_debuginfo]`)?
853853 pub collapse_debuginfo : bool ,
854+ pub hide_backtrace : bool ,
854855}
855856
856857impl SyntaxExtension {
@@ -884,6 +885,7 @@ impl SyntaxExtension {
884885 allow_internal_unsafe : false ,
885886 local_inner_macros : false ,
886887 collapse_debuginfo : false ,
888+ hide_backtrace : false ,
887889 }
888890 }
889891
@@ -939,6 +941,12 @@ impl SyntaxExtension {
939941 collapse_table[ flag as usize ] [ attr as usize ]
940942 }
941943
944+ fn get_hide_backtrace ( attrs : & [ hir:: Attribute ] ) -> bool {
945+ // FIXME(estebank): instead of reusing `#[rustc_diagnostic_item]` as a proxy, introduce a
946+ // new attribute purely for this under the `#[diagnostic]` namespace.
947+ ast:: attr:: find_by_name ( attrs, sym:: rustc_diagnostic_item) . is_some ( )
948+ }
949+
942950 /// Constructs a syntax extension with the given properties
943951 /// and other properties converted from attributes.
944952 pub fn new (
@@ -975,6 +983,7 @@ impl SyntaxExtension {
975983 // Not a built-in macro
976984 None => ( None , helper_attrs) ,
977985 } ;
986+ let hide_backtrace = builtin_name. is_some ( ) || Self :: get_hide_backtrace ( attrs) ;
978987
979988 let stability = find_attr ! ( attrs, AttributeKind :: Stability { stability, .. } => * stability) ;
980989
@@ -1009,6 +1018,7 @@ impl SyntaxExtension {
10091018 allow_internal_unsafe,
10101019 local_inner_macros,
10111020 collapse_debuginfo,
1021+ hide_backtrace,
10121022 }
10131023 }
10141024
@@ -1088,7 +1098,7 @@ impl SyntaxExtension {
10881098 self . allow_internal_unsafe ,
10891099 self . local_inner_macros ,
10901100 self . collapse_debuginfo ,
1091- self . builtin_name . is_some ( ) ,
1101+ self . hide_backtrace ,
10921102 )
10931103 }
10941104}
0 commit comments