preserve span when evaluating mir::ConstOperand

This commit is contained in:
Ralf Jung 2024-03-14 08:09:21 +01:00
parent 30f74ff0dc
commit 48f2f0d725
21 changed files with 192 additions and 7 deletions

View file

@ -393,7 +393,9 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> {
}
}
Operand::Constant(box constant) => {
if let Ok(constant) = self.ecx.eval_mir_constant(&constant.const_, None, None) {
if let Ok(constant) =
self.ecx.eval_mir_constant(&constant.const_, Some(constant.span), None)
{
self.assign_constant(state, place, constant, &[]);
}
}

View file

@ -416,7 +416,8 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
match rhs {
// If we expect `lhs ?= A`, we have an opportunity if we assume `constant == A`.
Operand::Constant(constant) => {
let constant = self.ecx.eval_mir_constant(&constant.const_, None, None).ok()?;
let constant =
self.ecx.eval_mir_constant(&constant.const_, Some(constant.span), None).ok()?;
self.process_constant(bb, lhs, constant, state);
}
// Transfer the conditions on the copied rhs.