Skip to content

Commit f2ed9a3

Browse files
committed
Can't use EncodableWithShorthand for Predicate
1 parent dcad9f1 commit f2ed9a3

File tree

4 files changed

+2
-35
lines changed

4 files changed

+2
-35
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ pub(super) struct EncodeContext<'a, 'tcx> {
4646

4747
lazy_state: LazyState,
4848
type_shorthands: FxHashMap<Ty<'tcx>, usize>,
49-
predicate_shorthands: FxHashMap<ty::Predicate<'tcx>, usize>,
5049

5150
interpret_allocs: FxIndexSet<interpret::AllocId>,
5251

@@ -328,10 +327,6 @@ impl<'a, 'tcx> TyEncoder<'tcx> for EncodeContext<'a, 'tcx> {
328327
&mut self.type_shorthands
329328
}
330329

331-
fn predicate_shorthands(&mut self) -> &mut FxHashMap<rustc_middle::ty::Predicate<'tcx>, usize> {
332-
&mut self.predicate_shorthands
333-
}
334-
335330
fn encode_alloc_id(
336331
&mut self,
337332
alloc_id: &rustc_middle::mir::interpret::AllocId,
@@ -2151,7 +2146,6 @@ fn encode_metadata_impl(tcx: TyCtxt<'_>) -> EncodedMetadata {
21512146
tables: Default::default(),
21522147
lazy_state: LazyState::NoNode,
21532148
type_shorthands: Default::default(),
2154-
predicate_shorthands: Default::default(),
21552149
source_file_cache,
21562150
interpret_allocs: Default::default(),
21572151
required_source_files,

compiler/rustc_middle/src/ty/codec.rs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,11 @@ impl<'tcx, E: TyEncoder<'tcx>> EncodableWithShorthand<'tcx, E> for Ty<'tcx> {
4343
}
4444
}
4545

46-
impl<'tcx, E: TyEncoder<'tcx>> EncodableWithShorthand<'tcx, E> for ty::Predicate<'tcx> {
47-
type Variant = ty::Binder<ty::PredicateKind<'tcx>>;
48-
fn variant(&self) -> &Self::Variant {
49-
self.kind_ref()
50-
}
51-
}
52-
5346
pub trait TyEncoder<'tcx>: Encoder {
5447
const CLEAR_CROSS_CRATE: bool;
5548

5649
fn position(&self) -> usize;
5750
fn type_shorthands(&mut self) -> &mut FxHashMap<Ty<'tcx>, usize>;
58-
fn predicate_shorthands(&mut self) -> &mut FxHashMap<ty::Predicate<'tcx>, usize>;
5951
fn encode_alloc_id(&mut self, alloc_id: &AllocId) -> Result<(), Self::Error>;
6052
}
6153

@@ -120,7 +112,7 @@ impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for Ty<'tcx> {
120112

121113
impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for ty::Predicate<'tcx> {
122114
fn encode(&self, e: &mut E) -> Result<(), E::Error> {
123-
encode_with_shorthand(e, self, TyEncoder::predicate_shorthands)
115+
self.kind().encode(e)
124116
}
125117
}
126118

@@ -220,16 +212,7 @@ impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for Ty<'tcx> {
220212

221213
impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for ty::Predicate<'tcx> {
222214
fn decode(decoder: &mut D) -> Result<ty::Predicate<'tcx>, D::Error> {
223-
// Handle shorthands first, if we have an usize > 0x80.
224-
let predicate_kind = if decoder.positioned_at_shorthand() {
225-
let pos = decoder.read_usize()?;
226-
assert!(pos >= SHORTHAND_OFFSET);
227-
let shorthand = pos - SHORTHAND_OFFSET;
228-
229-
decoder.with_position(shorthand, ty::Binder::<ty::PredicateKind<'tcx>>::decode)
230-
} else {
231-
ty::Binder::<ty::PredicateKind<'tcx>>::decode(decoder)
232-
}?;
215+
let predicate_kind = Decodable::decode(decoder)?;
233216
let predicate = decoder.tcx().mk_predicate(predicate_kind);
234217
Ok(predicate)
235218
}

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,11 +1064,6 @@ impl<'tcx> Predicate<'tcx> {
10641064
pub fn kind(self) -> Binder<PredicateKind<'tcx>> {
10651065
self.inner.kind
10661066
}
1067-
1068-
/// Like `kind` but returns a reference. Only needed because of encoding.
1069-
pub(super) fn kind_ref(self) -> &'tcx Binder<PredicateKind<'tcx>> {
1070-
&self.inner.kind
1071-
}
10721067
}
10731068

10741069
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Predicate<'tcx> {

compiler/rustc_middle/src/ty/query/on_disk_cache.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ impl<'sess> OnDiskCache<'sess> {
293293
tcx,
294294
encoder,
295295
type_shorthands: Default::default(),
296-
predicate_shorthands: Default::default(),
297296
interpret_allocs: Default::default(),
298297
source_map: CachingSourceMapView::new(tcx.sess.source_map()),
299298
file_to_file_index,
@@ -989,7 +988,6 @@ struct CacheEncoder<'a, 'tcx, E: OpaqueEncoder> {
989988
tcx: TyCtxt<'tcx>,
990989
encoder: &'a mut E,
991990
type_shorthands: FxHashMap<Ty<'tcx>, usize>,
992-
predicate_shorthands: FxHashMap<ty::Predicate<'tcx>, usize>,
993991
interpret_allocs: FxIndexSet<interpret::AllocId>,
994992
source_map: CachingSourceMapView<'tcx>,
995993
file_to_file_index: FxHashMap<*const SourceFile, SourceFileIndex>,
@@ -1103,9 +1101,6 @@ where
11031101
fn type_shorthands(&mut self) -> &mut FxHashMap<Ty<'tcx>, usize> {
11041102
&mut self.type_shorthands
11051103
}
1106-
fn predicate_shorthands(&mut self) -> &mut FxHashMap<ty::Predicate<'tcx>, usize> {
1107-
&mut self.predicate_shorthands
1108-
}
11091104
fn encode_alloc_id(&mut self, alloc_id: &interpret::AllocId) -> Result<(), Self::Error> {
11101105
let (index, _) = self.interpret_allocs.insert_full(*alloc_id);
11111106

0 commit comments

Comments
 (0)