mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 21:05:08 +00:00
Format let-else with rustfmt nightly (#5461)
Support for `let…else` formatting was just merged to nightly (rust-lang/rust#113225). Rerun `cargo fmt` with Rust nightly 2023-07-02 to pick this up. Followup to #939. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
parent
c8b9a46e2b
commit
df13e69c3c
105 changed files with 782 additions and 362 deletions
|
@ -31,14 +31,30 @@ struct Rule {
|
|||
|
||||
pub(crate) fn map_codes(func: &ItemFn) -> syn::Result<TokenStream> {
|
||||
let Some(last_stmt) = func.block.stmts.last() else {
|
||||
return Err(Error::new(func.block.span(), "expected body to end in an expression"));
|
||||
return Err(Error::new(
|
||||
func.block.span(),
|
||||
"expected body to end in an expression",
|
||||
));
|
||||
};
|
||||
let Stmt::Expr(Expr::Call(ExprCall { args: some_args, .. }), _) = last_stmt else {
|
||||
return Err(Error::new(last_stmt.span(), "expected last expression to be `Some(match (..) { .. })`"));
|
||||
let Stmt::Expr(
|
||||
Expr::Call(ExprCall {
|
||||
args: some_args, ..
|
||||
}),
|
||||
_,
|
||||
) = last_stmt
|
||||
else {
|
||||
return Err(Error::new(
|
||||
last_stmt.span(),
|
||||
"expected last expression to be `Some(match (..) { .. })`",
|
||||
));
|
||||
};
|
||||
let mut some_args = some_args.into_iter();
|
||||
let (Some(Expr::Match(ExprMatch { arms, .. })), None) = (some_args.next(), some_args.next()) else {
|
||||
return Err(Error::new(last_stmt.span(), "expected last expression to be `Some(match (..) { .. })`"));
|
||||
let (Some(Expr::Match(ExprMatch { arms, .. })), None) = (some_args.next(), some_args.next())
|
||||
else {
|
||||
return Err(Error::new(
|
||||
last_stmt.span(),
|
||||
"expected last expression to be `Some(match (..) { .. })`",
|
||||
));
|
||||
};
|
||||
|
||||
// Map from: linter (e.g., `Flake8Bugbear`) to rule code (e.g.,`"002"`) to rule data (e.g.,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue