Make utils::remove_blocks non-recursive
This commit is contained in:
@@ -873,12 +873,11 @@ pub fn is_automatically_derived(attrs: &[ast::Attribute]) -> bool {
|
|||||||
///
|
///
|
||||||
/// Ie. `x`, `{ x }` and `{{{{ x }}}}` all give `x`. `{ x; y }` and `{}` return
|
/// Ie. `x`, `{ x }` and `{{{{ x }}}}` all give `x`. `{ x; y }` and `{}` return
|
||||||
/// themselves.
|
/// themselves.
|
||||||
pub fn remove_blocks<'tcx>(expr: &'tcx Expr<'tcx>) -> &'tcx Expr<'tcx> {
|
pub fn remove_blocks<'tcx>(mut expr: &'tcx Expr<'tcx>) -> &'tcx Expr<'tcx> {
|
||||||
if let ExprKind::Block(ref block, _) = expr.kind {
|
while let ExprKind::Block(ref block, ..) = expr.kind {
|
||||||
if block.stmts.is_empty() {
|
match (block.stmts.is_empty(), block.expr.as_ref()) {
|
||||||
if let Some(ref expr) = block.expr {
|
(true, Some(e)) => expr = e,
|
||||||
return remove_blocks(expr);
|
_ => break,
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
expr
|
expr
|
||||||
|
|||||||
Reference in New Issue
Block a user