Skip to content

Commit 3311536

Browse files
committed
Workaround issue 112651.
1 parent 6dfa053 commit 3311536

File tree

1 file changed

+5
-1
lines changed
  • compiler/rustc_mir_transform/src

1 file changed

+5
-1
lines changed

compiler/rustc_mir_transform/src/gvn.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ fn propagate_ssa<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
9696

9797
for (local, rvalue, _) in ssa.assignments(body) {
9898
let value = state.insert_rvalue(rvalue).or_else(|| state.new_opaque()).unwrap();
99-
state.assign(local, value);
99+
// FIXME(#112651) `rvalue` may have a subtype to `local`. We can only mark `local` as
100+
// reusable if we have an exact type match.
101+
if state.local_decls[local].ty == rvalue.ty(state.local_decls, tcx) {
102+
state.assign(local, value);
103+
}
100104
}
101105

102106
// Stop creating opaques during replacement as it is useless.

0 commit comments

Comments
 (0)