Skip to content

Commit fec9c70

Browse files
committed
Optimize MIR only if transmutations are correct
1 parent 5aab62d commit fec9c70

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

  • compiler/rustc_mir_transform/src

compiler/rustc_mir_transform/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,11 @@ fn inner_optimized_mir(tcx: TyCtxt<'_>, did: LocalDefId) -> Body<'_> {
827827
return body;
828828
}
829829

830+
// If check_transmutes found faulty transmutes, then return early to avoid ICEs during optimizations
831+
if !tcx.is_typeck_child(did.to_def_id()) && tcx.check_transmutes(did).is_err() {
832+
return body;
833+
}
834+
830835
run_optimization_passes(tcx, &mut body);
831836

832837
body

0 commit comments

Comments
 (0)