@@ -1024,12 +1024,10 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
1024
1024
placeholder ( fragment_kind, NodeId :: placeholder_from_expn_id ( expn_id) , vis)
1025
1025
}
1026
1026
1027
- fn collect_bang (
1028
- & mut self ,
1029
- mac : ast:: MacCall ,
1030
- span : Span ,
1031
- kind : AstFragmentKind ,
1032
- ) -> AstFragment {
1027
+ fn collect_bang ( & mut self , mac : ast:: MacCall , kind : AstFragmentKind ) -> AstFragment {
1028
+ // cache the macro call span so that it can be
1029
+ // easily adjusted for incremental compilation
1030
+ let span = mac. span ( ) ;
1033
1031
self . collect ( kind, InvocationKind :: Bang { mac, span } )
1034
1032
}
1035
1033
@@ -1087,25 +1085,19 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
1087
1085
let MacCallStmt { mac, style, attrs, .. } = mac. into_inner ( ) ;
1088
1086
Ok ( ( style == MacStmtStyle :: Semicolon , mac, attrs. into ( ) ) )
1089
1087
}
1090
- StmtKind :: Item ( ref item) if matches ! ( item. kind, ItemKind :: MacCall ( ..) ) => {
1091
- match stmt. kind {
1092
- StmtKind :: Item ( item) => match item. into_inner ( ) {
1093
- ast:: Item { kind : ItemKind :: MacCall ( mac) , attrs, .. } => {
1094
- Ok ( ( mac. args . need_semicolon ( ) , mac, attrs) )
1095
- }
1096
- _ => unreachable ! ( ) ,
1097
- } ,
1088
+ StmtKind :: Item ( item) if matches ! ( item. kind, ItemKind :: MacCall ( ..) ) => {
1089
+ match item. into_inner ( ) {
1090
+ ast:: Item { kind : ItemKind :: MacCall ( mac) , attrs, .. } => {
1091
+ Ok ( ( mac. args . need_semicolon ( ) , mac, attrs) )
1092
+ }
1098
1093
_ => unreachable ! ( ) ,
1099
1094
}
1100
1095
}
1101
- StmtKind :: Semi ( ref expr) if matches ! ( expr. kind, ast:: ExprKind :: MacCall ( ..) ) => {
1102
- match stmt. kind {
1103
- StmtKind :: Semi ( expr) => match expr. into_inner ( ) {
1104
- ast:: Expr { kind : ast:: ExprKind :: MacCall ( mac) , attrs, .. } => {
1105
- Ok ( ( mac. args . need_semicolon ( ) , mac, attrs. into ( ) ) )
1106
- }
1107
- _ => unreachable ! ( ) ,
1108
- } ,
1096
+ StmtKind :: Semi ( expr) if matches ! ( expr. kind, ast:: ExprKind :: MacCall ( ..) ) => {
1097
+ match expr. into_inner ( ) {
1098
+ ast:: Expr { kind : ast:: ExprKind :: MacCall ( mac) , attrs, .. } => {
1099
+ Ok ( ( mac. args . need_semicolon ( ) , mac, attrs. into ( ) ) )
1100
+ }
1109
1101
_ => unreachable ! ( ) ,
1110
1102
}
1111
1103
}
@@ -1222,7 +1214,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1222
1214
1223
1215
if let ast:: ExprKind :: MacCall ( mac) = expr. kind {
1224
1216
self . check_attributes ( & expr. attrs , & mac) ;
1225
- self . collect_bang ( mac, expr . span , AstFragmentKind :: Expr ) . make_expr ( ) . into_inner ( )
1217
+ self . collect_bang ( mac, AstFragmentKind :: Expr ) . make_expr ( ) . into_inner ( )
1226
1218
} else {
1227
1219
assign_id ! ( self , & mut expr. id, || {
1228
1220
ensure_sufficient_stack( || noop_visit_expr( & mut expr, self ) ) ;
@@ -1318,7 +1310,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1318
1310
1319
1311
if let ast:: ExprKind :: MacCall ( mac) = expr. kind {
1320
1312
self . check_attributes ( & expr. attrs , & mac) ;
1321
- self . collect_bang ( mac, expr . span , AstFragmentKind :: OptExpr )
1313
+ self . collect_bang ( mac, AstFragmentKind :: OptExpr )
1322
1314
. make_opt_expr ( )
1323
1315
. map ( |expr| expr. into_inner ( ) )
1324
1316
} else {
@@ -1339,9 +1331,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1339
1331
}
1340
1332
1341
1333
visit_clobber ( pat, |mut pat| match mem:: replace ( & mut pat. kind , PatKind :: Wild ) {
1342
- PatKind :: MacCall ( mac) => {
1343
- self . collect_bang ( mac, pat. span , AstFragmentKind :: Pat ) . make_pat ( )
1344
- }
1334
+ PatKind :: MacCall ( mac) => self . collect_bang ( mac, AstFragmentKind :: Pat ) . make_pat ( ) ,
1345
1335
_ => unreachable ! ( ) ,
1346
1336
} ) ;
1347
1337
}
@@ -1360,12 +1350,10 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1360
1350
. make_stmts ( ) ;
1361
1351
}
1362
1352
1363
- let span = stmt. span ;
1364
1353
match self . take_stmt_bang ( stmt) {
1365
1354
Ok ( ( add_semicolon, mac, attrs) ) => {
1366
1355
self . check_attributes ( & attrs, & mac) ;
1367
- let mut stmts =
1368
- self . collect_bang ( mac, span, AstFragmentKind :: Stmts ) . make_stmts ( ) ;
1356
+ let mut stmts = self . collect_bang ( mac, AstFragmentKind :: Stmts ) . make_stmts ( ) ;
1369
1357
1370
1358
// If this is a macro invocation with a semicolon, then apply that
1371
1359
// semicolon to the final statement produced by expansion.
@@ -1433,7 +1421,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1433
1421
item. attrs = attrs;
1434
1422
item. and_then ( |item| match item. kind {
1435
1423
ItemKind :: MacCall ( mac) => {
1436
- self . collect_bang ( mac, span , AstFragmentKind :: Items ) . make_items ( )
1424
+ self . collect_bang ( mac, AstFragmentKind :: Items ) . make_items ( )
1437
1425
}
1438
1426
_ => unreachable ! ( ) ,
1439
1427
} )
@@ -1542,9 +1530,9 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1542
1530
ast:: AssocItemKind :: MacCall ( ref mac) => {
1543
1531
self . check_attributes ( & item. attrs , & mac) ;
1544
1532
item. and_then ( |item| match item. kind {
1545
- ast:: AssocItemKind :: MacCall ( mac) => self
1546
- . collect_bang ( mac, item . span , AstFragmentKind :: TraitItems )
1547
- . make_trait_items ( ) ,
1533
+ ast:: AssocItemKind :: MacCall ( mac) => {
1534
+ self . collect_bang ( mac, AstFragmentKind :: TraitItems ) . make_trait_items ( )
1535
+ }
1548
1536
_ => unreachable ! ( ) ,
1549
1537
} )
1550
1538
}
@@ -1567,9 +1555,9 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1567
1555
ast:: AssocItemKind :: MacCall ( ref mac) => {
1568
1556
self . check_attributes ( & item. attrs , & mac) ;
1569
1557
item. and_then ( |item| match item. kind {
1570
- ast:: AssocItemKind :: MacCall ( mac) => self
1571
- . collect_bang ( mac, item . span , AstFragmentKind :: ImplItems )
1572
- . make_impl_items ( ) ,
1558
+ ast:: AssocItemKind :: MacCall ( mac) => {
1559
+ self . collect_bang ( mac, AstFragmentKind :: ImplItems ) . make_impl_items ( )
1560
+ }
1573
1561
_ => unreachable ! ( ) ,
1574
1562
} )
1575
1563
}
@@ -1586,9 +1574,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1586
1574
} ;
1587
1575
1588
1576
visit_clobber ( ty, |mut ty| match mem:: replace ( & mut ty. kind , ast:: TyKind :: Err ) {
1589
- ast:: TyKind :: MacCall ( mac) => {
1590
- self . collect_bang ( mac, ty. span , AstFragmentKind :: Ty ) . make_ty ( )
1591
- }
1577
+ ast:: TyKind :: MacCall ( mac) => self . collect_bang ( mac, AstFragmentKind :: Ty ) . make_ty ( ) ,
1592
1578
_ => unreachable ! ( ) ,
1593
1579
} ) ;
1594
1580
}
@@ -1613,9 +1599,9 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1613
1599
ast:: ForeignItemKind :: MacCall ( ref mac) => {
1614
1600
self . check_attributes ( & foreign_item. attrs , & mac) ;
1615
1601
foreign_item. and_then ( |item| match item. kind {
1616
- ast:: ForeignItemKind :: MacCall ( mac) => self
1617
- . collect_bang ( mac, item . span , AstFragmentKind :: ForeignItems )
1618
- . make_foreign_items ( ) ,
1602
+ ast:: ForeignItemKind :: MacCall ( mac) => {
1603
+ self . collect_bang ( mac, AstFragmentKind :: ForeignItems ) . make_foreign_items ( )
1604
+ }
1619
1605
_ => unreachable ! ( ) ,
1620
1606
} )
1621
1607
}
0 commit comments