feat: support underscore expressions

This commit is contained in:
Caleb Cartwright 2020-11-27 21:18:39 -06:00 committed by Caleb Cartwright
parent 5c0673c371
commit 4d9fa00fd5
4 changed files with 23 additions and 1 deletions

View File

@ -384,6 +384,7 @@ pub(crate) fn format_expr(
}
}
ast::ExprKind::Await(_) => rewrite_chain(expr, context, shape),
ast::ExprKind::Underscore => Some("_".to_owned()),
ast::ExprKind::Err => None,
};

View File

@ -504,7 +504,8 @@ pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr
| ast::ExprKind::Ret(..)
| ast::ExprKind::Tup(..)
| ast::ExprKind::Type(..)
| ast::ExprKind::Yield(None) => false,
| ast::ExprKind::Yield(None)
| ast::ExprKind::Underscore => false,
}
}

View File

@ -567,3 +567,13 @@ fn foo() {
}
.await;
}
fn underscore() {
_= 1;
_;
[ _,a,_ ] = [1, 2, 3];
(a, _) = (8, 9);
TupleStruct( _, a) = TupleStruct(2, 2);
let _ : usize = foo(_, _);
}

View File

@ -659,3 +659,13 @@ fn foo() {
}
.await;
}
fn underscore() {
_ = 1;
_;
[_, a, _] = [1, 2, 3];
(a, _) = (8, 9);
TupleStruct(_, a) = TupleStruct(2, 2);
let _: usize = foo(_, _);
}