diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 58931bc5ff0..0b398c35db0 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -46,7 +46,6 @@ pub(super) struct EncodeContext<'a, 'tcx> { lazy_state: LazyState, type_shorthands: FxHashMap, usize>, - predicate_shorthands: FxHashMap, usize>, interpret_allocs: FxIndexSet, @@ -328,10 +327,6 @@ impl<'a, 'tcx> TyEncoder<'tcx> for EncodeContext<'a, 'tcx> { &mut self.type_shorthands } - fn predicate_shorthands(&mut self) -> &mut FxHashMap, usize> { - &mut self.predicate_shorthands - } - fn encode_alloc_id( &mut self, alloc_id: &rustc_middle::mir::interpret::AllocId, @@ -2151,7 +2146,6 @@ fn encode_metadata_impl(tcx: TyCtxt<'_>) -> EncodedMetadata { tables: Default::default(), lazy_state: LazyState::NoNode, type_shorthands: Default::default(), - predicate_shorthands: Default::default(), source_file_cache, interpret_allocs: Default::default(), required_source_files, diff --git a/compiler/rustc_middle/src/ty/codec.rs b/compiler/rustc_middle/src/ty/codec.rs index 6fa9c414bc0..380fb8172a7 100644 --- a/compiler/rustc_middle/src/ty/codec.rs +++ b/compiler/rustc_middle/src/ty/codec.rs @@ -43,19 +43,11 @@ impl<'tcx, E: TyEncoder<'tcx>> EncodableWithShorthand<'tcx, E> for Ty<'tcx> { } } -impl<'tcx, E: TyEncoder<'tcx>> EncodableWithShorthand<'tcx, E> for ty::Predicate<'tcx> { - type Variant = ty::Binder>; - fn variant(&self) -> &Self::Variant { - self.kind_ref() - } -} - pub trait TyEncoder<'tcx>: Encoder { const CLEAR_CROSS_CRATE: bool; fn position(&self) -> usize; fn type_shorthands(&mut self) -> &mut FxHashMap, usize>; - fn predicate_shorthands(&mut self) -> &mut FxHashMap, usize>; fn encode_alloc_id(&mut self, alloc_id: &AllocId) -> Result<(), Self::Error>; } @@ -120,7 +112,7 @@ impl<'tcx, E: TyEncoder<'tcx>> Encodable for Ty<'tcx> { impl<'tcx, E: TyEncoder<'tcx>> Encodable for ty::Predicate<'tcx> { fn encode(&self, e: &mut E) -> Result<(), E::Error> { - encode_with_shorthand(e, self, TyEncoder::predicate_shorthands) + self.kind().encode(e) } } @@ -220,16 +212,7 @@ impl<'tcx, D: TyDecoder<'tcx>> Decodable for Ty<'tcx> { impl<'tcx, D: TyDecoder<'tcx>> Decodable for ty::Predicate<'tcx> { fn decode(decoder: &mut D) -> Result, D::Error> { - // Handle shorthands first, if we have an usize > 0x80. - let predicate_kind = if decoder.positioned_at_shorthand() { - let pos = decoder.read_usize()?; - assert!(pos >= SHORTHAND_OFFSET); - let shorthand = pos - SHORTHAND_OFFSET; - - decoder.with_position(shorthand, ty::Binder::>::decode) - } else { - ty::Binder::>::decode(decoder) - }?; + let predicate_kind = Decodable::decode(decoder)?; let predicate = decoder.tcx().mk_predicate(predicate_kind); Ok(predicate) } diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 76d3bc7a3d5..099c5aa84e5 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -1064,11 +1064,6 @@ impl<'tcx> Predicate<'tcx> { pub fn kind(self) -> Binder> { self.inner.kind } - - /// Like `kind` but returns a reference. Only needed because of encoding. - pub(super) fn kind_ref(self) -> &'tcx Binder> { - &self.inner.kind - } } impl<'a, 'tcx> HashStable> for Predicate<'tcx> { diff --git a/compiler/rustc_middle/src/ty/query/on_disk_cache.rs b/compiler/rustc_middle/src/ty/query/on_disk_cache.rs index 6003509780a..914937134b4 100644 --- a/compiler/rustc_middle/src/ty/query/on_disk_cache.rs +++ b/compiler/rustc_middle/src/ty/query/on_disk_cache.rs @@ -293,7 +293,6 @@ impl<'sess> OnDiskCache<'sess> { tcx, encoder, type_shorthands: Default::default(), - predicate_shorthands: Default::default(), interpret_allocs: Default::default(), source_map: CachingSourceMapView::new(tcx.sess.source_map()), file_to_file_index, @@ -989,7 +988,6 @@ struct CacheEncoder<'a, 'tcx, E: OpaqueEncoder> { tcx: TyCtxt<'tcx>, encoder: &'a mut E, type_shorthands: FxHashMap, usize>, - predicate_shorthands: FxHashMap, usize>, interpret_allocs: FxIndexSet, source_map: CachingSourceMapView<'tcx>, file_to_file_index: FxHashMap<*const SourceFile, SourceFileIndex>, @@ -1103,9 +1101,6 @@ where fn type_shorthands(&mut self) -> &mut FxHashMap, usize> { &mut self.type_shorthands } - fn predicate_shorthands(&mut self) -> &mut FxHashMap, usize> { - &mut self.predicate_shorthands - } fn encode_alloc_id(&mut self, alloc_id: &interpret::AllocId) -> Result<(), Self::Error> { let (index, _) = self.interpret_allocs.insert_full(*alloc_id);