We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e11e408 commit f74695bCopy full SHA for f74695b
compiler/rustc_mir_transform/src/const_prop.rs
@@ -889,6 +889,21 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
889
StatementKind::StorageLive(local) => {
890
Self::remove_const(&mut self.ecx, local);
891
}
892
+ // We do not need to mark dead locals as such. For `FullConstProp` locals,
893
+ // this allows to propagate the single assigned value in this case:
894
+ // ```
895
+ // let x = SOME_CONST;
896
+ // if a {
897
+ // f(copy x);
898
+ // StorageDead(x);
899
+ // } else {
900
+ // g(copy x);
901
902
+ // }
903
904
+ //
905
+ // This may propagate a constant where the local would be uninit or dead.
906
+ // In both cases, this does not matter, as those reads would be UB anyway.
907
_ => {}
908
909
0 commit comments