@@ -497,3 +497,53 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcNonConstTraitMethodParser {
497497 ] ) ;
498498 const CREATE : fn ( Span ) -> AttributeKind = |_| AttributeKind :: RustcNonConstTraitMethod ;
499499}
500+
501+ pub ( crate ) struct RustcSymbolName ;
502+
503+ impl < S : Stage > SingleAttributeParser < S > for RustcSymbolName {
504+ const ALLOWED_TARGETS : AllowedTargets = AllowedTargets :: AllowList ( & [
505+ Allow ( Target :: Fn ) ,
506+ Allow ( Target :: Method ( MethodKind :: TraitImpl ) ) ,
507+ Allow ( Target :: Method ( MethodKind :: Inherent ) ) ,
508+ Allow ( Target :: Method ( MethodKind :: Trait { body : true } ) ) ,
509+ Allow ( Target :: ForeignFn ) ,
510+ Allow ( Target :: ForeignStatic ) ,
511+ Allow ( Target :: Impl { of_trait : false } ) ,
512+ ] ) ;
513+ const ON_DUPLICATE : OnDuplicate < S > = OnDuplicate :: Error ;
514+ const PATH : & [ Symbol ] = & [ sym:: rustc_symbol_name] ;
515+ const ATTRIBUTE_ORDER : AttributeOrder = AttributeOrder :: KeepInnermost ;
516+ const TEMPLATE : AttributeTemplate = template ! ( Word ) ;
517+ fn convert ( cx : & mut AcceptContext < ' _ , ' _ , S > , args : & ArgParser ) -> Option < AttributeKind > {
518+ if let Err ( span) = args. no_args ( ) {
519+ cx. expected_no_args ( span) ;
520+ return None ;
521+ }
522+ Some ( AttributeKind :: RustcSymbolName ( cx. attr_span ) )
523+ }
524+ }
525+
526+ pub ( crate ) struct RustcDefPath ;
527+
528+ impl < S : Stage > SingleAttributeParser < S > for RustcDefPath {
529+ const ALLOWED_TARGETS : AllowedTargets = AllowedTargets :: AllowList ( & [
530+ Allow ( Target :: Fn ) ,
531+ Allow ( Target :: Method ( MethodKind :: TraitImpl ) ) ,
532+ Allow ( Target :: Method ( MethodKind :: Inherent ) ) ,
533+ Allow ( Target :: Method ( MethodKind :: Trait { body : true } ) ) ,
534+ Allow ( Target :: ForeignFn ) ,
535+ Allow ( Target :: ForeignStatic ) ,
536+ Allow ( Target :: Impl { of_trait : false } ) ,
537+ ] ) ;
538+ const ON_DUPLICATE : OnDuplicate < S > = OnDuplicate :: Error ;
539+ const PATH : & [ Symbol ] = & [ sym:: rustc_def_path] ;
540+ const ATTRIBUTE_ORDER : AttributeOrder = AttributeOrder :: KeepInnermost ;
541+ const TEMPLATE : AttributeTemplate = template ! ( Word ) ;
542+ fn convert ( cx : & mut AcceptContext < ' _ , ' _ , S > , args : & ArgParser ) -> Option < AttributeKind > {
543+ if let Err ( span) = args. no_args ( ) {
544+ cx. expected_no_args ( span) ;
545+ return None ;
546+ }
547+ Some ( AttributeKind :: RustcDefPath ( cx. attr_span ) )
548+ }
549+ }
0 commit comments