about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/traits
diff options
context:
space:
mode:
authorDavid Wood <david.wood2@arm.com>2024-12-04 12:51:59 +0000
committerDavid Wood <david.wood2@arm.com>2025-02-24 08:08:23 +0000
commit5afa6a111bcf8552b8de15d1aec060580add640f (patch)
tree953d44ec9b3653353dd990645134d929fe8082e2 /compiler/rustc_codegen_ssa/src/traits
parentad27045c31a9f37ad7d44ca2a403de52d1a896d3 (diff)
ssa/mono: deduplicate `type_has_metadata`
The implementation of the `type_has_metadata` function is duplicated in
`rustc_codegen_ssa` and `rustc_monomorphize`, so move this to
`rustc_middle`.
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/traits')
-rw-r--r--compiler/rustc_codegen_ssa/src/traits/type_.rs15
1 files changed, 1 insertions, 14 deletions
diff --git a/compiler/rustc_codegen_ssa/src/traits/type_.rs b/compiler/rustc_codegen_ssa/src/traits/type_.rs
index c178ebc596e..fbd927d0d66 100644
--- a/compiler/rustc_codegen_ssa/src/traits/type_.rs
+++ b/compiler/rustc_codegen_ssa/src/traits/type_.rs
@@ -1,7 +1,7 @@
 use rustc_abi::{AddressSpace, Float, Integer, Reg};
 use rustc_middle::bug;
+use rustc_middle::ty::Ty;
 use rustc_middle::ty::layout::{HasTyCtxt, HasTypingEnv, TyAndLayout};
-use rustc_middle::ty::{self, Ty};
 use rustc_target::callconv::{ArgAbi, CastTarget, FnAbi};
 
 use super::BackendTypes;
@@ -84,19 +84,6 @@ pub trait DerivedTypeCodegenMethods<'tcx>:
     fn type_is_freeze(&self, ty: Ty<'tcx>) -> bool {
         ty.is_freeze(self.tcx(), self.typing_env())
     }
-
-    fn type_has_metadata(&self, ty: Ty<'tcx>) -> bool {
-        if ty.is_sized(self.tcx(), self.typing_env()) {
-            return false;
-        }
-
-        let tail = self.tcx().struct_tail_for_codegen(ty, self.typing_env());
-        match tail.kind() {
-            ty::Foreign(..) => false,
-            ty::Str | ty::Slice(..) | ty::Dynamic(..) => true,
-            _ => bug!("unexpected unsized tail: {:?}", tail),
-        }
-    }
 }
 
 impl<'tcx, T> DerivedTypeCodegenMethods<'tcx> for T where