From dbc6f5836c798ceea7518696a1cb72b8f602df76 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Fri, 8 Aug 2025 23:11:08 +0800 Subject: [PATCH] rustc_metadata: remove unused private trait impls --- .../src/rmeta/decoder/cstore_impl.rs | 18 ------ .../rustc_metadata/src/rmeta/parameterized.rs | 7 +-- compiler/rustc_metadata/src/rmeta/table.rs | 63 ------------------- 3 files changed, 1 insertion(+), 87 deletions(-) diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index 0f3896fd9be8a..df95ed602cd36 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -74,24 +74,6 @@ impl<'a, 'tcx, T: Copy + Decodable>> ProcessQueryValue<' } } -impl<'a, 'tcx, T: Copy + Decodable>> - ProcessQueryValue<'tcx, ty::EarlyBinder<'tcx, &'tcx [T]>> - for Option> -{ - #[inline(always)] - fn process_decoded( - self, - tcx: TyCtxt<'tcx>, - err: impl Fn() -> !, - ) -> ty::EarlyBinder<'tcx, &'tcx [T]> { - ty::EarlyBinder::bind(if let Some(iter) = self { - tcx.arena.alloc_from_iter(iter) - } else { - err() - }) - } -} - impl<'a, 'tcx, T: Copy + Decodable>> ProcessQueryValue<'tcx, Option<&'tcx [T]>> for Option> { diff --git a/compiler/rustc_metadata/src/rmeta/parameterized.rs b/compiler/rustc_metadata/src/rmeta/parameterized.rs index d632e65104a7a..34180001f8044 100644 --- a/compiler/rustc_metadata/src/rmeta/parameterized.rs +++ b/compiler/rustc_metadata/src/rmeta/parameterized.rs @@ -6,7 +6,7 @@ use rustc_index::{Idx, IndexVec}; use rustc_middle::ty::{Binder, EarlyBinder}; use rustc_span::Symbol; -use crate::rmeta::{LazyArray, LazyTable, LazyValue}; +use crate::rmeta::{LazyArray, LazyValue}; pub(crate) trait ParameterizedOverTcx: 'static { type Value<'tcx>; @@ -48,10 +48,6 @@ impl ParameterizedOverTcx for LazyArray { type Value<'tcx> = LazyArray>; } -impl ParameterizedOverTcx for LazyTable { - type Value<'tcx> = LazyTable>; -} - macro_rules! trivially_parameterized_over_tcx { ($($ty:ty),+ $(,)?) => { $( @@ -154,7 +150,6 @@ parameterized_over_tcx! { rustc_middle::mir::CoroutineLayout, rustc_middle::mir::interpret::ConstAllocation, rustc_middle::ty::Clause, - rustc_middle::ty::ClauseKind, rustc_middle::ty::Const, rustc_middle::ty::ConstConditions, rustc_middle::ty::FnSig, diff --git a/compiler/rustc_metadata/src/rmeta/table.rs b/compiler/rustc_metadata/src/rmeta/table.rs index 28f406fbc9629..0671aa203993a 100644 --- a/compiler/rustc_metadata/src/rmeta/table.rs +++ b/compiler/rustc_metadata/src/rmeta/table.rs @@ -66,22 +66,6 @@ pub(super) trait FixedSizeEncoding: IsDefault { fn write_to_bytes(self, b: &mut Self::ByteArray); } -/// This implementation is not used generically, but for reading/writing -/// concrete `u32` fields in `Lazy*` structures, which may be zero. -impl FixedSizeEncoding for u32 { - type ByteArray = [u8; 4]; - - #[inline] - fn from_bytes(b: &[u8; 4]) -> Self { - Self::from_le_bytes(*b) - } - - #[inline] - fn write_to_bytes(self, b: &mut [u8; 4]) { - *b = self.to_le_bytes(); - } -} - impl FixedSizeEncoding for u64 { type ByteArray = [u8; 8]; @@ -174,14 +158,6 @@ fixed_size_enum! { } } -fixed_size_enum! { - ty::ImplPolarity { - ( Positive ) - ( Negative ) - ( Reservation ) - } -} - fixed_size_enum! { hir::Constness { ( NotConst ) @@ -306,45 +282,6 @@ impl FixedSizeEncoding for bool { } } -impl FixedSizeEncoding for Option { - type ByteArray = [u8; 1]; - - #[inline] - fn from_bytes(b: &[u8; 1]) -> Self { - match b[0] { - 0 => Some(false), - 1 => Some(true), - 2 => None, - _ => unreachable!(), - } - } - - #[inline] - fn write_to_bytes(self, b: &mut [u8; 1]) { - debug_assert!(!self.is_default()); - b[0] = match self { - Some(false) => 0, - Some(true) => 1, - None => 2, - }; - } -} - -impl FixedSizeEncoding for UnusedGenericParams { - type ByteArray = [u8; 4]; - - #[inline] - fn from_bytes(b: &[u8; 4]) -> Self { - let x: u32 = u32::from_bytes(b); - UnusedGenericParams::from_bits(x) - } - - #[inline] - fn write_to_bytes(self, b: &mut [u8; 4]) { - self.bits().write_to_bytes(b); - } -} - // NOTE(eddyb) there could be an impl for `usize`, which would enable a more // generic `LazyValue` impl, but in the general case we might not need / want // to fit every `usize` in `u32`.