@@ -16,7 +16,7 @@ use ast;
1616use ext:: mtwt;
1717use ext:: build:: AstBuilder ;
1818use attr;
19- use attr:: { AttrMetaMethods , WithAttrs } ;
19+ use attr:: { AttrMetaMethods , WithAttrs , ThinAttributesExt } ;
2020use codemap;
2121use codemap:: { Span , Spanned , ExpnInfo , NameAndSpan , MacroBang , MacroAttribute } ;
2222use ext:: base:: * ;
@@ -86,14 +86,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
8686 // expr_mac should really be expr_ext or something; it's the
8787 // entry-point for all syntax extensions.
8888 ast:: ExprKind :: Mac ( mac) => {
89- if let Some ( ref attrs) = attrs {
90- check_attributes ( attrs, fld) ;
91- }
92-
93- // Assert that we drop any macro attributes on the floor here
94- drop ( attrs) ;
95-
96- expand_mac_invoc ( mac, span, fld)
89+ expand_mac_invoc ( mac, attrs. into_attr_vec ( ) , span, fld)
9790 }
9891
9992 ast:: ExprKind :: InPlace ( placer, value_expr) => {
@@ -204,7 +197,12 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
204197}
205198
206199/// Expand a (not-ident-style) macro invocation. Returns the result of expansion.
207- fn expand_mac_invoc < T : MacroGenerable > ( mac : ast:: Mac , span : Span , fld : & mut MacroExpander ) -> T {
200+ fn expand_mac_invoc < T > ( mac : ast:: Mac , attrs : Vec < ast:: Attribute > , span : Span ,
201+ fld : & mut MacroExpander ) -> T
202+ where T : MacroGenerable ,
203+ {
204+ check_attributes ( & attrs, fld) ;
205+
208206 // it would almost certainly be cleaner to pass the whole
209207 // macro invocation in, rather than pulling it apart and
210208 // marking the tts and the ctxt separately. This also goes
@@ -527,15 +525,8 @@ fn expand_stmt(stmt: Stmt, fld: &mut MacroExpander) -> SmallVector<Stmt> {
527525 _ => return expand_non_macro_stmt ( stmt, fld)
528526 } ;
529527
530- if let Some ( ref attrs) = attrs {
531- check_attributes ( attrs, fld) ;
532- }
533-
534- // Assert that we drop any macro attributes on the floor here
535- drop ( attrs) ;
536-
537528 let mut fully_expanded: SmallVector < ast:: Stmt > =
538- expand_mac_invoc ( mac. unwrap ( ) , stmt. span , fld) ;
529+ expand_mac_invoc ( mac. unwrap ( ) , attrs . into_attr_vec ( ) , stmt. span , fld) ;
539530
540531 // If this is a macro invocation with a semicolon, then apply that
541532 // semicolon to the final statement produced by expansion.
@@ -752,7 +743,7 @@ fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> {
752743 }
753744 p. and_then ( |ast:: Pat { node, span, ..} | {
754745 match node {
755- PatKind :: Mac ( mac) => expand_mac_invoc ( mac, span, fld) ,
746+ PatKind :: Mac ( mac) => expand_mac_invoc ( mac, Vec :: new ( ) , span, fld) ,
756747 _ => unreachable ! ( )
757748 }
758749 } )
@@ -1007,8 +998,7 @@ fn expand_impl_item(ii: ast::ImplItem, fld: &mut MacroExpander)
1007998 span : fld. new_span ( ii. span )
1008999 } ) ,
10091000 ast:: ImplItemKind :: Macro ( mac) => {
1010- check_attributes ( & ii. attrs , fld) ;
1011- expand_mac_invoc ( mac, ii. span , fld)
1001+ expand_mac_invoc ( mac, ii. attrs , ii. span , fld)
10121002 }
10131003 _ => fold:: noop_fold_impl_item ( ii, fld)
10141004 }
@@ -1052,7 +1042,7 @@ pub fn expand_type(t: P<ast::Ty>, fld: &mut MacroExpander) -> P<ast::Ty> {
10521042 let t = match t. node . clone ( ) {
10531043 ast:: TyKind :: Mac ( mac) => {
10541044 if fld. cx . ecfg . features . unwrap ( ) . type_macros {
1055- expand_mac_invoc ( mac, t. span , fld)
1045+ expand_mac_invoc ( mac, Vec :: new ( ) , t. span , fld)
10561046 } else {
10571047 feature_gate:: emit_feature_err (
10581048 & fld. cx . parse_sess . span_diagnostic ,
0 commit comments