diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2023-07-01 14:57:29 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2023-09-24 09:09:04 +0000 |
| commit | 33115367404c7e860853054c53e7ad613258516b (patch) | |
| tree | 05d091f17632f6d80cf1547008707ce2eab81c04 | |
| parent | 6dfa05369767d7c079618d93d8bab53415721f65 (diff) | |
| download | rust-33115367404c7e860853054c53e7ad613258516b.tar.gz rust-33115367404c7e860853054c53e7ad613258516b.zip | |
Workaround issue 112651.
| -rw-r--r-- | compiler/rustc_mir_transform/src/gvn.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index 2b96763c297..d4894d3c24d 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -96,7 +96,11 @@ fn propagate_ssa<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { for (local, rvalue, _) in ssa.assignments(body) { let value = state.insert_rvalue(rvalue).or_else(|| state.new_opaque()).unwrap(); - state.assign(local, value); + // FIXME(#112651) `rvalue` may have a subtype to `local`. We can only mark `local` as + // reusable if we have an exact type match. + if state.local_decls[local].ty == rvalue.ty(state.local_decls, tcx) { + state.assign(local, value); + } } // Stop creating opaques during replacement as it is useless. |
