Struct rustc_metadata::rmeta::encoder::EncodeContext [−][src]
pub(super) struct EncodeContext<'a, 'tcx> {
opaque: Encoder,
tcx: TyCtxt<'tcx>,
feat: &'tcx Features,
tables: TableBuilders<'tcx>,
lazy_state: LazyState,
type_shorthands: FxHashMap<Ty<'tcx>, usize>,
predicate_shorthands: FxHashMap<PredicateKind<'tcx>, usize>,
interpret_allocs: FxIndexSet<AllocId>,
source_file_cache: (Lrc<SourceFile>, usize),
required_source_files: Option<GrowableBitSet<usize>>,
is_proc_macro: bool,
hygiene_ctxt: &'a HygieneEncodeContext,
}
Fields
opaque: Encoder
tcx: TyCtxt<'tcx>
feat: &'tcx Features
tables: TableBuilders<'tcx>
lazy_state: LazyState
type_shorthands: FxHashMap<Ty<'tcx>, usize>
predicate_shorthands: FxHashMap<PredicateKind<'tcx>, usize>
interpret_allocs: FxIndexSet<AllocId>
source_file_cache: (Lrc<SourceFile>, usize)
required_source_files: Option<GrowableBitSet<usize>>
is_proc_macro: bool
hygiene_ctxt: &'a HygieneEncodeContext
Implementations
fn lazy<T: ?Sized + LazyMeta>(
&mut self,
value: impl EncodeContentsForLazy<'a, 'tcx, T>
) -> Lazy<T>
fn encode_info_for_generic_param(
&mut self,
def_id: DefId,
kind: EntryKind,
encode_type: bool
)
fn encode_hygiene(
&mut self
) -> (Lazy<Table<u32, Lazy<SyntaxContextData>>>, Lazy<Table<ExpnIndex, Lazy<ExpnData>>>, Lazy<Table<ExpnIndex, Lazy<ExpnHash>>>)
Encodes an index, mapping each trait to its (local) implementations.
fn encode_exported_symbols(
&mut self,
exported_symbols: &[(ExportedSymbol<'tcx>, SymbolExportLevel)]
) -> Lazy<[(ExportedSymbol<'tcx>, SymbolExportLevel)]>
In some cases, along with the item itself, we also encode some sub-items. Usually we want some info from the item so it’s easier to do that here then to wait until we would encounter normally in the visitor walk.
Trait Implementations
impl<'a, 'tcx, T: Encodable<EncodeContext<'a, 'tcx>>> Encodable<EncodeContext<'a, 'tcx>> for Lazy<T>
impl<'a, 'tcx, T: Encodable<EncodeContext<'a, 'tcx>>> Encodable<EncodeContext<'a, 'tcx>> for Lazy<T>
impl<'a, 'tcx, T: Encodable<EncodeContext<'a, 'tcx>>> Encodable<EncodeContext<'a, 'tcx>> for Lazy<[T]>
impl<'a, 'tcx, T: Encodable<EncodeContext<'a, 'tcx>>> Encodable<EncodeContext<'a, 'tcx>> for Lazy<[T]>
impl<'a, 'tcx, I: Idx, T: Encodable<EncodeContext<'a, 'tcx>>> Encodable<EncodeContext<'a, 'tcx>> for Lazy<Table<I, T>> where
Option<T>: FixedSizeEncoding,
impl<'a, 'tcx, I: Idx, T: Encodable<EncodeContext<'a, 'tcx>>> Encodable<EncodeContext<'a, 'tcx>> for Lazy<Table<I, T>> where
Option<T>: FixedSizeEncoding,
fn emit_enum<F>(&mut self, f: F) -> Result<(), Self::Error> where
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
fn emit_enum_variant<F>(
&mut self,
_v_name: &str,
v_id: usize,
_len: usize,
f: F
) -> Result<(), Self::Error> where
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
fn emit_enum_variant_arg<F>(
&mut self,
_first: bool,
f: F
) -> Result<(), Self::Error> where
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
fn emit_struct<F>(&mut self, _no_fields: bool, f: F) -> Result<(), Self::Error> where
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
fn emit_struct_field<F>(
&mut self,
_f_name: &str,
_first: bool,
f: F
) -> Result<(), Self::Error> where
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
fn emit_tuple<F>(&mut self, _len: usize, f: F) -> Result<(), Self::Error> where
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
fn emit_tuple_arg<F>(&mut self, _idx: usize, f: F) -> Result<(), Self::Error> where
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
fn emit_option<F>(&mut self, f: F) -> Result<(), Self::Error> where
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
fn emit_option_some<F>(&mut self, f: F) -> Result<(), Self::Error> where
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
fn emit_seq<F>(&mut self, len: usize, f: F) -> Result<(), Self::Error> where
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
fn emit_seq_elt<F>(&mut self, _idx: usize, f: F) -> Result<(), Self::Error> where
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
fn emit_map<F>(&mut self, len: usize, f: F) -> Result<(), Self::Error> where
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
The default versions of the visit_nested_XXX
routines invoke
this method to get a map to use. By selecting an enum variant,
you control which kinds of nested HIR are visited; see
NestedVisitorMap
for details. By “nested HIR”, we are
referring to bits of HIR that are not directly embedded within
one another but rather indirectly, through a table in the
crate. This is done to control dependencies during incremental
compilation: the non-inline bits of HIR can be tracked and
hashed separately. Read more
Visits the top-level item and (optionally) nested items / impl items. See
visit_nested_item
for details. Read more
Invoked when a nested item is encountered. By default does
nothing unless you override nested_visit_map
to return other than
None
, in which case it will walk the item. You probably
don’t want to override this method – instead, override
nested_visit_map
or use the “shallow” or “deep” visit
patterns described on itemlikevisit::ItemLikeVisitor
. The only
reason to override this method is if you want a nested pattern
but cannot supply a Map
; see nested_visit_map
for advice. Read more
Like visit_nested_item()
, but for trait items. See
visit_nested_item()
for advice on when to override this
method. Read more
Like visit_nested_item()
, but for impl items. See
visit_nested_item()
for advice on when to override this
method. Read more
Like visit_nested_item()
, but for foreign items. See
visit_nested_item()
for advice on when to override this
method. Read more
Invoked to visit the body of a function, method or closure. Like
visit_nested_item, does nothing by default unless you override
nested_visit_map
to return other than None
, in which case it will walk
the body. Read more
When invoking visit_all_item_likes()
, you need to supply an
item-like visitor. This method converts an “intra-visit”
visitor into an item-like visitor that walks the entire tree.
If you use this, you probably don’t want to process the
contents of nested item-like things, since the outer loop will
visit them as well. Read more
fn visit_variant_data(
&mut self,
s: &'v VariantData<'v>,
Symbol,
&'v Generics<'v>,
_parent_id: HirId,
Span
)
fn visit_enum_def(
&mut self,
enum_definition: &'v EnumDef<'v>,
generics: &'v Generics<'v>,
item_id: HirId,
Span
)
Auto Trait Implementations
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> Unpin for EncodeContext<'a, 'tcx>
impl<'a, 'tcx> !UnwindSafe for EncodeContext<'a, 'tcx>
Blanket Implementations
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: 960 bytes