@@ -16,8 +16,7 @@ pub use self::IntType::*;
16
16
17
17
use ast;
18
18
use ast:: { AttrId , Attribute , Attribute_ , MetaItem , MetaItemKind } ;
19
- use ast:: { Stmt , StmtKind , DeclKind } ;
20
- use ast:: { Expr , Item , Local , Decl } ;
19
+ use ast:: { Expr , Item , Local , Stmt , StmtKind } ;
21
20
use codemap:: { spanned, dummy_spanned, Spanned } ;
22
21
use syntax_pos:: { Span , BytePos } ;
23
22
use errors:: Handler ;
@@ -909,38 +908,28 @@ impl<T: HasAttrs + 'static> HasAttrs for P<T> {
909
908
}
910
909
}
911
910
912
- impl HasAttrs for DeclKind {
913
- fn attrs ( & self ) -> & [ Attribute ] {
914
- match * self {
915
- DeclKind :: Local ( ref local) => local. attrs ( ) ,
916
- DeclKind :: Item ( ref item) => item. attrs ( ) ,
917
- }
918
- }
919
-
920
- fn map_attrs < F : FnOnce ( Vec < Attribute > ) -> Vec < Attribute > > ( self , f : F ) -> Self {
921
- match self {
922
- DeclKind :: Local ( local) => DeclKind :: Local ( local. map_attrs ( f) ) ,
923
- DeclKind :: Item ( item) => DeclKind :: Item ( item. map_attrs ( f) ) ,
924
- }
925
- }
926
- }
927
-
928
911
impl HasAttrs for StmtKind {
929
912
fn attrs ( & self ) -> & [ Attribute ] {
930
913
match * self {
931
- StmtKind :: Decl ( ref decl, _) => decl. attrs ( ) ,
932
- StmtKind :: Expr ( ref expr, _) | StmtKind :: Semi ( ref expr, _) => expr. attrs ( ) ,
933
- StmtKind :: Mac ( _, _, ref attrs) => attrs. attrs ( ) ,
914
+ StmtKind :: Local ( ref local) => local. attrs ( ) ,
915
+ StmtKind :: Item ( ref item) => item. attrs ( ) ,
916
+ StmtKind :: Expr ( ref expr) | StmtKind :: Semi ( ref expr) => expr. attrs ( ) ,
917
+ StmtKind :: Mac ( ref mac) => {
918
+ let ( _, _, ref attrs) = * * mac;
919
+ attrs. attrs ( )
920
+ }
934
921
}
935
922
}
936
923
937
924
fn map_attrs < F : FnOnce ( Vec < Attribute > ) -> Vec < Attribute > > ( self , f : F ) -> Self {
938
925
match self {
939
- StmtKind :: Decl ( decl, id) => StmtKind :: Decl ( decl. map_attrs ( f) , id) ,
940
- StmtKind :: Expr ( expr, id) => StmtKind :: Expr ( expr. map_attrs ( f) , id) ,
941
- StmtKind :: Semi ( expr, id) => StmtKind :: Semi ( expr. map_attrs ( f) , id) ,
942
- StmtKind :: Mac ( mac, style, attrs) =>
943
- StmtKind :: Mac ( mac, style, attrs. map_attrs ( f) ) ,
926
+ StmtKind :: Local ( local) => StmtKind :: Local ( local. map_attrs ( f) ) ,
927
+ StmtKind :: Item ( item) => StmtKind :: Item ( item. map_attrs ( f) ) ,
928
+ StmtKind :: Expr ( expr) => StmtKind :: Expr ( expr. map_attrs ( f) ) ,
929
+ StmtKind :: Semi ( expr) => StmtKind :: Semi ( expr. map_attrs ( f) ) ,
930
+ StmtKind :: Mac ( mac) => StmtKind :: Mac ( mac. map ( |( mac, style, attrs) | {
931
+ ( mac, style, attrs. map_attrs ( f) )
932
+ } ) ) ,
944
933
}
945
934
}
946
935
}
@@ -967,4 +956,4 @@ derive_has_attrs_from_field! {
967
956
Item , Expr , Local , ast:: ForeignItem , ast:: StructField , ast:: ImplItem , ast:: TraitItem , ast:: Arm
968
957
}
969
958
970
- derive_has_attrs_from_field ! { Decl : . node , Stmt : . node, ast:: Variant : . node. attrs }
959
+ derive_has_attrs_from_field ! { Stmt : . node, ast:: Variant : . node. attrs }
0 commit comments