simplified tail_expr
This commit is contained in:
parent
4896ffb65c
commit
ee862cec10
@ -1476,25 +1476,21 @@ fn make_body(
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let mut tail_expr = match elements.pop() {
|
let mut tail_expr = match &elements.last() {
|
||||||
Some(element) => match element {
|
Some(element) => match element {
|
||||||
syntax::NodeOrToken::Node(node) => {
|
syntax::NodeOrToken::Node(node) if ast::Expr::can_cast(node.kind()) => {
|
||||||
ast::Expr::cast(node.clone()).or_else(|| {
|
ast::Expr::cast(node.clone())
|
||||||
elements.push(syntax::NodeOrToken::Node(node));
|
|
||||||
None
|
|
||||||
})
|
|
||||||
}
|
|
||||||
syntax::NodeOrToken::Token(token) if token.kind() == COMMENT => {
|
|
||||||
elements.push(syntax::NodeOrToken::Token(token));
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
if tail_expr.is_none() {
|
match tail_expr {
|
||||||
match fun.outliving_locals.as_slice() {
|
Some(_) => {
|
||||||
|
elements.pop();
|
||||||
|
}
|
||||||
|
None => match fun.outliving_locals.as_slice() {
|
||||||
[] => {}
|
[] => {}
|
||||||
[var] => {
|
[var] => {
|
||||||
tail_expr = Some(path_expr_from_local(ctx, var.local));
|
tail_expr = Some(path_expr_from_local(ctx, var.local));
|
||||||
@ -1504,8 +1500,8 @@ fn make_body(
|
|||||||
let expr = make::expr_tuple(exprs);
|
let expr = make::expr_tuple(exprs);
|
||||||
tail_expr = Some(expr);
|
tail_expr = Some(expr);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
|
|
||||||
let body_indent = IndentLevel(1);
|
let body_indent = IndentLevel(1);
|
||||||
let elements: Vec<SyntaxElement> = elements
|
let elements: Vec<SyntaxElement> = elements
|
||||||
|
Loading…
Reference in New Issue
Block a user