Skip to content

Commit 483f9e2

Browse files
committed
Fix rustfmt according to review
1 parent 962c014 commit 483f9e2

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Diff for: src/tools/rustfmt/src/patterns.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,9 @@ impl Rewrite for Pat {
339339
.max_width_error(shape.width, self.span)?,
340340
)
341341
.map(|inner_pat| format!("({})", inner_pat)),
342-
PatKind::Err(_) => Err(RewriteError::Unknown),
342+
PatKind::Guard(..) => Ok(context.snippet(self.span).to_string()),
343343
PatKind::Deref(_) => Err(RewriteError::Unknown),
344-
PatKind::Guard(..) => Err(RewriteError::Unknown),
344+
PatKind::Err(_) => Err(RewriteError::Unknown),
345345
}
346346
}
347347
}

Diff for: src/tools/rustfmt/tests/target/guard_patterns.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![feature(guard_patterns)]
2+
3+
fn main() {
4+
match user.subscription_plan() {
5+
(Plan::Regular if user.credit() >= 100) | (Plan::Premium if user.credit() >= 80) => {
6+
// Complete the transaction.
7+
}
8+
_ => {
9+
// The user doesn't have enough credit, return an error message.
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)