From 68d1fd942710eb7cb408f3dea2f6e1845f6cbe87 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Thu, 17 Oct 2024 14:46:08 -0700 Subject: [PATCH] compiler: pre-move code for fixing enum layout ICEs --- compiler/rustc_ty_utils/src/layout.rs | 5 +++-- .../src/{layout_sanity_check.rs => layout/invariant.rs} | 2 +- compiler/rustc_ty_utils/src/lib.rs | 1 - .../126966.rs => ui/layout/thaw-transmute-invalid-enum.rs} | 0 .../128870.rs => ui/layout/thaw-validate-invalid-enum.rs} | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename compiler/rustc_ty_utils/src/{layout_sanity_check.rs => layout/invariant.rs} (99%) rename tests/{crashes/126966.rs => ui/layout/thaw-transmute-invalid-enum.rs} (100%) rename tests/{crashes/128870.rs => ui/layout/thaw-validate-invalid-enum.rs} (100%) diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index afdfa2e80c1f6..db70a12a4d1c8 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -30,7 +30,8 @@ use {rustc_abi as abi, rustc_hir as hir}; use crate::errors::{ MultipleArrayFieldsSimdType, NonPrimitiveSimdType, OversizedSimdType, ZeroLengthSimdType, }; -use crate::layout_sanity_check::sanity_check_layout; + +mod invariant; pub(crate) fn provide(providers: &mut Providers) { *providers = Providers { layout_of, ..*providers }; @@ -79,7 +80,7 @@ fn layout_of<'tcx>( record_layout_for_printing(&cx, layout); } - sanity_check_layout(&cx, &layout); + invariant::partially_check_layout(&cx, &layout); Ok(layout) } diff --git a/compiler/rustc_ty_utils/src/layout_sanity_check.rs b/compiler/rustc_ty_utils/src/layout/invariant.rs similarity index 99% rename from compiler/rustc_ty_utils/src/layout_sanity_check.rs rename to compiler/rustc_ty_utils/src/layout/invariant.rs index be0a7c5ee890a..6cf114b74c13d 100644 --- a/compiler/rustc_ty_utils/src/layout_sanity_check.rs +++ b/compiler/rustc_ty_utils/src/layout/invariant.rs @@ -5,7 +5,7 @@ use rustc_middle::ty::layout::{HasTyCtxt, LayoutCx, TyAndLayout}; use rustc_target::abi::*; /// Enforce some basic invariants on layouts. -pub(super) fn sanity_check_layout<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayout<'tcx>) { +pub(super) fn partially_check_layout<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayout<'tcx>) { let tcx = cx.tcx(); // Type-level uninhabitedness should always imply ABI uninhabitedness. diff --git a/compiler/rustc_ty_utils/src/lib.rs b/compiler/rustc_ty_utils/src/lib.rs index dc5303317a8a0..8be1611bb9ac2 100644 --- a/compiler/rustc_ty_utils/src/lib.rs +++ b/compiler/rustc_ty_utils/src/lib.rs @@ -29,7 +29,6 @@ mod errors; mod implied_bounds; mod instance; mod layout; -mod layout_sanity_check; mod needs_drop; mod opaque_types; mod representability; diff --git a/tests/crashes/126966.rs b/tests/ui/layout/thaw-transmute-invalid-enum.rs similarity index 100% rename from tests/crashes/126966.rs rename to tests/ui/layout/thaw-transmute-invalid-enum.rs diff --git a/tests/crashes/128870.rs b/tests/ui/layout/thaw-validate-invalid-enum.rs similarity index 100% rename from tests/crashes/128870.rs rename to tests/ui/layout/thaw-validate-invalid-enum.rs