@@ -36,7 +36,6 @@ use visit;
36
36
use visit:: Visitor ;
37
37
use parse:: token:: { self , InternedString } ;
38
38
39
- use std:: slice;
40
39
use std:: ascii:: AsciiExt ;
41
40
42
41
// If you change this list without updating src/doc/reference.md, @cmr will be sad
@@ -574,42 +573,32 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
574
573
}
575
574
576
575
fn visit_attribute ( & mut self , attr : & ast:: Attribute ) {
577
- if attr. check_name ( "staged_api" ) {
578
- self . gate_feature ( "staged_api" , attr. span ,
579
- "staged_api is for use by rustc only" ) ;
580
- } else if attr. check_name ( "plugin" ) {
581
- self . gate_feature ( "plugin" , attr. span ,
582
- "compiler plugins are experimental \
583
- and possibly buggy") ;
584
- }
585
-
586
- if attr:: contains_name ( slice:: ref_slice ( attr) , "lang" ) {
587
- self . gate_feature ( "lang_items" ,
588
- attr. span ,
589
- "language items are subject to change" ) ;
590
- }
591
-
592
- if attr. check_name ( "no_std" ) {
593
- self . gate_feature ( "no_std" , attr. span ,
594
- "no_std is experimental" ) ;
595
- }
596
-
597
- if attr. check_name ( "unsafe_no_drop_flag" ) {
598
- self . gate_feature ( "unsafe_no_drop_flag" , attr. span ,
599
- "unsafe_no_drop_flag has unstable semantics \
600
- and may be removed in the future") ;
601
- }
602
-
603
- // Custom attribute check
604
- let name = attr. name ( ) ;
605
-
606
- if KNOWN_ATTRIBUTES . iter ( ) . all ( |& ( n, _) | n != name) {
607
- self . gate_feature ( "custom_attribute" , attr. span ,
608
- format ! ( "The attribute `{}` is currently \
609
- unknown to the the compiler and \
610
- may have meaning \
611
- added to it in the future",
612
- attr. name( ) ) . as_slice ( ) ) ;
576
+ match & * attr. name ( ) {
577
+ "staged_api" => self . gate_feature ( "staged_api" , attr. span ,
578
+ "staged_api is for use by rustc only" ) ,
579
+ "plugin" => self . gate_feature ( "plugin" , attr. span ,
580
+ "compiler plugins are experimental \
581
+ and possibly buggy") ,
582
+ "no_std" => self . gate_feature ( "no_std" , attr. span ,
583
+ "no_std is experimental" ) ,
584
+ "unsafe_no_drop_flag" => self . gate_feature ( "unsafe_no_drop_flag" , attr. span ,
585
+ "unsafe_no_drop_flag has unstable \
586
+ semantics and may be removed \
587
+ in the future") ,
588
+ "lang" => self . gate_feature ( "lang_items" ,
589
+ attr. span ,
590
+ "language items are subject to change" ) ,
591
+ name => {
592
+ // Custom attribute check
593
+ if KNOWN_ATTRIBUTES . iter ( ) . all ( |& ( n, _) | n != name) {
594
+ self . gate_feature ( "custom_attribute" , attr. span ,
595
+ format ! ( "The attribute `{}` is currently \
596
+ unknown to the the compiler and \
597
+ may have meaning \
598
+ added to it in the future",
599
+ attr. name( ) ) . as_slice ( ) ) ;
600
+ }
601
+ }
613
602
}
614
603
}
615
604
0 commit comments