pub(super) struct EncodeContext<'a, 'tcx> {Show 16 fields
opaque: FileEncoder<'a>,
metadata_hasher: Arc<Mutex<XxHash3_128>>,
tcx: TyCtxt<'tcx>,
feat: &'tcx Features,
tables: TableBuilders,
lazy_state: LazyState,
span_shorthands: FxHashMap<Span, usize>,
type_shorthands: FxHashMap<Ty<'tcx>, usize>,
predicate_shorthands: FxHashMap<PredicateKind<'tcx>, usize>,
interpret_allocs: FxIndexSet<AllocId>,
source_file_cache: (Arc<SourceFile>, usize),
required_source_files: Option<FxIndexSet<usize>>,
is_proc_macro: bool,
hygiene_ctxt: Rc<RefCell<HygieneEncodeContext>>,
symbol_index_table: FxHashMap<u32, usize>,
local_defs_remapping: LocalDefsRemapping,
}Fields§
§opaque: FileEncoder<'a>§metadata_hasher: Arc<Mutex<XxHash3_128>>§tcx: TyCtxt<'tcx>§feat: &'tcx Features§tables: TableBuilders§lazy_state: LazyState§span_shorthands: FxHashMap<Span, usize>§type_shorthands: FxHashMap<Ty<'tcx>, usize>§predicate_shorthands: FxHashMap<PredicateKind<'tcx>, usize>§interpret_allocs: FxIndexSet<AllocId>§source_file_cache: (Arc<SourceFile>, usize)§required_source_files: Option<FxIndexSet<usize>>§is_proc_macro: bool§hygiene_ctxt: Rc<RefCell<HygieneEncodeContext>>§symbol_index_table: FxHashMap<u32, usize>§local_defs_remapping: LocalDefsRemappingImplementations§
Source§impl<'a, 'tcx> EncodeContext<'a, 'tcx>
impl<'a, 'tcx> EncodeContext<'a, 'tcx>
fn emit_lazy_distance(&mut self, position: NonZero<usize>)
fn lazy<T: ParameterizedOverTcx, B: Borrow<T::Value<'tcx>>>( &mut self, value: B, ) -> LazyValue<T>
fn lazy_array<T: ParameterizedOverTcx, I: IntoIterator<Item = B>, B: Borrow<T::Value<'tcx>>>( &mut self, values: I, ) -> LazyArray<T>
fn encode_symbol_or_byte_symbol( &mut self, index: u32, emit_str_or_byte_str: impl Fn(&mut Self), )
fn encode_def_path_table(&mut self)
fn encode_def_path_hash_map(&mut self) -> LazyValue<DefPathHashMapRef<'static>>
fn encode_source_map( &mut self, ) -> LazyTable<u32, u32, Option<LazyValue<SourceFile>>>
fn encode_crate_root( &mut self, ) -> (LazyValue<CrateRoot>, LazyValue<CrateRootUnhashed>)
Source§impl<'a, 'tcx> EncodeContext<'a, 'tcx>
impl<'a, 'tcx> EncodeContext<'a, 'tcx>
fn encode_attrs(&mut self, def_id: LocalDefId)
fn encode_def_ids(&mut self)
fn encode_externally_implementable_items( &mut self, ) -> LazyArray<(DefId, (EiiDecl, Vec<(DefId, EiiImpl)>))>
fn encode_info_for_adt(&mut self, local_def_id: LocalDefId)
fn encode_info_for_mod(&mut self, local_def_id: LocalDefId)
fn encode_explicit_item_bounds(&mut self, def_id: LocalDefId)
fn encode_explicit_item_self_bounds(&mut self, def_id: LocalDefId)
fn encode_info_for_assoc_item(&mut self, def_id: LocalDefId)
fn encode_precise_capturing_args(&mut self, def_id: LocalDefId)
fn encode_mir(&mut self)
fn encode_stability(&mut self, def_id: LocalDefId)
fn encode_const_stability(&mut self, def_id: LocalDefId)
fn encode_default_body_stability(&mut self, def_id: LocalDefId)
fn encode_deprecation(&mut self, def_id: LocalDefId)
fn encode_info_for_macro(&mut self, def_id: LocalDefId)
fn encode_native_libraries(&mut self) -> LazyArray<NativeLib>
fn encode_foreign_modules(&mut self) -> LazyArray<ForeignModule>
fn encode_hygiene( &mut self, ) -> (LazyTable<u32, u32, Option<LazyValue<SyntaxContextKey>>>, LazyTable<ExpnIndex, ExpnIndex, Option<LazyValue<ExpnData>>>, LazyTable<ExpnIndex, ExpnIndex, Option<LazyValue<ExpnHash>>>)
fn encode_proc_macros(&mut self) -> Option<ProcMacroData>
fn encode_debugger_visualizers(&mut self) -> LazyArray<DebuggerVisualizerFile>
fn encode_crate_deps(&mut self) -> LazyArray<CrateDep>
fn encode_target_modifiers(&mut self) -> LazyArray<TargetModifier>
fn encode_enabled_denied_partial_mitigations( &mut self, ) -> LazyArray<DeniedPartialMitigation>
fn encode_lib_features(&mut self) -> LazyArray<(Symbol, FeatureStability)>
fn encode_stability_implications(&mut self) -> LazyArray<(Symbol, Symbol)>
fn encode_canonical_symbols(&mut self) -> LazyArray<(Symbol, LocalDefId)>
fn encode_diagnostic_items(&mut self) -> LazyArray<(Symbol, LocalDefId)>
fn encode_fake_doc_items(&mut self) -> LazyArray<LocalDefId>
fn encode_lang_items(&mut self) -> LazyArray<(LocalDefId, LangItem)>
fn encode_lang_items_missing(&mut self) -> LazyArray<LangItem>
fn encode_stripped_cfg_items( &mut self, ) -> LazyArray<StrippedCfgItem<LocalDefId>>
fn encode_traits(&mut self) -> LazyArray<LocalDefId>
Sourcefn encode_impls(&mut self) -> LazyArray<TraitImpls>
fn encode_impls(&mut self) -> LazyArray<TraitImpls>
Encodes an index, mapping each trait to its (local) implementations.
fn encode_incoherent_impls(&mut self) -> LazyArray<IncoherentImpls>
fn encode_exportable_items(&mut self) -> LazyArray<LocalDefId>
fn encode_stable_order_of_exportable_impls( &mut self, ) -> LazyArray<(LocalDefId, usize)>
fn encode_exported_symbols( &mut self, exported_symbols: &[(ExportedSymbol<'tcx>, SymbolExportInfo)], ) -> LazyArray<(ExportedSymbol<'static>, SymbolExportInfo)>
fn encode_dylib_dependency_formats( &mut self, ) -> LazyArray<Option<LinkagePreference>>
Trait Implementations§
Source§impl<'tcx, '__a> Encodable<EncodeContext<'__a, 'tcx>> for ProcMacroData
impl<'tcx, '__a> Encodable<EncodeContext<'__a, 'tcx>> for ProcMacroData
fn encode(&self, __encoder: &mut EncodeContext<'__a, 'tcx>)
Source§impl<'tcx, '__a> Encodable<EncodeContext<'__a, 'tcx>> for ProcMacroKind
impl<'tcx, '__a> Encodable<EncodeContext<'__a, 'tcx>> for ProcMacroKind
fn encode(&self, __encoder: &mut EncodeContext<'__a, 'tcx>)
Source§impl<'tcx, '__a> Encodable<EncodeContext<'__a, 'tcx>> for CrateHeader
impl<'tcx, '__a> Encodable<EncodeContext<'__a, 'tcx>> for CrateHeader
fn encode(&self, __encoder: &mut EncodeContext<'__a, 'tcx>)
Source§impl<'tcx, '__a> Encodable<EncodeContext<'__a, 'tcx>> for CrateRoot
impl<'tcx, '__a> Encodable<EncodeContext<'__a, 'tcx>> for CrateRoot
fn encode(&self, __encoder: &mut EncodeContext<'__a, 'tcx>)
Source§impl<'tcx, '__a> Encodable<EncodeContext<'__a, 'tcx>> for CrateRootUnhashed
impl<'tcx, '__a> Encodable<EncodeContext<'__a, 'tcx>> for CrateRootUnhashed
fn encode(&self, __encoder: &mut EncodeContext<'__a, 'tcx>)
Source§impl<'tcx, '__a> Encodable<EncodeContext<'__a, 'tcx>> for TraitImpls
impl<'tcx, '__a> Encodable<EncodeContext<'__a, 'tcx>> for TraitImpls
fn encode(&self, __encoder: &mut EncodeContext<'__a, 'tcx>)
Source§impl<'tcx, '__a> Encodable<EncodeContext<'__a, 'tcx>> for IncoherentImpls
impl<'tcx, '__a> Encodable<EncodeContext<'__a, 'tcx>> for IncoherentImpls
fn encode(&self, __encoder: &mut EncodeContext<'__a, 'tcx>)
Source§impl<'tcx, '__a> Encodable<EncodeContext<'__a, 'tcx>> for LazyTables
impl<'tcx, '__a> Encodable<EncodeContext<'__a, 'tcx>> for LazyTables
fn encode(&self, __encoder: &mut EncodeContext<'__a, 'tcx>)
Source§impl<'a, 'tcx> Encodable<EncodeContext<'a, 'tcx>> for DefPathHashMapRef<'tcx>
impl<'a, 'tcx> Encodable<EncodeContext<'a, 'tcx>> for DefPathHashMapRef<'tcx>
fn encode(&self, e: &mut EncodeContext<'a, 'tcx>)
Source§impl<'a, 'tcx, T> Encodable<EncodeContext<'a, 'tcx>> for LazyValue<T>
impl<'a, 'tcx, T> Encodable<EncodeContext<'a, 'tcx>> for LazyValue<T>
fn encode(&self, e: &mut EncodeContext<'a, 'tcx>)
Source§impl<'a, 'tcx, T> Encodable<EncodeContext<'a, 'tcx>> for LazyArray<T>
impl<'a, 'tcx, T> Encodable<EncodeContext<'a, 'tcx>> for LazyArray<T>
fn encode(&self, e: &mut EncodeContext<'a, 'tcx>)
Source§impl<'a, 'tcx, Ie, Id, T> Encodable<EncodeContext<'a, 'tcx>> for LazyTable<Ie, Id, T>
impl<'a, 'tcx, Ie, Id, T> Encodable<EncodeContext<'a, 'tcx>> for LazyTable<Ie, Id, T>
fn encode(&self, e: &mut EncodeContext<'a, 'tcx>)
Source§impl<'a, 'tcx> Encodable<EncodeContext<'a, 'tcx>> for ExpnIndex
impl<'a, 'tcx> Encodable<EncodeContext<'a, 'tcx>> for ExpnIndex
fn encode(&self, s: &mut EncodeContext<'a, 'tcx>)
Source§impl<'a, 'tcx> Encodable<EncodeContext<'a, 'tcx>> for SpanData
impl<'a, 'tcx> Encodable<EncodeContext<'a, 'tcx>> for SpanData
fn encode(&self, s: &mut EncodeContext<'a, 'tcx>)
Source§impl<'a, 'tcx> Encodable<EncodeContext<'a, 'tcx>> for [u8]
impl<'a, 'tcx> Encodable<EncodeContext<'a, 'tcx>> for [u8]
fn encode(&self, e: &mut EncodeContext<'a, 'tcx>)
Source§impl<'a, 'tcx> Encoder for EncodeContext<'a, 'tcx>
impl<'a, 'tcx> Encoder for EncodeContext<'a, 'tcx>
fn emit_usize(&mut self, value: usize)
fn emit_u128(&mut self, value: u128)
fn emit_u64(&mut self, value: u64)
fn emit_u32(&mut self, value: u32)
fn emit_u16(&mut self, value: u16)
fn emit_u8(&mut self, value: u8)
fn emit_isize(&mut self, value: isize)
fn emit_i128(&mut self, value: i128)
fn emit_i64(&mut self, value: i64)
fn emit_i32(&mut self, value: i32)
fn emit_i16(&mut self, value: i16)
fn emit_raw_bytes(&mut self, value: &[u8])
fn emit_i8(&mut self, v: i8)
fn emit_bool(&mut self, v: bool)
fn emit_char(&mut self, v: char)
fn emit_str(&mut self, v: &str)
fn emit_byte_str(&mut self, v: &[u8])
Source§impl<'a, 'tcx> SpanEncoder for EncodeContext<'a, 'tcx>
impl<'a, 'tcx> SpanEncoder for EncodeContext<'a, 'tcx>
Source§fn encode_def_index(&mut self, _: DefIndex)
fn encode_def_index(&mut self, _: DefIndex)
This function panics as we need to remap only local def indices, however
we can not determine if the def index is local given only def index.
In metadata LocalDefId is used instead of DefIndex as with this wrapper
around def index we certainly know that it came from local crate.
Source§fn encode_local_def_id(&mut self, def_id: LocalDefId)
fn encode_local_def_id(&mut self, def_id: LocalDefId)
We override encode function for LocalDefId as its default
encoding logic is self.encode_def_id(def_id.to_def_id())
meaning that the crate num will also be encoded, however as in metadata we use
LocalDefId as a wrapper around def index we want to encode
def index only, so we override the encode implementation.
Source§fn encode_def_key(
&mut self,
parent: Option<DefIndex>,
disambiguated_data: impl Encodable<Self>,
)
fn encode_def_key( &mut self, parent: Option<DefIndex>, disambiguated_data: impl Encodable<Self>, )
We override encoding logic for DefKey during metadata encoding,
as DefKey has a field parent of type Option<DefIndex> whose encoding will
cause panic. So we remap it to LocalDefId as def keys during metadata encoding are all local.
Source§fn encode_crate_num(&mut self, crate_num: CrateNum)
fn encode_crate_num(&mut self, crate_num: CrateNum)
CrateNum is only meaningful within its context, e.g. within a
tcx. Therefore, make sure to include the context when encode a CrateNum.fn encode_def_id(&mut self, def_id: DefId)
fn encode_syntax_context(&mut self, syntax_context: SyntaxContext)
fn encode_expn_id(&mut self, expn_id: ExpnId)
fn encode_span(&mut self, span: Span)
fn encode_symbol(&mut self, sym: Symbol)
fn encode_byte_symbol(&mut self, byte_sym: ByteSymbol)
Source§impl<'a, 'tcx> TyEncoder<'tcx> for EncodeContext<'a, 'tcx>
impl<'a, 'tcx> TyEncoder<'tcx> for EncodeContext<'a, 'tcx>
const CLEAR_CROSS_CRATE: bool = true
fn position(&self) -> usize
fn type_shorthands(&mut self) -> &mut FxHashMap<Ty<'tcx>, usize>
fn predicate_shorthands(&mut self) -> &mut FxHashMap<PredicateKind<'tcx>, usize>
fn encode_alloc_id(&mut self, alloc_id: &AllocId)
Auto Trait Implementations§
impl<'a, 'tcx> !DynSend for EncodeContext<'a, 'tcx>
impl<'a, 'tcx> !DynSync for EncodeContext<'a, 'tcx>
impl<'a, 'tcx> !RefUnwindSafe for EncodeContext<'a, 'tcx>
impl<'a, 'tcx> !Send for EncodeContext<'a, 'tcx>
impl<'a, 'tcx> !Sync for EncodeContext<'a, 'tcx>
impl<'a, 'tcx> !UnwindSafe for EncodeContext<'a, 'tcx>
impl<'a, 'tcx> Freeze for EncodeContext<'a, 'tcx>
impl<'a, 'tcx> Unpin for EncodeContext<'a, 'tcx>
impl<'a, 'tcx> UnsafeUnpin for EncodeContext<'a, 'tcx>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<K> IntoQueryKey<K> for K
impl<K> IntoQueryKey<K> for K
Source§fn into_query_key(self) -> K
fn into_query_key(self) -> K
Self to K.
This should always be a very cheap conversion, e.g. LocalDefId::to_def_id.Source§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
Source§impl<I, T> UpcastFrom<I, T> for T
impl<I, T> UpcastFrom<I, T> for T
fn upcast_from(from: T, _tcx: I) -> T
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
Source§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 3064 bytes