Allow dbg expression inside string interpolation

This commit is contained in:
Elias Mulhall 2024-08-26 15:09:19 -04:00
parent 220bb55048
commit 9dae102603
3 changed files with 74 additions and 1 deletions

View file

@ -2478,13 +2478,19 @@ pub fn is_valid_interpolation(expr: &ast::Expr<'_>) -> bool {
// Newlines are disallowed inside interpolation, and these all require newlines
ast::Expr::DbgStmt(_, _)
| ast::Expr::LowLevelDbg(_, _, _)
| ast::Expr::Defs(_, _)
| ast::Expr::Expect(_, _)
| ast::Expr::When(_, _)
| ast::Expr::Backpassing(_, _, _)
| ast::Expr::SpaceBefore(_, _)
| ast::Expr::Str(StrLiteral::Block(_))
| ast::Expr::SpaceAfter(_, _) => false,
// Desugared dbg expression
ast::Expr::Defs(_, loc_ret) => match loc_ret.value {
ast::Expr::LowLevelDbg(_, _, continuation) => {
is_valid_interpolation(&continuation.value)
}
_ => false,
},
// These can contain subexpressions, so we need to recursively check those
ast::Expr::Dbg(expr) => is_valid_interpolation(&expr.value),
ast::Expr::Str(StrLiteral::Line(segments)) => {