Don't turn pnc apply dbg into DbgStmt

This commit is contained in:
Joshua Warner 2025-01-11 10:37:28 -08:00
parent 6d324590da
commit 6d2b635dbc
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
7 changed files with 103 additions and 82 deletions

View file

@ -3166,40 +3166,6 @@ fn stmts_to_defs<'a>(
last_expr = Some(Loc::at(sp_stmt.item.region, e));
// don't re-process the rest of the statements; they got consumed by the dbg expr
break;
} else {
defs.push_value_def(
ValueDef::Stmt(arena.alloc(Loc::at(sp_stmt.item.region, e))),
sp_stmt.item.region,
sp_stmt.before,
&[],
);
}
} else if let Expr::PncApply(
Loc {
value: Expr::Dbg, ..
},
args,
) = e
{
if let Some((first, extra_args)) = args.items.split_first() {
let rest = stmts_to_expr(&stmts[i + 1..], arena)?;
let e = Expr::DbgStmt {
first,
extra_args,
continuation: arena.alloc(rest),
pnc_style: true,
};
let e = if sp_stmt.before.is_empty() {
e
} else {
arena.alloc(e).before(sp_stmt.before)
};
last_expr = Some(Loc::at(sp_stmt.item.region, e));
// don't re-process the rest of the statements; they got consumed by the dbg expr
break;
} else {

View file

@ -843,35 +843,6 @@ fn fold_defs<'a>(
new_defs.push_value_def(vd, Region::zero(), &[], &[]);
}
}
ValueDef::Stmt(&Loc {
value:
Expr::PncApply(
&Loc {
value: Expr::Dbg, ..
},
args,
),
..
}) => {
if let Some((first, extra_args)) = args.items.split_first() {
let rest = fold_defs(arena, defs, final_expr);
let new_final = Expr::DbgStmt {
first,
extra_args,
continuation: arena.alloc(Loc::at_zero(rest)),
pnc_style: true,
};
if new_defs.is_empty() {
return new_final;
}
return Expr::Defs(
arena.alloc(new_defs),
arena.alloc(Loc::at_zero(new_final)),
);
} else {
new_defs.push_value_def(vd, Region::zero(), &[], &[]);
}
}
_ => {
new_defs.push_value_def(vd, Region::zero(), &[], &[]);
}