@@ -39,7 +39,7 @@ use syntax::codemap::{self, Span, Spanned, DUMMY_SP, ExpnId};
39
39
use syntax:: abi:: Abi ;
40
40
use syntax:: ast:: { Name , NodeId , DUMMY_NODE_ID , TokenTree , AsmDialect } ;
41
41
use syntax:: ast:: { Attribute , Lit , StrStyle , FloatTy , IntTy , UintTy , MetaItem } ;
42
- use syntax:: attr:: ThinAttributes ;
42
+ use syntax:: attr:: { ThinAttributes , ThinAttributesExt } ;
43
43
use syntax:: parse:: token:: InternedString ;
44
44
use syntax:: ptr:: P ;
45
45
@@ -635,6 +635,16 @@ pub enum Stmt_ {
635
635
StmtSemi ( P < Expr > , NodeId ) ,
636
636
}
637
637
638
+ impl Stmt_ {
639
+ pub fn attrs ( & self ) -> & [ Attribute ] {
640
+ match * self {
641
+ StmtDecl ( ref d, _) => d. node . attrs ( ) ,
642
+ StmtExpr ( ref e, _) |
643
+ StmtSemi ( ref e, _) => e. attrs . as_attr_slice ( ) ,
644
+ }
645
+ }
646
+ }
647
+
638
648
// FIXME (pending discussion of #1697, #2178...): local should really be
639
649
// a refinement on pat.
640
650
/// Local represents a `let` statement, e.g., `let <pat>:<ty> = <expr>;`
@@ -659,6 +669,15 @@ pub enum Decl_ {
659
669
DeclItem ( ItemId ) ,
660
670
}
661
671
672
+ impl Decl_ {
673
+ pub fn attrs ( & self ) -> & [ Attribute ] {
674
+ match * self {
675
+ DeclLocal ( ref l) => l. attrs . as_attr_slice ( ) ,
676
+ DeclItem ( _) => & [ ]
677
+ }
678
+ }
679
+ }
680
+
662
681
/// represents one arm of a 'match'
663
682
#[ derive( Clone , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug ) ]
664
683
pub struct Arm {
0 commit comments