Merge pull request #7296 from smores56/proper-try-keyword

Proper `try` keyword
This commit is contained in:
Sam Mohr 2024-12-05 01:38:22 -08:00 committed by GitHub
commit 193c23bac8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 1036 additions and 521 deletions

View file

@ -67,10 +67,6 @@ 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, _) => {
let apply_needs_parens = parens == Parens::InApply;
@ -201,6 +197,13 @@ impl<'a> Formattable for Expr<'a> {
LowLevelDbg(_, _, _) => unreachable!(
"LowLevelDbg should only exist after desugaring, not during formatting"
),
Try => {
buf.indent(indent);
buf.push_str("try");
}
LowLevelTry(_) => unreachable!(
"LowLevelTry should only exist after desugaring, not during formatting"
),
Return(return_value, after_return) => {
fmt_return(buf, return_value, after_return, parens, newlines, indent);
}
@ -367,6 +370,9 @@ pub fn expr_is_multiline(me: &Expr<'_>, comments_only: bool) -> bool {
| Expr::Crash
| Expr::Dbg
| Expr::Try => false,
Expr::LowLevelTry(_) => {
unreachable!("LowLevelTry should only exist after desugaring, not during formatting")
}
Expr::RecordAccess(inner, _)
| Expr::TupleAccess(inner, _)