Remove trailing semicolon from macro call span

This commit is contained in:
Cameron Steffen 2021-10-13 13:58:19 -05:00
parent c75a734a43
commit 1333ae67f4

View File

@ -1024,12 +1024,10 @@ fn collect(&mut self, fragment_kind: AstFragmentKind, kind: InvocationKind) -> A
placeholder(fragment_kind, NodeId::placeholder_from_expn_id(expn_id), vis)
}
fn collect_bang(
&mut self,
mac: ast::MacCall,
span: Span,
kind: AstFragmentKind,
) -> AstFragment {
fn collect_bang(&mut self, mac: ast::MacCall, kind: AstFragmentKind) -> AstFragment {
// cache the macro call span so that it can be
// easily adjusted for incremental compilation
let span = mac.span();
self.collect(kind, InvocationKind::Bang { mac, span })
}
@ -1216,7 +1214,7 @@ fn visit_expr(&mut self, expr: &mut P<ast::Expr>) {
if let ast::ExprKind::MacCall(mac) = expr.kind {
self.check_attributes(&expr.attrs, &mac);
self.collect_bang(mac, expr.span, AstFragmentKind::Expr).make_expr().into_inner()
self.collect_bang(mac, AstFragmentKind::Expr).make_expr().into_inner()
} else {
assign_id!(self, &mut expr.id, || {
ensure_sufficient_stack(|| noop_visit_expr(&mut expr, self));
@ -1312,7 +1310,7 @@ fn filter_map_expr(&mut self, expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
if let ast::ExprKind::MacCall(mac) = expr.kind {
self.check_attributes(&expr.attrs, &mac);
self.collect_bang(mac, expr.span, AstFragmentKind::OptExpr)
self.collect_bang(mac, AstFragmentKind::OptExpr)
.make_opt_expr()
.map(|expr| expr.into_inner())
} else {
@ -1333,9 +1331,7 @@ fn visit_pat(&mut self, pat: &mut P<ast::Pat>) {
}
visit_clobber(pat, |mut pat| match mem::replace(&mut pat.kind, PatKind::Wild) {
PatKind::MacCall(mac) => {
self.collect_bang(mac, pat.span, AstFragmentKind::Pat).make_pat()
}
PatKind::MacCall(mac) => self.collect_bang(mac, AstFragmentKind::Pat).make_pat(),
_ => unreachable!(),
});
}
@ -1354,12 +1350,10 @@ fn visit_pat(&mut self, pat: &mut P<ast::Pat>) {
.make_stmts();
}
let span = stmt.span;
match self.take_stmt_bang(stmt) {
Ok((add_semicolon, mac, attrs)) => {
self.check_attributes(&attrs, &mac);
let mut stmts =
self.collect_bang(mac, span, AstFragmentKind::Stmts).make_stmts();
let mut stmts = self.collect_bang(mac, AstFragmentKind::Stmts).make_stmts();
// If this is a macro invocation with a semicolon, then apply that
// semicolon to the final statement produced by expansion.
@ -1427,7 +1421,7 @@ fn visit_block(&mut self, block: &mut P<Block>) {
item.attrs = attrs;
item.and_then(|item| match item.kind {
ItemKind::MacCall(mac) => {
self.collect_bang(mac, span, AstFragmentKind::Items).make_items()
self.collect_bang(mac, AstFragmentKind::Items).make_items()
}
_ => unreachable!(),
})
@ -1536,9 +1530,9 @@ fn visit_block(&mut self, block: &mut P<Block>) {
ast::AssocItemKind::MacCall(ref mac) => {
self.check_attributes(&item.attrs, &mac);
item.and_then(|item| match item.kind {
ast::AssocItemKind::MacCall(mac) => self
.collect_bang(mac, item.span, AstFragmentKind::TraitItems)
.make_trait_items(),
ast::AssocItemKind::MacCall(mac) => {
self.collect_bang(mac, AstFragmentKind::TraitItems).make_trait_items()
}
_ => unreachable!(),
})
}
@ -1561,9 +1555,9 @@ fn visit_block(&mut self, block: &mut P<Block>) {
ast::AssocItemKind::MacCall(ref mac) => {
self.check_attributes(&item.attrs, &mac);
item.and_then(|item| match item.kind {
ast::AssocItemKind::MacCall(mac) => self
.collect_bang(mac, item.span, AstFragmentKind::ImplItems)
.make_impl_items(),
ast::AssocItemKind::MacCall(mac) => {
self.collect_bang(mac, AstFragmentKind::ImplItems).make_impl_items()
}
_ => unreachable!(),
})
}
@ -1580,9 +1574,7 @@ fn visit_ty(&mut self, ty: &mut P<ast::Ty>) {
};
visit_clobber(ty, |mut ty| match mem::replace(&mut ty.kind, ast::TyKind::Err) {
ast::TyKind::MacCall(mac) => {
self.collect_bang(mac, ty.span, AstFragmentKind::Ty).make_ty()
}
ast::TyKind::MacCall(mac) => self.collect_bang(mac, AstFragmentKind::Ty).make_ty(),
_ => unreachable!(),
});
}
@ -1607,9 +1599,9 @@ fn flat_map_foreign_item(
ast::ForeignItemKind::MacCall(ref mac) => {
self.check_attributes(&foreign_item.attrs, &mac);
foreign_item.and_then(|item| match item.kind {
ast::ForeignItemKind::MacCall(mac) => self
.collect_bang(mac, item.span, AstFragmentKind::ForeignItems)
.make_foreign_items(),
ast::ForeignItemKind::MacCall(mac) => {
self.collect_bang(mac, AstFragmentKind::ForeignItems).make_foreign_items()
}
_ => unreachable!(),
})
}