1
Fork 0

Raise precedence of closure that has explicit return type

This commit is contained in:
David Tolnay 2024-12-02 17:41:47 -08:00
parent 4df47a09a4
commit 72ac961616
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82
3 changed files with 18 additions and 6 deletions

View file

@ -1316,9 +1316,15 @@ impl Expr {
}
pub fn precedence(&self) -> ExprPrecedence {
match self.kind {
match &self.kind {
ExprKind::Closure(closure) => {
match closure.fn_decl.output {
FnRetTy::Default(_) => ExprPrecedence::Jump,
FnRetTy::Ty(_) => ExprPrecedence::Unambiguous,
}
}
ExprKind::Break(..)
| ExprKind::Closure(..)
| ExprKind::Continue(..)
| ExprKind::Ret(..)
| ExprKind::Yield(..)