@@ -37,15 +37,14 @@ use std::collections::HashSet;
37
37
38
38
pub fn expand_expr ( e : P < ast:: Expr > , fld : & mut MacroExpander ) -> P < ast:: Expr > {
39
39
let expr_span = e. span ;
40
- // FIXME: Drop attrs on the floor for now.
41
40
return e. and_then ( |ast:: Expr { id, node, span, attrs} | match node {
42
41
43
42
// expr_mac should really be expr_ext or something; it's the
44
43
// entry-point for all syntax extensions.
45
44
ast:: ExprMac ( mac) => {
46
45
47
- // drop attributes on the macro itself
48
- let _ = attrs;
46
+ // FIXME: for now, drop attributes on the macro itself
47
+ drop ( attrs) ;
49
48
50
49
let expanded_expr = match expand_mac_invoc ( mac, span,
51
50
|r| r. make_expr ( ) ,
@@ -79,14 +78,14 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
79
78
let placer = fld. fold_expr ( placer) ;
80
79
let value_expr = fld. fold_expr ( value_expr) ;
81
80
fld. cx . expr ( span, ast:: ExprInPlace ( placer, value_expr) )
82
- . with_attrs ( attrs)
81
+ . with_attrs ( fold_thin_attrs ( attrs, fld ) )
83
82
}
84
83
85
84
ast:: ExprWhile ( cond, body, opt_ident) => {
86
85
let cond = fld. fold_expr ( cond) ;
87
86
let ( body, opt_ident) = expand_loop_block ( body, opt_ident, fld) ;
88
87
fld. cx . expr ( span, ast:: ExprWhile ( cond, body, opt_ident) )
89
- . with_attrs ( attrs)
88
+ . with_attrs ( fold_thin_attrs ( attrs, fld ) )
90
89
}
91
90
92
91
ast:: ExprWhileLet ( pat, expr, body, opt_ident) => {
@@ -104,13 +103,13 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
104
103
assert ! ( rewritten_pats. len( ) == 1 ) ;
105
104
106
105
fld. cx . expr ( span, ast:: ExprWhileLet ( rewritten_pats. remove ( 0 ) , expr, body, opt_ident) )
107
- . with_attrs ( attrs)
106
+ . with_attrs ( fold_thin_attrs ( attrs, fld ) )
108
107
}
109
108
110
109
ast:: ExprLoop ( loop_block, opt_ident) => {
111
110
let ( loop_block, opt_ident) = expand_loop_block ( loop_block, opt_ident, fld) ;
112
111
fld. cx . expr ( span, ast:: ExprLoop ( loop_block, opt_ident) )
113
- . with_attrs ( attrs)
112
+ . with_attrs ( fold_thin_attrs ( attrs, fld ) )
114
113
}
115
114
116
115
ast:: ExprForLoop ( pat, head, body, opt_ident) => {
@@ -128,7 +127,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
128
127
129
128
let head = fld. fold_expr ( head) ;
130
129
fld. cx . expr ( span, ast:: ExprForLoop ( rewritten_pats. remove ( 0 ) , head, body, opt_ident) )
131
- . with_attrs ( attrs)
130
+ . with_attrs ( fold_thin_attrs ( attrs, fld ) )
132
131
}
133
132
134
133
ast:: ExprIfLet ( pat, sub_expr, body, else_opt) => {
@@ -147,7 +146,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
147
146
let else_opt = else_opt. map ( |else_opt| fld. fold_expr ( else_opt) ) ;
148
147
let sub_expr = fld. fold_expr ( sub_expr) ;
149
148
fld. cx . expr ( span, ast:: ExprIfLet ( rewritten_pats. remove ( 0 ) , sub_expr, body, else_opt) )
150
- . with_attrs ( attrs)
149
+ . with_attrs ( fold_thin_attrs ( attrs, fld ) )
151
150
}
152
151
153
152
ast:: ExprClosure ( capture_clause, fn_decl, block) => {
@@ -157,17 +156,16 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
157
156
rewritten_fn_decl,
158
157
rewritten_block) ;
159
158
P ( ast:: Expr { id : id, node : new_node, span : fld. new_span ( span) ,
160
- attrs : None } )
161
- . with_attrs ( attrs)
159
+ attrs : fold_thin_attrs ( attrs, fld) } )
162
160
}
163
161
164
162
_ => {
165
163
P ( noop_fold_expr ( ast:: Expr {
166
164
id : id,
167
165
node : node,
168
166
span : span,
169
- attrs : None
170
- } , fld) ) . with_attrs ( attrs )
167
+ attrs : attrs
168
+ } , fld) )
171
169
}
172
170
} ) ;
173
171
}
@@ -506,8 +504,8 @@ fn expand_stmt(stmt: P<Stmt>, fld: &mut MacroExpander) -> SmallVector<P<Stmt>> {
506
504
_ => return expand_non_macro_stmt ( stmt, fld)
507
505
} ;
508
506
509
- // FIXME: drop attrs for macros.
510
- let _ = attrs;
507
+ // FIXME: for now, drop attrs on macros.
508
+ drop ( attrs) ;
511
509
512
510
let maybe_new_items =
513
511
expand_mac_invoc ( mac. and_then ( |m| m) , stmt. span ,
0 commit comments