Skip to content

Commit

Permalink
Fix rustfmt according to review
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadrieril committed Nov 24, 2024
1 parent 962c014 commit 483f9e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tools/rustfmt/src/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,9 @@ impl Rewrite for Pat {
.max_width_error(shape.width, self.span)?,
)
.map(|inner_pat| format!("({})", inner_pat)),
PatKind::Err(_) => Err(RewriteError::Unknown),
PatKind::Guard(..) => Ok(context.snippet(self.span).to_string()),
PatKind::Deref(_) => Err(RewriteError::Unknown),
PatKind::Guard(..) => Err(RewriteError::Unknown),
PatKind::Err(_) => Err(RewriteError::Unknown),
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/tools/rustfmt/tests/target/guard_patterns.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![feature(guard_patterns)]

fn main() {
match user.subscription_plan() {
(Plan::Regular if user.credit() >= 100) | (Plan::Premium if user.credit() >= 80) => {
// Complete the transaction.
}
_ => {
// The user doesn't have enough credit, return an error message.
}
}
}

0 comments on commit 483f9e2

Please sign in to comment.