diff options
| author | David Wood <david.wood2@arm.com> | 2024-12-04 12:51:59 +0000 |
|---|---|---|
| committer | David Wood <david.wood2@arm.com> | 2025-02-24 08:08:23 +0000 |
| commit | 5afa6a111bcf8552b8de15d1aec060580add640f (patch) | |
| tree | 953d44ec9b3653353dd990645134d929fe8082e2 /compiler/rustc_monomorphize | |
| parent | ad27045c31a9f37ad7d44ca2a403de52d1a896d3 (diff) | |
| download | rust-5afa6a111bcf8552b8de15d1aec060580add640f.tar.gz rust-5afa6a111bcf8552b8de15d1aec060580add640f.zip | |
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_monomorphize')
| -rw-r--r-- | compiler/rustc_monomorphize/src/collector.rs | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index d7cb8f18f82..f8af6837fc2 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -1043,18 +1043,7 @@ fn find_vtable_types_for_unsizing<'tcx>( ) -> (Ty<'tcx>, Ty<'tcx>) { let ptr_vtable = |inner_source: Ty<'tcx>, inner_target: Ty<'tcx>| { let typing_env = ty::TypingEnv::fully_monomorphized(); - let type_has_metadata = |ty: Ty<'tcx>| -> bool { - if ty.is_sized(tcx.tcx, typing_env) { - return false; - } - let tail = tcx.struct_tail_for_codegen(ty, typing_env); - match tail.kind() { - ty::Foreign(..) => false, - ty::Str | ty::Slice(..) | ty::Dynamic(..) => true, - _ => bug!("unexpected unsized tail: {:?}", tail), - } - }; - if type_has_metadata(inner_source) { + if tcx.type_has_metadata(inner_source, typing_env) { (inner_source, inner_target) } else { tcx.struct_lockstep_tails_for_codegen(inner_source, inner_target, typing_env) |
