@@ -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
@@ -1216,7 +1214,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1216
1214
1217
1215
if let ast:: ExprKind :: MacCall ( mac) = expr. kind {
1218
1216
self . check_attributes ( & expr. attrs , & mac) ;
1219
- self . collect_bang ( mac, expr . span , AstFragmentKind :: Expr ) . make_expr ( ) . into_inner ( )
1217
+ self . collect_bang ( mac, AstFragmentKind :: Expr ) . make_expr ( ) . into_inner ( )
1220
1218
} else {
1221
1219
assign_id ! ( self , & mut expr. id, || {
1222
1220
ensure_sufficient_stack( || noop_visit_expr( & mut expr, self ) ) ;
@@ -1312,7 +1310,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1312
1310
1313
1311
if let ast:: ExprKind :: MacCall ( mac) = expr. kind {
1314
1312
self . check_attributes ( & expr. attrs , & mac) ;
1315
- self . collect_bang ( mac, expr . span , AstFragmentKind :: OptExpr )
1313
+ self . collect_bang ( mac, AstFragmentKind :: OptExpr )
1316
1314
. make_opt_expr ( )
1317
1315
. map ( |expr| expr. into_inner ( ) )
1318
1316
} else {
@@ -1333,9 +1331,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1333
1331
}
1334
1332
1335
1333
visit_clobber ( pat, |mut pat| match mem:: replace ( & mut pat. kind , PatKind :: Wild ) {
1336
- PatKind :: MacCall ( mac) => {
1337
- self . collect_bang ( mac, pat. span , AstFragmentKind :: Pat ) . make_pat ( )
1338
- }
1334
+ PatKind :: MacCall ( mac) => self . collect_bang ( mac, AstFragmentKind :: Pat ) . make_pat ( ) ,
1339
1335
_ => unreachable ! ( ) ,
1340
1336
} ) ;
1341
1337
}
@@ -1354,12 +1350,10 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1354
1350
. make_stmts ( ) ;
1355
1351
}
1356
1352
1357
- let span = stmt. span ;
1358
1353
match self . take_stmt_bang ( stmt) {
1359
1354
Ok ( ( add_semicolon, mac, attrs) ) => {
1360
1355
self . check_attributes ( & attrs, & mac) ;
1361
- let mut stmts =
1362
- self . collect_bang ( mac, span, AstFragmentKind :: Stmts ) . make_stmts ( ) ;
1356
+ let mut stmts = self . collect_bang ( mac, AstFragmentKind :: Stmts ) . make_stmts ( ) ;
1363
1357
1364
1358
// If this is a macro invocation with a semicolon, then apply that
1365
1359
// semicolon to the final statement produced by expansion.
@@ -1427,7 +1421,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1427
1421
item. attrs = attrs;
1428
1422
item. and_then ( |item| match item. kind {
1429
1423
ItemKind :: MacCall ( mac) => {
1430
- self . collect_bang ( mac, span , AstFragmentKind :: Items ) . make_items ( )
1424
+ self . collect_bang ( mac, AstFragmentKind :: Items ) . make_items ( )
1431
1425
}
1432
1426
_ => unreachable ! ( ) ,
1433
1427
} )
@@ -1536,9 +1530,9 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1536
1530
ast:: AssocItemKind :: MacCall ( ref mac) => {
1537
1531
self . check_attributes ( & item. attrs , & mac) ;
1538
1532
item. and_then ( |item| match item. kind {
1539
- ast:: AssocItemKind :: MacCall ( mac) => self
1540
- . collect_bang ( mac, item . span , AstFragmentKind :: TraitItems )
1541
- . make_trait_items ( ) ,
1533
+ ast:: AssocItemKind :: MacCall ( mac) => {
1534
+ self . collect_bang ( mac, AstFragmentKind :: TraitItems ) . make_trait_items ( )
1535
+ }
1542
1536
_ => unreachable ! ( ) ,
1543
1537
} )
1544
1538
}
@@ -1561,9 +1555,9 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1561
1555
ast:: AssocItemKind :: MacCall ( ref mac) => {
1562
1556
self . check_attributes ( & item. attrs , & mac) ;
1563
1557
item. and_then ( |item| match item. kind {
1564
- ast:: AssocItemKind :: MacCall ( mac) => self
1565
- . collect_bang ( mac, item . span , AstFragmentKind :: ImplItems )
1566
- . make_impl_items ( ) ,
1558
+ ast:: AssocItemKind :: MacCall ( mac) => {
1559
+ self . collect_bang ( mac, AstFragmentKind :: ImplItems ) . make_impl_items ( )
1560
+ }
1567
1561
_ => unreachable ! ( ) ,
1568
1562
} )
1569
1563
}
@@ -1580,9 +1574,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1580
1574
} ;
1581
1575
1582
1576
visit_clobber ( ty, |mut ty| match mem:: replace ( & mut ty. kind , ast:: TyKind :: Err ) {
1583
- ast:: TyKind :: MacCall ( mac) => {
1584
- self . collect_bang ( mac, ty. span , AstFragmentKind :: Ty ) . make_ty ( )
1585
- }
1577
+ ast:: TyKind :: MacCall ( mac) => self . collect_bang ( mac, AstFragmentKind :: Ty ) . make_ty ( ) ,
1586
1578
_ => unreachable ! ( ) ,
1587
1579
} ) ;
1588
1580
}
@@ -1607,9 +1599,9 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1607
1599
ast:: ForeignItemKind :: MacCall ( ref mac) => {
1608
1600
self . check_attributes ( & foreign_item. attrs , & mac) ;
1609
1601
foreign_item. and_then ( |item| match item. kind {
1610
- ast:: ForeignItemKind :: MacCall ( mac) => self
1611
- . collect_bang ( mac, item . span , AstFragmentKind :: ForeignItems )
1612
- . make_foreign_items ( ) ,
1602
+ ast:: ForeignItemKind :: MacCall ( mac) => {
1603
+ self . collect_bang ( mac, AstFragmentKind :: ForeignItems ) . make_foreign_items ( )
1604
+ }
1613
1605
_ => unreachable ! ( ) ,
1614
1606
} )
1615
1607
}
0 commit comments