File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
compiler/rustc_mir_transform/src Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -889,6 +889,21 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
889
889
StatementKind :: StorageLive ( local) => {
890
890
Self :: remove_const ( & mut self . ecx , local) ;
891
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
+ // StorageDead(x);
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.
892
907
_ => { }
893
908
}
894
909
}
You can’t perform that action at this time.
0 commit comments