Skip to main content

Module prelude

Module prelude 

Source

Re-exports§

pub use crate::sinto_reexport;
pub use crate::sinto_todo;
pub use mir_kinds::IsMirKind;
pub use rustc_trait_elaboration as elaboration;
pub use crate::frontend::*;
pub use crate::frontend::state::*;

Modules§

adt
def_id
This module contains the type definition for DefId and the types DefId depends on.
full_def
item_ref
mir
Copies of the relevant MIR types. MIR represents a rust (function) body as a CFG. It’s a semantically rich representation that contains no high-level control-flow operations like loops or patterns; instead the control flow is entirely described by gotos and switches on integer values.
mir_kinds
Enumerates the kinds of Mir bodies. TODO: use const generics instead of an open list of types.
new
This module contains type definitions that have no equivalent in Rustc.
predicates
rustc
synthetic_items
traits
ty
Frontend representations of Rust types and related type operations.
uneval
Translate constants to the frontend: type-system constants, and the values read by rustc_const_uneval.
vars

Structs§

Adt
ADts (Struct, Enum and Union map to this).
AdtTy
Alias
This type merges the information from [ty::AliasTyKind] and [ty::AliasTy].
ArrayTy
AssocConst
Associated constant: trait MyTrait { const ASSOC: usize; }
AssocFn
Associated function: impl MyStruct { fn associated() {} } or trait Foo { fn associated() {} }
AssocItem
Reflects [ty::AssocItem]
AssocTy
Associated type: trait MyTrait { type Assoc; }
Binder
Reflects [ty::Binder]
BoundTy
Reflects [ty::BoundTy]
BoundTyRef
Canonical
Reflects [rustc_middle::infer::canonical::Canonical]
CanonicalUserTypeAnnotation
Reflects [ty::CanonicalUserTypeAnnotation]
Clause
Reflects [ty::Clause] and adds a hash-consed predicate identifier.
Closure
A closure, coroutine, or coroutine-closure.
ClosureTy
Reflects [ty::ClosureArgs]
CoercePredicate
Reflects [ty::CoercePredicate]
Const
ConstOperand
The contents of Operand::Const.
ConstantExpr
Rustc has different representations for constants: one for MIR ([rustc_middle::mir::Const]), one for the type system ([rustc_middle::ty::ConstKind]). For simplicity the frontend maps those two constructs to the same ConstantExpr type.
ConstantFieldExpr
CoroutineTy
Ctor
The constructor function of a tuple/unit struct or tuple/unit enum variant.
DefId
Reflects rustc_hir::def_id::DefId, augmented to also give ids to promoted constants (which have their own ad-hoc numbering scheme in rustc for now).
DefIdContents
DisambiguatedDefPathItem
Reflects [rustc_hir::definitions::DisambiguatedDefPathData]
DiscriminantValue
Reflects [ty::util::Discr]
DynBinder
A representation of exists<T: Trait1 + Trait2>(value): we create a fresh type id and the appropriate trait clauses. The contained value may refer to the fresh ty and the in-scope trait clauses. This is used to represent types related to dyn Trait.
DynTraitTy
ElaborationCtx
ExistentialProjection
Reflects [ty::ExistentialProjection]
ExistentialTraitRef
Reflects [ty::ExistentialTraitRef]
FieldDef
Reflects [ty::FieldDef]
Fn
FnDefTy
FnPointer
FnPtrShape
Represents the “shape” of a function pointer, i.e. the most general signature we can obtain from it without breaking the higher-kinded variables. E.g. for<'a> fn(&'a u32) -> Adt<'a, u32> is considered to be an instantiation of the shape for<'a> fn(&'a A) -> Adt<'a, B> with A=B=u32.
FnPtrTy
ForeignMod
An extern block.
ForeignTy
FullDef
Gathers a lot of definition information about a rustc_hir::def_id::DefId.
GenericParamDef
Reflects [ty::GenericParamDef]
GenericParamDefIds
This is a pretty criminal hack: I want to generate ty::Generics for my fake items. This requires DefIds for the generic parameters. rustc has an affordance for creating new DefIds (tcx.create_def()) but I could not figure out a way to use it that didn’t end up ICEing during metadata encoding. So instead I’m reusing the DefIds of generic parameters from core functions.
GenericPredicate
GenericPredicates
Reflects [ty::GenericPredicates]
ImplAssocItem
An associated item in a trait impl. This can be an item provided by the trait impl, or an item that reuses the trait decl default value.
ImplAssocItemValue
The item is provided by the trait impl.
InherentImpl
ItemPredicate
ItemPredicates
ItemRef
Reference to an item, with generics. Basically any mention of an item (function, type, etc) uses this.
ItemRefContents
Contents of ItemRef.
LateBinder
A binder that wraps something that may mention the late-bound variables of an item. This does not count for de Bruijn indices: the late bound vars will instead be referred to using LateParam, using the def_id of this binder. That def_id is always that of the item, except in cases where the item doesn’t have a rustc DefId, in which case we use a dummy one.
Mod
OutlivesPredicate
Reflects [ty::OutlivesPredicate] as a named struct instead of a tuple struct. This is because the script converting JSONSchema types to OCaml doesn’t support tuple structs, and this is the only tuple struct in the whole AST.
ParamEnv
The combination of type generics and related predicates.
PatTy
PathBuf
An owned, mutable path (akin to String).
Placeholder
Reflects [ty::Placeholder]
Predicate
Reflects [ty::Predicate] and adds a hash-consed predicate identifier.
ProjectionPredicate
Expresses a constraints over an associated type.
RawPtrTy
Rc
A single-threaded reference-counting pointer. ‘Rc’ stands for ‘Reference Counted’.
RefTy
ReprFlags
The representation flags without the ones irrelevant outside of rustc.
ReprOptions
Reflects [rustc_abi::ReprOptions].
SliceTy
Static
StrTy
SubtypePredicate
Reflects [ty::SubtypePredicate]
SyntheticItemData
Trait
TraitAlias
Trait alias: trait IntIterator = Iterator<Item = i32>;
TraitImpl
TraitItemBinder
The binding context to use when translating a trait impl associated item.
TraitPredicate
Reflects [ty::TraitClause]
TraitProof
A TraitProof describes the full data of a trait implementation. Because of generics, this may need to combine several concrete trait implementation items. For example, ((1u8, 2u8), "hello").clone() combines the generic implementation of Clone for (A, B) with the concrete implementations for u8 and &str, represented as a tree.
TraitProofContents
TupleTy
Ty
Reflects [rustc_middle::ty::Ty]
TyAlias
Type alias: type Foo = Bar;
TyFnSig
Reflects [ty::FnSig]
TyGenerics
Reflects [rustc_trait_elaboration::GenericParams].
TypeAndMut
Reflects [ty::TypeAndMut]
UserArgs
Reflects [ty::UserArgs]
UserSelfTy
Reflects [ty::UserSelfTy]
VariantDef
Reflects [ty::VariantDef]
VirtualImplAssocItem
Align
Alignment of a type in bytes (always a power of two).
BoundVar
ByteSymbol
Like Symbol, but for byte strings. ByteSymbol is used less widely, so it has fewer operations defined than Symbol.
DebruijnIndex
A De Bruijn index is a standard means of representing regions (and perhaps later types) in a higher-ranked setting. In particular, imagine a type like this:
EarlyParamRegion
FieldIdx
The source-order index of a field in a variant.
IndexVec
An owned contiguous collection of Ts, indexed by I rather than by usize.
MacroKinds
A set of macro kinds, for macros that can have more than one kind
ParamConst
ParamTy
PromotedId
RAllocId
RDefId
A DefId identifies a particular definition, by combining a crate index and a def index.
Span
A compressed span.
Spanned
Symbol
An interned UTF-8 string.
VariantIdx
The source-order index of a variant in a type.

Enums§

AdtKind
Reflects [ty::AdtKind]
AliasKind
Reflects [rustc_middle::ty::AliasTyKind].
AssocItemContainer
AssocItemResolution
AssocTyKind
BoundRegionKind
Reflects [ty::BoundRegionKind]
BoundTyKind
Reflects [ty::BoundTyKind]
BoundVariableKind
Reflects [ty::BoundVariableKind]
BuiltinTraitData
ClauseKind
Reflects [ty::ClauseKind]
ClosureKind
Reflects [ty::ClosureKind]
ConstKind
The kind of a constant item.
ConstOperandKind
ConstSource
A constant that we can ask rustc to evaluate.
ConstantByte
A byte of an evaluated constant, in the MiniRust sense.
ConstantByteProvenance
What a pointer byte in an evaluated constant points to.
ConstantExprKind
The subset of expressions that corresponds to constants.
ConstantInt
ConstantLiteral
ConstantProjectionElem
Projects a place inside the pointee of a constant pointer.
ConstantPtrBase
The place a constant pointer starts from.
DefIdBase
DefKind
Reflects rustc_hir::def::DefKind
DefPathItem
Reflects [rustc_hir::definitions::DefPathData]
DerivedItemKind
DestructData
DiscriminantDefinition
Reflects [ty::VariantDiscr]
ExistentialPredicate
A predicate without Self, for use in dyn Trait.
FnPtrTarget
The function a function pointer points to.
FullDefKind
Imbues rustc_hir::def::DefKind with a lot of extra information.
GenericArg
Reflects both [ty::GenericArg] and [ty::GenericArgKind]
GenericParamDefKind
Reflects [ty::GenericParamDefKind]
GenericPredicateId
Uniquely identifies a predicate.
GlobalRef
A global allocation.
HostEffectClause
ItemPredicateId
Uniquely identifies a predicate.
NormalizesTo
Pattern
PredicateDirection
PredicateKind
Reflects [ty::PredicateKind]
ReadMode
How to read back an evaluated constant.
SyntheticItem
We create some extra DefIds to represent things that rustc doesn’t have a DefId for. This makes the pipeline much easier to have “real” def_ids for them, as we can then solve traits for them etc, and works well with monomorphization.
Term
Reflects [ty::Term]
TraitProofImpliedPredicate
TraitProofKind
The source of a particular trait implementation. Most often this is either Concrete for a concrete impl Trait for Type {} item, or LocalBound for a context-bound where T: Trait.
TyKind
Reflects [ty::TyKind]
UnsizingMetadata
The metadata to attach to the newly-unsized ptr.
UserType
Reflects [ty::UserType]: this is currently disabled, and everything is printed as debug in the UserType::Todo variant.
VariantKind
Describe the kind of a variant
Visibility
Reflects [ty::Visibility]
AssocConstData
AssocKind
AssocTypeData
BoundVarIndexKind
Okay, we do something fun for Bound types/regions/consts: Specifically, we distinguish between canonically bound things and for<> bound things. And, really, it comes down to caching during canonicalization and instantiation.
CtorKind
What kind of constructor something is.
CtorOf
Encodes if a DefKind::Ctor is the constructor of an enum variant or a struct.
ExternAbi
ABI we expect to see within extern "{abi}"
FloatTy
ImplTraitInTraitData
Useful source information about where a desugared associated type for an RPITIT originated from.
InferTy
A placeholder for a type that hasn’t been inferred yet.
InlineAttr
IntTy
Mutability
RDefKind
What kind of definition something is; e.g., mod vs struct. enum DefPathData may need to be updated if a new variant is added here.
Safety
SolverTraitLangItem
UintTy
Variance

Constants§

SYNTHETIC_CRATE_NAME
The crate name under which synthetic items are exported under.

Traits§

BinderVariances
Lets types declare how to compute the variance of bound parameters.
ItemId
The identifier of an item; generalizes over rustc’s DefId to allow for virtual items.
SubstBinder
ToPolyTraitRef

Functions§

alias_ty_kind_def_id
assoc_items_of
The associated items of the trait or inherent impl that owns s, in definition order.
assoc_tys_for_trait
Generates a list of <trait_ref>::Ty type aliases for each non-gat associated type of the given trait and its parents, in a specific order.
bits_and_type_to_float_constant_literal
Converts a bit-representation of a float of type ty to a constant literal
can_have_generics
Whether the item can have generic parameters.
closure_sig
Retrieve a closure’s signature.
compute_unsizing_metadata
const_reader
The reader for constants evaluated in the current context.
drop_glue_shim
dyn_self_ty
Generates a dyn Trait<Args.., Ty = <Self as Trait>::Ty..> type for the given trait ref.
erase_and_norm
erase_free_regions
Erase free regions from the given value. Largely copied from tcx.erase_and_anonymize_regions, but also erases bound regions that are bound outside value, so we can call this function inside a Binder.
fn_sig_bound_region_variances
Computes the variance of each region bound by sig.
gen_vtable_sig
The vtable signature of the method, along with the state of its container.
get_def_kind
Gets the kind of the definition. Can’t use def_kind directly because this crashes on the crate root.
get_foreign_mod_children
Gets the children of an extern block. Empty if the block is not defined in the current crate.
get_implied_predicates
get_method_sig
The signature of a method impl may be a subtype of the one expected from the trait decl, as in the example below. For correctness, we must be able to map from the method generics declared in the trait to the actual method generics. Because this would require type inference, we instead simply return the declared signature. This will cause issues if it is possible to use such a more-specific implementation with its more-specific type, but we have a few other issues with lifetime-generic function pointers anyway so this is unlikely to cause problems.
get_mod_children
Gets the children of a module.
get_param_env
get_self_predicate
get_trait_decl_dyn_self_ty
Generates a dyn Trait<Args.., Ty = <Self as Trait>::Ty..> type for this trait.
get_variant_kind
identity_args_with_inferred
Closures and inline consts have special type params that are used as inference variables. After analysis, they can be computed from the rest of the args (modulo some erased regions). This computes the identity args for this def_id with the inference ars properly inferred.
inst_binder
Instantiate this binder with the provided args. Use None if the args are known to be the identity args.
late_bound_for_def
lifetime_param_name
local_names
match_region_args
Takes two values that differ only in their regions, where template has placeholder regions used each once in the places that they differ. Returns a mapping from those placeholders to the corresponding regions in actual.
normalize
Normalize a value.
read_const
Evaluate src and read it back as a ConstantExpr.
resolve_for_dyn
scalar_int_to_constant_literal
self_clause_for_item
Retrieve the Self: Trait clause for a trait associated item.
self_predicate
The special “self” predicate on a trait.
self_trait_ref
solve_copy
Solve the T: Copy predicate.
solve_destruct
Solve the T: Destruct predicate.
solve_item_implied_traits
Solve the trait obligations for implementing a trait (or for trait associated type bounds) in the current context.
solve_item_traits_inner
Apply the given generics to the provided clauses and resolve the trait references in the current context.
solve_sized
Solve the T: Sized predicate.
solve_trait
This is the entrypoint of the solving.
substitute
Instantiate this value with the provided args. Use None if the args are known to be the identity args.
super_clause_to_clause_and_trait_proof
Given a clause clause in the context of some impl block impl_did, susbts correctly Self from clause and (1) derive a Clause and (2) resolve a TraitProof.
translate_full_def
Construct the FullDef for this item. If args is Some, the returned FullDef will be instantiated with the provided generics.
translate_full_def_kind
Construct the FullDefKind for this item.
translate_item_ref
Translate a reference to an item, resolving the appropriate trait clauses as needed.
translate_mir_const
Translate a MIR constant.
translate_user_annotation
Convert a type annotation into data we can use, by fetching the types that rustc inferred and gathering the predicates that still need to be checked at borrowck time.
type_alias_trait_clauses
Collects the trait clauses needed to make a type alias well-formed, as Rust itself does not require type aliases to declare the clauses they use.
type_param_name
unerase_lifetimes
Replace each erased region in this value with a fresh placeholder region.
unsizing_metadata
The metadata of a pointer to a value of type from unsized to type to.
vtable_sig_with_dyn_self
The signature of method_decl as stored in a vtable, i.e. with its Self type replaced by the given dyn Trait<..> type.

Type Aliases§

CanonicalUserType
Reflects [ty::CanonicalUserType]
HashMap
Type alias for a hash map that uses the Fx hashing algorithm.
Ident
Reflects [rustc_span::symbol::Ident]
PlaceholderConst
Reflects [ty::PlaceholderConst]
PlaceholderTy
Reflects [ty::PlaceholderType]
PolyFnSig
Reflects [ty::PolyFnSig]
PredicateSearcher
RegionOutlivesPredicate
Reflects [ty::RegionOutlivesPredicate]
TraitRef
Reflects [ty::TraitRef] Contains the def_id and arguments passed to the trait. The first type argument is the Self type. The trait proofs are the required predicate for this trait; currently they are always empty because we consider all trait predicates as implied. self.in_trait is always None because a trait can’t be associated to another one.
TypeOutlivesPredicate
Reflects [ty::TypeOutlivesPredicate]
UnitBinder
UserAnnotation
The data of a user annotation, bound in an existentially-quantified binder.
UserAnnotationData
The data of a user annotation: for each used projection we get the type of the corresponding place, and we record outlives predicates that must hold. The first vec matches the input list of projections, the second is free-form.
UserAnnotationProj
Denotes a subplace of a user annotation, e.g. in let Foo { x, .. }: Self = ...; the annotation will have a projection for x.
PlaceholderRegion
Region