mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 13:33:50 +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
|
@ -1411,11 +1411,18 @@ impl Truthiness {
|
|||
Constant::Ellipsis => Some(true),
|
||||
Constant::Tuple(elts) => Some(!elts.is_empty()),
|
||||
},
|
||||
Expr::JoinedStr(ast::ExprJoinedStr { values, range: _range }) => {
|
||||
Expr::JoinedStr(ast::ExprJoinedStr {
|
||||
values,
|
||||
range: _range,
|
||||
}) => {
|
||||
if values.is_empty() {
|
||||
Some(false)
|
||||
} else if values.iter().any(|value| {
|
||||
let Expr::Constant(ast::ExprConstant { value: Constant::Str(string), .. } )= &value else {
|
||||
let Expr::Constant(ast::ExprConstant {
|
||||
value: Constant::Str(string),
|
||||
..
|
||||
}) = &value
|
||||
else {
|
||||
return false;
|
||||
};
|
||||
!string.is_empty()
|
||||
|
@ -1425,14 +1432,30 @@ impl Truthiness {
|
|||
None
|
||||
}
|
||||
}
|
||||
Expr::List(ast::ExprList { elts, range: _range, .. })
|
||||
| Expr::Set(ast::ExprSet { elts, range: _range })
|
||||
| Expr::Tuple(ast::ExprTuple { elts, range: _range,.. }) => Some(!elts.is_empty()),
|
||||
Expr::Dict(ast::ExprDict { keys, range: _range, .. }) => Some(!keys.is_empty()),
|
||||
Expr::List(ast::ExprList {
|
||||
elts,
|
||||
range: _range,
|
||||
..
|
||||
})
|
||||
| Expr::Set(ast::ExprSet {
|
||||
elts,
|
||||
range: _range,
|
||||
})
|
||||
| Expr::Tuple(ast::ExprTuple {
|
||||
elts,
|
||||
range: _range,
|
||||
..
|
||||
}) => Some(!elts.is_empty()),
|
||||
Expr::Dict(ast::ExprDict {
|
||||
keys,
|
||||
range: _range,
|
||||
..
|
||||
}) => Some(!keys.is_empty()),
|
||||
Expr::Call(ast::ExprCall {
|
||||
func,
|
||||
args,
|
||||
keywords, range: _range,
|
||||
keywords,
|
||||
range: _range,
|
||||
}) => {
|
||||
if let Expr::Name(ast::ExprName { id, .. }) = func.as_ref() {
|
||||
if is_iterable_initializer(id.as_str(), |id| is_builtin(id)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue