@@ -377,17 +377,28 @@ pub enum AttributeGate {
377377 Ungated ,
378378}
379379
380- #[ derive( Copy , Clone , PartialEq , Eq ) ]
380+ impl AttributeGate {
381+ fn is_deprecated ( & self ) -> bool {
382+ match * self {
383+ Gated ( Stability :: Deprecated ( _) , ..) => true ,
384+ _ => false ,
385+ }
386+ }
387+ }
388+
389+ #[ derive( Copy , Clone , PartialEq , Eq , Debug ) ]
381390pub enum Stability {
382391 Unstable ,
383- Deprecated ,
392+ // Argument is tracking issue link.
393+ Deprecated ( & ' static str ) ,
384394}
385395
386396// fn() is not Debug
387397impl :: std:: fmt:: Debug for AttributeGate {
388398 fn fmt ( & self , fmt : & mut :: std:: fmt:: Formatter ) -> :: std:: fmt:: Result {
389399 match * self {
390- Gated ( _, ref name, ref expl, _) => write ! ( fmt, "Gated({}, {})" , name, expl) ,
400+ Gated ( ref stab, ref name, ref expl, _) =>
401+ write ! ( fmt, "Gated({:?}, {}, {})" , stab, name, expl) ,
391402 Ungated => write ! ( fmt, "Ungated" )
392403 }
393404 }
@@ -402,6 +413,21 @@ macro_rules! cfg_fn {
402413 } }
403414}
404415
416+ pub fn with_deprecated_attributes < F , T > ( f : F ) -> T
417+ where F : FnOnce ( & [ & ' static ( & ' static str , AttributeType , AttributeGate ) ] ) -> T
418+ {
419+ static mut DEPR_ATTRS : Option < Vec < & ' static ( & ' static str , AttributeType , AttributeGate ) > >
420+ = None ;
421+
422+ unsafe {
423+ if DEPR_ATTRS . is_none ( ) {
424+ DEPR_ATTRS = Some ( KNOWN_ATTRIBUTES . iter ( ) . filter ( |a| a. 2 . is_deprecated ( ) ) . collect ( ) ) ;
425+ }
426+
427+ f ( DEPR_ATTRS . as_ref ( ) . unwrap ( ) )
428+ }
429+ }
430+
405431// Attributes that have a special meaning to rustc or rustdoc
406432pub const KNOWN_ATTRIBUTES : & ' static [ ( & ' static str , AttributeType , AttributeGate ) ] = & [
407433 // Normal attributes
@@ -643,11 +669,11 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeGat
643669 ( "link_section" , Whitelisted , Ungated ) ,
644670 ( "no_builtins" , Whitelisted , Ungated ) ,
645671 ( "no_mangle" , Whitelisted , Ungated ) ,
646- ( "no_debug" , Whitelisted , Gated ( Stability :: Deprecated ,
647- "no_debug" ,
648- "the `#[ no_debug]` attribute \
649- is an experimental feature",
650- cfg_fn ! ( no_debug) ) ) ,
672+ ( "no_debug" , Whitelisted , Gated (
673+ Stability :: Deprecated ( "https://github.com/rust-lang/rust/issues/29721" ) ,
674+ " no_debug" ,
675+ "the `#[no_debug]` attribute is an experimental feature",
676+ cfg_fn ! ( no_debug) ) ) ,
651677 ( "omit_gdb_pretty_printer_section" , Whitelisted , Gated ( Stability :: Unstable ,
652678 "omit_gdb_pretty_printer_section" ,
653679 "the `#[omit_gdb_pretty_printer_section]` \
0 commit comments