1
Fork 0

Deny braced macro invocations in let-else

This commit is contained in:
Michael Goulet 2023-12-18 02:11:55 +00:00
parent 6ae4cfbbb0
commit c1c7707238
3 changed files with 59 additions and 4 deletions

View file

@ -2,7 +2,7 @@
// Predicates on exprs and stmts that the pretty-printer and parser use
use crate::ast;
use crate::{ast, token::Delimiter};
/// Does this expression require a semicolon to be treated
/// as a statement? The negation of this: 'can this expression
@ -59,8 +59,12 @@ pub fn expr_trailing_brace(mut expr: &ast::Expr) -> Option<&ast::Expr> {
| While(..)
| ConstBlock(_) => break Some(expr),
// FIXME: These can end in `}`, but changing these would break stable code.
InlineAsm(_) | OffsetOf(_, _) | MacCall(_) | IncludedBytes(_) | FormatArgs(_) => {
MacCall(mac) => {
break (mac.args.delim == Delimiter::Brace).then_some(expr);
}
InlineAsm(_) | OffsetOf(_, _) | IncludedBytes(_) | FormatArgs(_) => {
// These should have been denied pre-expansion.
break None;
}