File tree 3 files changed +18
-6
lines changed
3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -1316,9 +1316,15 @@ impl Expr {
1316
1316
}
1317
1317
1318
1318
pub fn precedence ( & self ) -> ExprPrecedence {
1319
- match self . kind {
1319
+ match & self . kind {
1320
+ ExprKind :: Closure ( closure) => {
1321
+ match closure. fn_decl . output {
1322
+ FnRetTy :: Default ( _) => ExprPrecedence :: Jump ,
1323
+ FnRetTy :: Ty ( _) => ExprPrecedence :: Unambiguous ,
1324
+ }
1325
+ }
1326
+
1320
1327
ExprKind :: Break ( ..)
1321
- | ExprKind :: Closure ( ..)
1322
1328
| ExprKind :: Continue ( ..)
1323
1329
| ExprKind :: Ret ( ..)
1324
1330
| ExprKind :: Yield ( ..)
Original file line number Diff line number Diff line change @@ -1696,9 +1696,15 @@ pub struct Expr<'hir> {
1696
1696
1697
1697
impl Expr < ' _ > {
1698
1698
pub fn precedence ( & self ) -> ExprPrecedence {
1699
- match self . kind {
1699
+ match & self . kind {
1700
+ ExprKind :: Closure ( closure) => {
1701
+ match closure. fn_decl . output {
1702
+ FnRetTy :: DefaultReturn ( _) => ExprPrecedence :: Jump ,
1703
+ FnRetTy :: Return ( _) => ExprPrecedence :: Unambiguous ,
1704
+ }
1705
+ }
1706
+
1700
1707
ExprKind :: Break ( ..)
1701
- | ExprKind :: Closure { .. }
1702
1708
| ExprKind :: Continue ( ..)
1703
1709
| ExprKind :: Ret ( ..)
1704
1710
| ExprKind :: Yield ( ..)
@@ -1741,7 +1747,7 @@ impl Expr<'_> {
1741
1747
| ExprKind :: Type ( ..)
1742
1748
| ExprKind :: Err ( _) => ExprPrecedence :: Unambiguous ,
1743
1749
1744
- ExprKind :: DropTemps ( ref expr, ..) => expr. precedence ( ) ,
1750
+ ExprKind :: DropTemps ( expr, ..) => expr. precedence ( ) ,
1745
1751
}
1746
1752
}
1747
1753
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ static EXPRS: &[&str] = &[
74
74
"|| return break 2" ,
75
75
"return break || 2" ,
76
76
// Closures with a return type have especially high precedence.
77
- "( || -> T { x }) + 1" , // FIXME: no parenthesis needed.
77
+ "|| -> T { x } + 1" ,
78
78
"(|| { x }) + 1" ,
79
79
// These mean different things.
80
80
"if let _ = true && false {}" ,
You can’t perform that action at this time.
0 commit comments