@@ -1204,7 +1204,7 @@ macro_rules! assign_id {
12041204}
12051205
12061206enum AddSemicolon {
1207- Yes ,
1207+ Yes ( Span ) ,
12081208 No ,
12091209}
12101210
@@ -1687,7 +1687,7 @@ impl InvocationCollectorNode for ast::Stmt {
16871687 StmtKind :: Item ( item) => matches ! ( item. kind, ItemKind :: MacCall ( ..) ) ,
16881688 StmtKind :: Semi ( expr) => matches ! ( expr. kind, ExprKind :: MacCall ( ..) ) ,
16891689 StmtKind :: Expr ( ..) => unreachable ! ( ) ,
1690- StmtKind :: Let ( ..) | StmtKind :: Empty => false ,
1690+ StmtKind :: Let ( ..) | StmtKind :: Empty ( _ ) => false ,
16911691 }
16921692 }
16931693 fn take_mac_call ( self ) -> ( P < ast:: MacCall > , ast:: AttrVec , AddSemicolon ) {
@@ -1696,23 +1696,32 @@ impl InvocationCollectorNode for ast::Stmt {
16961696 let ( add_semicolon, mac, attrs) = match self . kind {
16971697 StmtKind :: MacCall ( mac) => {
16981698 let ast:: MacCallStmt { mac, style, attrs, .. } = * mac;
1699- ( style == MacStmtStyle :: Semicolon , mac, attrs)
1699+ let add_semicolon = match style {
1700+ MacStmtStyle :: Semicolon ( span) => AddSemicolon :: Yes ( span) ,
1701+ MacStmtStyle :: Braces | MacStmtStyle :: NoBraces => AddSemicolon :: No ,
1702+ } ;
1703+ ( add_semicolon, mac, attrs)
17001704 }
17011705 StmtKind :: Item ( item) => match * item {
17021706 ast:: Item { kind : ItemKind :: MacCall ( mac) , attrs, .. } => {
1703- ( mac . args . need_semicolon ( ) , mac, attrs)
1707+ ( AddSemicolon :: No , mac, attrs)
17041708 }
17051709 _ => unreachable ! ( ) ,
17061710 } ,
17071711 StmtKind :: Semi ( expr) => match * expr {
1708- ast:: Expr { kind : ExprKind :: MacCall ( mac) , attrs, .. } => {
1709- ( mac. args . need_semicolon ( ) , mac, attrs)
1712+ ast:: Expr { kind : ExprKind :: MacCall ( mac) , attrs, span : expr_span, .. } => {
1713+ let add_semicolon = if mac. args . need_semicolon ( ) {
1714+ AddSemicolon :: Yes ( expr_span. shrink_to_hi ( ) . to ( self . span ) )
1715+ } else {
1716+ AddSemicolon :: No
1717+ } ;
1718+ ( add_semicolon, mac, attrs)
17101719 }
17111720 _ => unreachable ! ( ) ,
17121721 } ,
17131722 _ => unreachable ! ( ) ,
17141723 } ;
1715- ( mac, attrs, if add_semicolon { AddSemicolon :: Yes } else { AddSemicolon :: No } )
1724+ ( mac, attrs, add_semicolon)
17161725 }
17171726 fn delegation ( & self ) -> Option < ( & ast:: DelegationMac , & ast:: Item < Self :: ItemKind > ) > {
17181727 match & self . kind {
@@ -1735,9 +1744,9 @@ impl InvocationCollectorNode for ast::Stmt {
17351744 fn post_flat_map_node_collect_bang ( stmts : & mut Self :: OutputTy , add_semicolon : AddSemicolon ) {
17361745 // If this is a macro invocation with a semicolon, then apply that
17371746 // semicolon to the final statement produced by expansion.
1738- if matches ! ( add_semicolon , AddSemicolon :: Yes ) {
1747+ if let AddSemicolon :: Yes ( semi_span ) = add_semicolon {
17391748 if let Some ( stmt) = stmts. pop ( ) {
1740- stmts. push ( stmt. add_trailing_semicolon ( ) ) ;
1749+ stmts. push ( stmt. add_trailing_semicolon ( semi_span ) ) ;
17411750 }
17421751 }
17431752 }
0 commit comments