Temporary fix rustfmt for let-else
This commit is contained in:
parent
20ddab3def
commit
a603756cc5
3 changed files with 11 additions and 4 deletions
|
@ -48,7 +48,7 @@ impl Rewrite for ast::Local {
|
|||
|
||||
skip_out_of_file_lines_range!(context, self.span);
|
||||
|
||||
if contains_skip(&self.attrs) {
|
||||
if contains_skip(&self.attrs) || matches!(self.kind, ast::LocalKind::InitElse(..)) {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ impl Rewrite for ast::Local {
|
|||
infix.push_str(&rewrite);
|
||||
}
|
||||
|
||||
if self.init.is_some() {
|
||||
if self.kind.init().is_some() {
|
||||
infix.push_str(" =");
|
||||
}
|
||||
|
||||
|
@ -106,11 +106,12 @@ impl Rewrite for ast::Local {
|
|||
|
||||
result.push_str(&infix);
|
||||
|
||||
if let Some(ref ex) = self.init {
|
||||
if let Some((init, _els)) = self.kind.init_else_opt() {
|
||||
// 1 = trailing semicolon;
|
||||
let nested_shape = shape.sub_width(1)?;
|
||||
|
||||
result = rewrite_assign_rhs(context, result, &**ex, nested_shape)?;
|
||||
result = rewrite_assign_rhs(context, result, init, nested_shape)?;
|
||||
// todo else
|
||||
}
|
||||
|
||||
result.push(';');
|
||||
|
|
3
tests/source/let_else.rs
Normal file
3
tests/source/let_else.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
let Some(1) = Some(1) else { return };
|
||||
}
|
3
tests/target/let_else.rs
Normal file
3
tests/target/let_else.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
let Some(1) = Some(1) else { return };
|
||||
}
|
Loading…
Reference in a new issue