Skip to content

Commit

Permalink
Merge pull request #1700 from dtolnay/leadinglet
Browse files Browse the repository at this point in the history
Parenthesize leading Expr::Let in statement
  • Loading branch information
dtolnay authored Jul 7, 2024
2 parents 21b92f2 + f6cd75f commit 7276662
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/fixup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ impl FixupContext {
/// examples.
pub fn would_cause_statement_boundary(self, expr: &Expr) -> bool {
(self.leftmost_subexpression_in_stmt && !classify::requires_semi_to_be_stmt(expr))
|| ((self.stmt || self.leftmost_subexpression_in_stmt) && matches!(expr, Expr::Let(_)))
|| (self.leftmost_subexpression_in_match_arm
&& !classify::requires_comma_to_be_match_arm(expr))
}
Expand Down
1 change: 1 addition & 0 deletions tests/test_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ fn test_fixup() {
quote! { (..) = () },
quote! { (..) += () },
quote! { (1 < 2) == (3 < 4) },
quote! { { (let _ = ()) } },
] {
let original: Expr = syn::parse2(tokens).unwrap();

Expand Down

0 comments on commit 7276662

Please sign in to comment.