fix 2190; add test for "replace if let with match"

This commit is contained in:
Felix Kohlgrüber 2019-11-20 19:01:06 +01:00
parent 7a5fd1f3f3
commit bcb2ea912b
3 changed files with 58 additions and 5 deletions

View file

@ -38,9 +38,6 @@ fn prev_tokens(token: SyntaxToken) -> impl Iterator<Item = SyntaxToken> {
pub fn extract_trivial_expression(expr: &ast::BlockExpr) -> Option<ast::Expr> {
let block = expr.block()?;
let expr = block.expr()?;
if expr.syntax().text().contains_char('\n') {
return None;
}
let non_trivial_children = block.syntax().children().filter(|it| match it.kind() {
WHITESPACE | T!['{'] | T!['}'] => false,
_ => it != expr.syntax(),