Document handling of StorageDead.
This commit is contained in:
parent
e11e4081df
commit
f74695b010
1 changed files with 15 additions and 0 deletions
|
@ -889,6 +889,21 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
|
||||||
StatementKind::StorageLive(local) => {
|
StatementKind::StorageLive(local) => {
|
||||||
Self::remove_const(&mut self.ecx, local);
|
Self::remove_const(&mut self.ecx, local);
|
||||||
}
|
}
|
||||||
|
// We do not need to mark dead locals as such. For `FullConstProp` locals,
|
||||||
|
// this allows to propagate the single assigned value in this case:
|
||||||
|
// ```
|
||||||
|
// let x = SOME_CONST;
|
||||||
|
// if a {
|
||||||
|
// f(copy x);
|
||||||
|
// StorageDead(x);
|
||||||
|
// } else {
|
||||||
|
// g(copy x);
|
||||||
|
// StorageDead(x);
|
||||||
|
// }
|
||||||
|
// ```
|
||||||
|
//
|
||||||
|
// This may propagate a constant where the local would be uninit or dead.
|
||||||
|
// In both cases, this does not matter, as those reads would be UB anyway.
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue