@@ -16,8 +16,8 @@ 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:: { Stmt , StmtKind } ;
20
+ use ast:: { Expr , Item , Local } ;
21
21
use codemap:: { Span , Spanned , spanned, dummy_spanned} ;
22
22
use codemap:: BytePos ;
23
23
use errors:: Handler ;
@@ -924,38 +924,28 @@ impl<T: HasAttrs + 'static> HasAttrs for P<T> {
924
924
}
925
925
}
926
926
927
- impl HasAttrs for DeclKind {
928
- fn attrs ( & self ) -> & [ Attribute ] {
929
- match * self {
930
- DeclKind :: Local ( ref local) => local. attrs ( ) ,
931
- DeclKind :: Item ( ref item) => item. attrs ( ) ,
932
- }
933
- }
934
-
935
- fn map_attrs < F : FnOnce ( Vec < Attribute > ) -> Vec < Attribute > > ( self , f : F ) -> Self {
936
- match self {
937
- DeclKind :: Local ( local) => DeclKind :: Local ( local. map_attrs ( f) ) ,
938
- DeclKind :: Item ( item) => DeclKind :: Item ( item. map_attrs ( f) ) ,
939
- }
940
- }
941
- }
942
-
943
927
impl HasAttrs for StmtKind {
944
928
fn attrs ( & self ) -> & [ Attribute ] {
945
929
match * self {
946
- StmtKind :: Decl ( ref decl, _) => decl. attrs ( ) ,
947
- StmtKind :: Expr ( ref expr, _) | StmtKind :: Semi ( ref expr, _) => expr. attrs ( ) ,
948
- StmtKind :: Mac ( _, _, ref attrs) => attrs. attrs ( ) ,
930
+ StmtKind :: Local ( ref local) => local. attrs ( ) ,
931
+ StmtKind :: Item ( ref item) => item. attrs ( ) ,
932
+ StmtKind :: Expr ( ref expr) | StmtKind :: Semi ( ref expr) => expr. attrs ( ) ,
933
+ StmtKind :: Mac ( ref mac) => {
934
+ let ( _, _, ref attrs) = * * mac;
935
+ attrs. attrs ( )
936
+ }
949
937
}
950
938
}
951
939
952
940
fn map_attrs < F : FnOnce ( Vec < Attribute > ) -> Vec < Attribute > > ( self , f : F ) -> Self {
953
941
match self {
954
- StmtKind :: Decl ( decl, id) => StmtKind :: Decl ( decl. map_attrs ( f) , id) ,
955
- StmtKind :: Expr ( expr, id) => StmtKind :: Expr ( expr. map_attrs ( f) , id) ,
956
- StmtKind :: Semi ( expr, id) => StmtKind :: Semi ( expr. map_attrs ( f) , id) ,
957
- StmtKind :: Mac ( mac, style, attrs) =>
958
- StmtKind :: Mac ( mac, style, attrs. map_attrs ( f) ) ,
942
+ StmtKind :: Local ( local) => StmtKind :: Local ( local. map_attrs ( f) ) ,
943
+ StmtKind :: Item ( item) => StmtKind :: Item ( item. map_attrs ( f) ) ,
944
+ StmtKind :: Expr ( expr) => StmtKind :: Expr ( expr. map_attrs ( f) ) ,
945
+ StmtKind :: Semi ( expr) => StmtKind :: Semi ( expr. map_attrs ( f) ) ,
946
+ StmtKind :: Mac ( mac) => StmtKind :: Mac ( mac. map ( |( mac, style, attrs) | {
947
+ ( mac, style, attrs. map_attrs ( f) )
948
+ } ) ) ,
959
949
}
960
950
}
961
951
}
@@ -982,4 +972,4 @@ derive_has_attrs_from_field! {
982
972
Item , Expr , Local , ast:: ForeignItem , ast:: StructField , ast:: ImplItem , ast:: TraitItem , ast:: Arm
983
973
}
984
974
985
- derive_has_attrs_from_field ! { Decl : . node , Stmt : . node, ast:: Variant : . node. attrs }
975
+ derive_has_attrs_from_field ! { Stmt : . node, ast:: Variant : . node. attrs }
0 commit comments