about summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src
diff options
context:
space:
mode:
authorLukas Markeffsky <@>2023-07-05 20:44:24 +0200
committerLukas Markeffsky <@>2023-07-06 13:15:05 +0000
commit7aa5f39d3b55eb746d9d64244ed5343874807ac4 (patch)
treeaaa24ada6be615e676ccb6046bf876f95a37dae0 /compiler/rustc_ty_utils/src
parente3de14e46396694e48bfecf963fe9fa8e8a90d86 (diff)
downloadrust-7aa5f39d3b55eb746d9d64244ed5343874807ac4.tar.gz
rust-7aa5f39d3b55eb746d9d64244ed5343874807ac4.zip
add helper methods for accessing struct tail
Diffstat (limited to 'compiler/rustc_ty_utils/src')
-rw-r--r--compiler/rustc_ty_utils/src/layout.rs11
-rw-r--r--compiler/rustc_ty_utils/src/ty.rs2
2 files changed, 3 insertions, 10 deletions
diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs
index 0dbe6265522..b67cd96a734 100644
--- a/compiler/rustc_ty_utils/src/layout.rs
+++ b/compiler/rustc_ty_utils/src/layout.rs
@@ -480,7 +480,7 @@ fn layout_of_uncached<'tcx>(
                     .any(|(i, v)| v.discr != ty::VariantDiscr::Relative(i.as_u32()));
 
             let maybe_unsized = def.is_struct()
-                && def.non_enum_variant().fields.raw.last().is_some_and(|last_field| {
+                && def.non_enum_variant().tail_opt().is_some_and(|last_field| {
                     let param_env = tcx.param_env(def.did());
                     !tcx.type_of(last_field.did).subst_identity().is_sized(tcx, param_env)
                 });
@@ -502,14 +502,7 @@ fn layout_of_uncached<'tcx>(
             // If the struct tail is sized and can be unsized, check that unsizing doesn't move the fields around.
             if cfg!(debug_assertions)
                 && maybe_unsized
-                && def
-                    .non_enum_variant()
-                    .fields
-                    .raw
-                    .last()
-                    .unwrap()
-                    .ty(tcx, substs)
-                    .is_sized(tcx, cx.param_env)
+                && def.non_enum_variant().tail().ty(tcx, substs).is_sized(tcx, cx.param_env)
             {
                 let mut variants = variants;
                 let tail_replacement = cx.layout_of(Ty::new_slice(tcx, tcx.types.u8)).unwrap();
diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs
index 466616cd22b..6e5c50492c6 100644
--- a/compiler/rustc_ty_utils/src/ty.rs
+++ b/compiler/rustc_ty_utils/src/ty.rs
@@ -103,7 +103,7 @@ fn adt_sized_constraint(tcx: TyCtxt<'_>, def_id: DefId) -> &[Ty<'_>] {
     let result = tcx.mk_type_list_from_iter(
         def.variants()
             .iter()
-            .filter_map(|v| v.fields.raw.last())
+            .filter_map(|v| v.tail_opt())
             .flat_map(|f| sized_constraint_for_ty(tcx, def, tcx.type_of(f.did).subst_identity())),
     );