diff options
| author | Florian Sextl <florian.sextl@tuwien.ac.at> | 2025-06-28 13:54:44 +0200 |
|---|---|---|
| committer | Florian Sextl <florian.sextl@tuwien.ac.at> | 2025-06-28 14:47:27 +0200 |
| commit | 1c25bfba9d5bc6e4dfc295e016aac32ff0546f97 (patch) | |
| tree | 5864939a54cf094aa9d6bfcfb9f8fa99cb406928 /compiler/rustc_ty_utils/src | |
| parent | 3d968973c9563fb19ef041145b8e0ef7bb183b85 (diff) | |
| download | rust-1c25bfba9d5bc6e4dfc295e016aac32ff0546f97.tar.gz rust-1c25bfba9d5bc6e4dfc295e016aac32ff0546f97.zip | |
move discr=varid check to layout_sanity_check
Diffstat (limited to 'compiler/rustc_ty_utils/src')
| -rw-r--r-- | compiler/rustc_ty_utils/src/layout/invariant.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/rustc_ty_utils/src/layout/invariant.rs b/compiler/rustc_ty_utils/src/layout/invariant.rs index c929de11624..4b65c05d0e9 100644 --- a/compiler/rustc_ty_utils/src/layout/invariant.rs +++ b/compiler/rustc_ty_utils/src/layout/invariant.rs @@ -277,6 +277,12 @@ pub(super) fn layout_sanity_check<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou if !variant.is_uninhabited() { assert!(idx == *untagged_variant || niche_variants.contains(&idx)); } + + // Ensure that for niche encoded tags the discriminant coincides with the variant index. + assert_eq!( + layout.ty.discriminant_for_variant(tcx, idx).unwrap().val, + u128::from(idx.as_u32()), + ); } } for variant in variants.iter() { |
