Skip to content

Commit 490d479

Browse files
committed
Disregard bailouts inside of closure bodies
1 parent ee1a762 commit 490d479

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

src/fixup.rs

+1-20
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::classify;
22
use crate::precedence::Precedence;
33
use syn::{
44
Expr, ExprBreak, ExprRange, ExprRawAddr, ExprReference, ExprReturn, ExprUnary, ExprYield,
5-
ReturnType,
65
};
76

87
#[derive(Copy, Clone)]
@@ -595,25 +594,7 @@ fn scan_right(
595594
_ => Scan::Consume,
596595
},
597596
},
598-
// false positive: https://github.com/rust-lang/rust/issues/117304
599-
#[cfg_attr(all(test, exhaustive), allow(non_exhaustive_omitted_patterns))]
600-
Expr::Closure(e) => {
601-
if matches!(e.output, ReturnType::Default)
602-
|| matches!(&*e.body, Expr::Block(body) if body.attrs.is_empty() && body.label.is_none())
603-
{
604-
if bailout_offset >= 1 {
605-
return Scan::Consume;
606-
}
607-
let right_fixup =
608-
fixup.rightmost_subexpression_fixup(false, false, Precedence::Jump);
609-
match scan_right(&e.body, right_fixup, Precedence::Jump, 1, 1) {
610-
Scan::Fail => Scan::Bailout,
611-
Scan::Bailout | Scan::Consume => Scan::Consume,
612-
}
613-
} else {
614-
Scan::Consume
615-
}
616-
}
597+
Expr::Closure(_) => Scan::Consume,
617598
Expr::Let(e) => {
618599
if bailout_offset >= 1 {
619600
return Scan::Consume;

tests/test_precedence.rs

+4
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,10 @@ fn test_permutations() -> ExitCode {
872872
parsed,
873873
);
874874
}
875+
if pretty.contains("(||") {
876+
// https://github.com/dtolnay/prettyplease/issues/99
877+
return;
878+
}
875879
let no_paren = pretty.replace(['(', ')'], "");
876880
if pretty != no_paren {
877881
if let Ok(mut parsed2) = syn::parse_file(&no_paren) {

0 commit comments

Comments
 (0)