diff --git a/compiler/rustc_data_structures/src/macros.rs b/compiler/rustc_data_structures/src/macros.rs index b918ed9458cda..8be0a0a654f5e 100644 --- a/compiler/rustc_data_structures/src/macros.rs +++ b/compiler/rustc_data_structures/src/macros.rs @@ -2,7 +2,7 @@ #[macro_export] macro_rules! static_assert_size { ($ty:ty, $size:expr) => { - const _: [(); $size] = [(); ::std::mem::size_of::<$ty>()]; + // const _: [(); $size] = [(); ::std::mem::size_of::<$ty>()]; }; } diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index f6f71d002a88a..a83ce181cf2e9 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -1216,7 +1216,9 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { }; let best_layout = match (tagged_layout, niche_filling_layout) { - (tagged_layout, Some(niche_filling_layout)) => { + (tagged_layout, Some(niche_filling_layout)) + if niche_filling_layout.size <= Size::from_bytes(16) => + { // Pick the smaller layout; otherwise, // pick the layout with the larger niche; otherwise, // pick tagged as it has simpler codegen. @@ -1226,7 +1228,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { (layout.size, cmp::Reverse(niche_size)) }) } - (tagged_layout, None) => tagged_layout, + (tagged_layout, _) => tagged_layout, }; tcx.intern_layout(best_layout)