about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty/codec.rs
diff options
context:
space:
mode:
authorGeorge Bateman <george.bateman16@gmail.com>2023-08-15 20:10:45 +0100
committerGeorge Bateman <george.bateman16@gmail.com>2023-10-31 23:25:54 +0000
commite936416a8d3cfb501504f00d7250d5b595fed244 (patch)
treec0dd8196372db8a77ae1a90d38d87b630658e90e /compiler/rustc_middle/src/ty/codec.rs
parent9d83ac217957eece2189eccf4a7232caec7232ee (diff)
downloadrust-e936416a8d3cfb501504f00d7250d5b595fed244.tar.gz
rust-e936416a8d3cfb501504f00d7250d5b595fed244.zip
Support enum variants in offset_of!
Diffstat (limited to 'compiler/rustc_middle/src/ty/codec.rs')
-rw-r--r--compiler/rustc_middle/src/ty/codec.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/ty/codec.rs b/compiler/rustc_middle/src/ty/codec.rs
index d52a717b6b0..ce5198ee3ba 100644
--- a/compiler/rustc_middle/src/ty/codec.rs
+++ b/compiler/rustc_middle/src/ty/codec.rs
@@ -19,7 +19,7 @@ use rustc_data_structures::fx::FxHashMap;
 use rustc_middle::ty::TyCtxt;
 use rustc_serialize::{Decodable, Encodable};
 use rustc_span::Span;
-use rustc_target::abi::FieldIdx;
+use rustc_target::abi::{FieldIdx, OffsetOfIdx};
 pub use rustc_type_ir::{TyDecoder, TyEncoder};
 use std::hash::Hash;
 use std::intrinsics;
@@ -414,6 +414,15 @@ impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> RefDecodable<'tcx, D> for ty::List<Fi
     }
 }
 
+impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> RefDecodable<'tcx, D> for ty::List<OffsetOfIdx> {
+    fn decode(decoder: &mut D) -> &'tcx Self {
+        let len = decoder.read_usize();
+        decoder
+            .interner()
+            .mk_offset_of_from_iter((0..len).map::<OffsetOfIdx, _>(|_| Decodable::decode(decoder)))
+    }
+}
+
 impl_decodable_via_ref! {
     &'tcx ty::TypeckResults<'tcx>,
     &'tcx ty::List<Ty<'tcx>>,
@@ -426,6 +435,7 @@ impl_decodable_via_ref! {
     &'tcx ty::List<ty::BoundVariableKind>,
     &'tcx ty::List<ty::Clause<'tcx>>,
     &'tcx ty::List<FieldIdx>,
+    &'tcx ty::List<OffsetOfIdx>,
 }
 
 #[macro_export]