@@ -19,7 +19,8 @@ use ext::build::AstBuilder;
19
19
use attr;
20
20
use attr:: AttrMetaMethods ;
21
21
use codemap;
22
- use codemap:: { Span , Spanned , ExpnInfo , NameAndSpan , MacroBang , MacroAttribute , CompilerExpansion } ;
22
+ use codemap:: { Span , Spanned , ExpnInfo , NameAndSpan , MacroBang , MacroAttribute } ;
23
+ use codemap:: { CompilerExpansion , CompilerExpansionFormat } ;
23
24
use ext:: base:: * ;
24
25
use feature_gate:: { self , Features , GatedCfg } ;
25
26
use fold;
@@ -43,12 +44,12 @@ fn mk_core_path(fld: &mut MacroExpander,
43
44
}
44
45
45
46
pub fn expand_expr ( e : P < ast:: Expr > , fld : & mut MacroExpander ) -> P < ast:: Expr > {
46
- fn push_compiler_expansion ( fld : & mut MacroExpander , span : Span , expansion_desc : & str ) {
47
+ fn push_compiler_expansion ( fld : & mut MacroExpander , span : Span ,
48
+ expansion_type : CompilerExpansionFormat ) {
47
49
fld. cx . bt_push ( ExpnInfo {
48
50
call_site : span,
49
51
callee : NameAndSpan {
50
- name : expansion_desc. to_string ( ) ,
51
- format : CompilerExpansion ,
52
+ format : CompilerExpansion ( expansion_type) ,
52
53
53
54
// This does *not* mean code generated after
54
55
// `push_compiler_expansion` is automatically exempt
@@ -111,7 +112,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
111
112
& fld. cx . parse_sess . span_diagnostic ,
112
113
expr_span) ;
113
114
114
- push_compiler_expansion ( fld, expr_span, "placement-in expansion" ) ;
115
+ push_compiler_expansion ( fld, expr_span, CompilerExpansionFormat :: PlacementIn ) ;
115
116
116
117
let value_span = value_expr. span ;
117
118
let placer_span = placer. span ;
@@ -223,7 +224,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
223
224
// }
224
225
// }
225
226
226
- push_compiler_expansion ( fld, span, "while let expansion" ) ;
227
+ push_compiler_expansion ( fld, span, CompilerExpansionFormat :: WhileLet ) ;
227
228
228
229
// `<pat> => <body>`
229
230
let pat_arm = {
@@ -262,7 +263,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
262
263
// _ => [<elseopt> | ()]
263
264
// }
264
265
265
- push_compiler_expansion ( fld, span, "if let expansion" ) ;
266
+ push_compiler_expansion ( fld, span, CompilerExpansionFormat :: IfLet ) ;
266
267
267
268
// `<pat> => <body>`
268
269
let pat_arm = {
@@ -334,7 +335,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
334
335
ast:: ExprIf ( cond, blk, elseopt) => {
335
336
let elseopt = elseopt. map ( |els| els. and_then ( |els| match els. node {
336
337
ast:: ExprIfLet ( ..) => {
337
- push_compiler_expansion ( fld, span, "if let expansion" ) ;
338
+ push_compiler_expansion ( fld, span, CompilerExpansionFormat :: IfLet ) ;
338
339
// wrap the if-let expr in a block
339
340
let span = els. span ;
340
341
let blk = P ( ast:: Block {
@@ -378,7 +379,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
378
379
// result
379
380
// }
380
381
381
- push_compiler_expansion ( fld, span, "for loop expansion" ) ;
382
+ push_compiler_expansion ( fld, span, CompilerExpansionFormat :: ForLoop ) ;
382
383
383
384
let span = fld. new_span ( span) ;
384
385
@@ -458,7 +459,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
458
459
}
459
460
460
461
ast:: ExprClosure ( capture_clause, fn_decl, block) => {
461
- push_compiler_expansion ( fld, span, "closure expansion" ) ;
462
+ push_compiler_expansion ( fld, span, CompilerExpansionFormat :: Closure ) ;
462
463
let ( rewritten_fn_decl, rewritten_block)
463
464
= expand_and_rename_fn_decl_and_block ( fn_decl, block, fld) ;
464
465
let new_node = ast:: ExprClosure ( capture_clause,
@@ -542,8 +543,7 @@ fn expand_mac_invoc<T, F, G>(mac: ast::Mac,
542
543
fld. cx . bt_push ( ExpnInfo {
543
544
call_site : span,
544
545
callee : NameAndSpan {
545
- name : extname. to_string ( ) ,
546
- format : MacroBang ,
546
+ format : MacroBang ( extname) ,
547
547
span : exp_span,
548
548
allow_internal_unstable : allow_internal_unstable,
549
549
} ,
@@ -721,8 +721,7 @@ pub fn expand_item_mac(it: P<ast::Item>,
721
721
fld. cx . bt_push ( ExpnInfo {
722
722
call_site : it. span ,
723
723
callee : NameAndSpan {
724
- name : extname. to_string ( ) ,
725
- format : MacroBang ,
724
+ format : MacroBang ( extname) ,
726
725
span : span,
727
726
allow_internal_unstable : allow_internal_unstable,
728
727
}
@@ -741,8 +740,7 @@ pub fn expand_item_mac(it: P<ast::Item>,
741
740
fld. cx . bt_push ( ExpnInfo {
742
741
call_site : it. span ,
743
742
callee : NameAndSpan {
744
- name : extname. to_string ( ) ,
745
- format : MacroBang ,
743
+ format : MacroBang ( extname) ,
746
744
span : span,
747
745
allow_internal_unstable : allow_internal_unstable,
748
746
}
@@ -762,8 +760,7 @@ pub fn expand_item_mac(it: P<ast::Item>,
762
760
fld. cx . bt_push ( ExpnInfo {
763
761
call_site : it. span ,
764
762
callee : NameAndSpan {
765
- name : extname. to_string ( ) ,
766
- format : MacroBang ,
763
+ format : MacroBang ( extname) ,
767
764
span : None ,
768
765
// `macro_rules!` doesn't directly allow
769
766
// unstable (this is orthogonal to whether
@@ -1090,8 +1087,7 @@ fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> {
1090
1087
fld. cx . bt_push ( ExpnInfo {
1091
1088
call_site : span,
1092
1089
callee : NameAndSpan {
1093
- name : extname. to_string ( ) ,
1094
- format : MacroBang ,
1090
+ format : MacroBang ( extname) ,
1095
1091
span : tt_span,
1096
1092
allow_internal_unstable : allow_internal_unstable,
1097
1093
}
@@ -1293,17 +1289,16 @@ fn expand_decorators(a: Annotatable,
1293
1289
new_attrs : & mut Vec < ast:: Attribute > )
1294
1290
{
1295
1291
for attr in a. attrs ( ) {
1296
- let mname = attr. name ( ) ;
1297
- match fld. cx . syntax_env . find ( & intern ( & mname) ) {
1292
+ let mname = intern ( & attr. name ( ) ) ;
1293
+ match fld. cx . syntax_env . find ( & mname) {
1298
1294
Some ( rc) => match * rc {
1299
1295
Decorator ( ref dec) => {
1300
1296
attr:: mark_used ( & attr) ;
1301
1297
1302
1298
fld. cx . bt_push ( ExpnInfo {
1303
1299
call_site : attr. span ,
1304
1300
callee : NameAndSpan {
1305
- name : mname. to_string ( ) ,
1306
- format : MacroAttribute ,
1301
+ format : MacroAttribute ( mname) ,
1307
1302
span : Some ( attr. span ) ,
1308
1303
// attributes can do whatever they like,
1309
1304
// for now.
@@ -1330,8 +1325,7 @@ fn expand_decorators(a: Annotatable,
1330
1325
fld. cx . bt_push ( ExpnInfo {
1331
1326
call_site : attr. span ,
1332
1327
callee : NameAndSpan {
1333
- name : mname. to_string ( ) ,
1334
- format : MacroAttribute ,
1328
+ format : MacroAttribute ( mname) ,
1335
1329
span : Some ( attr. span ) ,
1336
1330
// attributes can do whatever they like,
1337
1331
// for now.
@@ -1372,17 +1366,16 @@ fn expand_item_multi_modifier(mut it: Annotatable,
1372
1366
}
1373
1367
1374
1368
for attr in & modifiers {
1375
- let mname = attr. name ( ) ;
1369
+ let mname = intern ( & attr. name ( ) ) ;
1376
1370
1377
- match fld. cx . syntax_env . find ( & intern ( & mname) ) {
1371
+ match fld. cx . syntax_env . find ( & mname) {
1378
1372
Some ( rc) => match * rc {
1379
1373
MultiModifier ( ref mac) => {
1380
1374
attr:: mark_used ( attr) ;
1381
1375
fld. cx . bt_push ( ExpnInfo {
1382
1376
call_site : attr. span ,
1383
1377
callee : NameAndSpan {
1384
- name : mname. to_string ( ) ,
1385
- format : MacroAttribute ,
1378
+ format : MacroAttribute ( mname) ,
1386
1379
span : Some ( attr. span ) ,
1387
1380
// attributes can do whatever they like,
1388
1381
// for now
@@ -1421,17 +1414,16 @@ fn expand_item_modifiers(mut it: P<ast::Item>,
1421
1414
}
1422
1415
1423
1416
for attr in & modifiers {
1424
- let mname = attr. name ( ) ;
1417
+ let mname = intern ( & attr. name ( ) ) ;
1425
1418
1426
- match fld. cx . syntax_env . find ( & intern ( & mname) ) {
1419
+ match fld. cx . syntax_env . find ( & mname) {
1427
1420
Some ( rc) => match * rc {
1428
1421
Modifier ( ref mac) => {
1429
1422
attr:: mark_used ( attr) ;
1430
1423
fld. cx . bt_push ( ExpnInfo {
1431
1424
call_site : attr. span ,
1432
1425
callee : NameAndSpan {
1433
- name : mname. to_string ( ) ,
1434
- format : MacroAttribute ,
1426
+ format : MacroAttribute ( mname) ,
1435
1427
span : Some ( attr. span ) ,
1436
1428
// attributes can do whatever they like,
1437
1429
// for now
0 commit comments