Implement the try keyword with desugaring

This commit is contained in:
Sam Mohr 2024-11-01 17:34:11 -07:00
parent 69dd8d77f3
commit 308defac46
No known key found for this signature in database
GPG key ID: EA41D161A3C1BC99
9 changed files with 196 additions and 10 deletions

View file

@ -48,7 +48,8 @@ impl<'a> Formattable for Expr<'a> {
| Tag(_)
| OpaqueRef(_)
| Crash
| Dbg => false,
| Dbg
| Try => false,
RecordAccess(inner, _) | TupleAccess(inner, _) | TrySuffix { expr: inner, .. } => {
inner.is_multiline()
@ -199,6 +200,10 @@ impl<'a> Formattable for Expr<'a> {
buf.indent(indent);
buf.push_str("crash");
}
Try => {
buf.indent(indent);
buf.push_str("try");
}
Apply(loc_expr, loc_args, _) => {
// Sadly this assertion fails in practice. The fact that the parser produces code like this is going to
// confuse the formatter, because it depends on being able to "see" spaces that logically come before the inner