@@ -1024,12 +1024,10 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
10241024 placeholder ( fragment_kind, NodeId :: placeholder_from_expn_id ( expn_id) , vis)
10251025 }
10261026
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 ( ) ;
10331031 self . collect ( kind, InvocationKind :: Bang { mac, span } )
10341032 }
10351033
@@ -1216,7 +1214,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
12161214
12171215 if let ast:: ExprKind :: MacCall ( mac) = expr. kind {
12181216 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 ( )
12201218 } else {
12211219 assign_id ! ( self , & mut expr. id, || {
12221220 ensure_sufficient_stack( || noop_visit_expr( & mut expr, self ) ) ;
@@ -1312,7 +1310,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
13121310
13131311 if let ast:: ExprKind :: MacCall ( mac) = expr. kind {
13141312 self . check_attributes ( & expr. attrs , & mac) ;
1315- self . collect_bang ( mac, expr . span , AstFragmentKind :: OptExpr )
1313+ self . collect_bang ( mac, AstFragmentKind :: OptExpr )
13161314 . make_opt_expr ( )
13171315 . map ( |expr| expr. into_inner ( ) )
13181316 } else {
@@ -1333,9 +1331,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
13331331 }
13341332
13351333 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 ( ) ,
13391335 _ => unreachable ! ( ) ,
13401336 } ) ;
13411337 }
@@ -1354,12 +1350,10 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
13541350 . make_stmts ( ) ;
13551351 }
13561352
1357- let span = stmt. span ;
13581353 match self . take_stmt_bang ( stmt) {
13591354 Ok ( ( add_semicolon, mac, attrs) ) => {
13601355 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 ( ) ;
13631357
13641358 // If this is a macro invocation with a semicolon, then apply that
13651359 // semicolon to the final statement produced by expansion.
@@ -1427,7 +1421,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
14271421 item. attrs = attrs;
14281422 item. and_then ( |item| match item. kind {
14291423 ItemKind :: MacCall ( mac) => {
1430- self . collect_bang ( mac, span , AstFragmentKind :: Items ) . make_items ( )
1424+ self . collect_bang ( mac, AstFragmentKind :: Items ) . make_items ( )
14311425 }
14321426 _ => unreachable ! ( ) ,
14331427 } )
@@ -1536,9 +1530,9 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
15361530 ast:: AssocItemKind :: MacCall ( ref mac) => {
15371531 self . check_attributes ( & item. attrs , & mac) ;
15381532 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+ }
15421536 _ => unreachable ! ( ) ,
15431537 } )
15441538 }
@@ -1561,9 +1555,9 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
15611555 ast:: AssocItemKind :: MacCall ( ref mac) => {
15621556 self . check_attributes ( & item. attrs , & mac) ;
15631557 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+ }
15671561 _ => unreachable ! ( ) ,
15681562 } )
15691563 }
@@ -1580,9 +1574,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
15801574 } ;
15811575
15821576 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 ( ) ,
15861578 _ => unreachable ! ( ) ,
15871579 } ) ;
15881580 }
@@ -1607,9 +1599,9 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
16071599 ast:: ForeignItemKind :: MacCall ( ref mac) => {
16081600 self . check_attributes ( & foreign_item. attrs , & mac) ;
16091601 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+ }
16131605 _ => unreachable ! ( ) ,
16141606 } )
16151607 }
0 commit comments