Struct rustc_middle::query::plumbing::TyCtxtAt
source · pub struct TyCtxtAt<'tcx> {
pub tcx: TyCtxt<'tcx>,
pub span: Span,
}
Fields§
§tcx: TyCtxt<'tcx>
§span: Span
Implementations§
source§impl<'tcx> TyCtxtAt<'tcx>
impl<'tcx> TyCtxtAt<'tcx>
sourcepub fn try_destructure_mir_constant_for_user_output(
self,
val: ConstValue<'tcx>,
ty: Ty<'tcx>,
) -> Option<DestructuredConstant<'tcx>>
pub fn try_destructure_mir_constant_for_user_output( self, val: ConstValue<'tcx>, ty: Ty<'tcx>, ) -> Option<DestructuredConstant<'tcx>>
Tries to destructure an mir::Const
ADT or array into its variant index
and its field values. This should only be used for pretty printing.
sourcepub fn const_caller_location(
self,
file: Symbol,
line: u32,
col: u32,
) -> ConstValue<'tcx>
pub fn const_caller_location( self, file: Symbol, line: u32, col: u32, ) -> ConstValue<'tcx>
Getting a &core::panic::Location referring to a span.
sourcepub fn is_eligible_for_coverage(self, key: LocalDefId) -> bool
pub fn is_eligible_for_coverage(self, key: LocalDefId) -> bool
Returns true
if this def is a function-like thing that is eligible for
coverage instrumentation under -Cinstrument-coverage
.
(Eligible functions might nevertheless be skipped for other reasons.)
sourcepub fn build_mir(self, key: LocalDefId) -> Body<'tcx>
pub fn build_mir(self, key: LocalDefId) -> Body<'tcx>
Create the MIR for a given DefId
- this includes
unreachable code.
You do not want to call this yourself, instead use the cached version
via mir_built
sourcepub fn import_source_files(self, key: CrateNum)
pub fn import_source_files(self, key: CrateNum)
Imports all SourceFile
s from the given crate into the current session.
This normally happens automatically when we decode a Span
from
that crate’s metadata - however, the incr comp cache needs
to trigger this manually when decoding a foreign Span
pub fn expn_hash_to_expn_id( self, cnum: CrateNum, index_guess: u32, hash: ExpnHash, ) -> ExpnId
sourcepub fn def_path_hash_to_def_id_extern(
self,
hash: DefPathHash,
stable_crate_id: StableCrateId,
) -> DefId
pub fn def_path_hash_to_def_id_extern( self, hash: DefPathHash, stable_crate_id: StableCrateId, ) -> DefId
Converts a DefPathHash
to its corresponding DefId
in the current compilation
session, if it still exists. This is used during incremental compilation to
turn a deserialized DefPathHash
into its current DefId
.
Will fetch a DefId from a DefPathHash for a foreign crate.
sourcepub fn thir_tree(self, key: LocalDefId) -> String
pub fn thir_tree(self, key: LocalDefId) -> String
Create a THIR tree for debugging.
sourcepub fn thir_flat(self, key: LocalDefId) -> String
pub fn thir_flat(self, key: LocalDefId) -> String
Create a list-like THIR representation for debugging.
sourcepub fn should_codegen_locally(self, instance: Instance<'tcx>) -> bool
pub fn should_codegen_locally(self, instance: Instance<'tcx>) -> bool
Returns true
if we should codegen an instance in the local crate, or returns false
if we
can just link to the upstream crate and therefore don’t need a mono item.
source§impl<'tcx> TyCtxtAt<'tcx>
impl<'tcx> TyCtxtAt<'tcx>
sourcepub fn create_def(
self,
parent: LocalDefId,
name: Symbol,
def_kind: DefKind,
) -> TyCtxtFeed<'tcx, LocalDefId>
pub fn create_def( self, parent: LocalDefId, name: Symbol, def_kind: DefKind, ) -> TyCtxtFeed<'tcx, LocalDefId>
Create a new definition within the incr. comp. engine.
source§impl<'tcx> TyCtxtAt<'tcx>
impl<'tcx> TyCtxtAt<'tcx>
sourcepub fn trigger_delayed_bug(self, key: impl IntoQueryParam<DefId>)
pub fn trigger_delayed_bug(self, key: impl IntoQueryParam<DefId>)
This exists purely for testing the interactions between delayed bugs and incremental.
sourcepub fn registered_tools(self, key: ()) -> &'tcx RegisteredTools
pub fn registered_tools(self, key: ()) -> &'tcx RegisteredTools
Collects the list of all tools registered using #![register_tool]
.
sourcepub fn early_lint_checks(self, key: ())
pub fn early_lint_checks(self, key: ())
[query description - consider adding a doc-comment!] perform lints prior to macro expansion
sourcepub fn resolutions(self, key: ()) -> &'tcx ResolverGlobalCtxt
pub fn resolutions(self, key: ()) -> &'tcx ResolverGlobalCtxt
[query description - consider adding a doc-comment!] getting the resolver outputs
sourcepub fn resolver_for_lowering_raw(
self,
key: (),
) -> (&'tcx Steal<(ResolverAstLowering, Lrc<Crate>)>, &'tcx ResolverGlobalCtxt)
pub fn resolver_for_lowering_raw( self, key: (), ) -> (&'tcx Steal<(ResolverAstLowering, Lrc<Crate>)>, &'tcx ResolverGlobalCtxt)
[query description - consider adding a doc-comment!] getting the resolver for lowering
sourcepub fn source_span(self, key: impl IntoQueryParam<LocalDefId>) -> Span
pub fn source_span(self, key: impl IntoQueryParam<LocalDefId>) -> Span
Return the span for a definition.
Contrary to def_span
below, this query returns the full absolute span of the definition.
This span is meant for dep-tracking rather than diagnostics. It should not be used outside
of rustc_middle::hir::source_map.
sourcepub fn hir_crate(self, key: ()) -> &'tcx Crate<'tcx>
pub fn hir_crate(self, key: ()) -> &'tcx Crate<'tcx>
Represents crate as a whole (as distinct from the top-level crate module).
If you call hir_crate
(e.g., indirectly by calling tcx.hir().krate()
),
we will have to assume that any change means that you need to be recompiled.
This is because the hir_crate
query gives you access to all other items.
To avoid this fate, do not call tcx.hir().krate()
; instead,
prefer wrappers like tcx.visit_all_items_in_krate()
.
sourcepub fn hir_crate_items(self, key: ()) -> &'tcx ModuleItems
pub fn hir_crate_items(self, key: ()) -> &'tcx ModuleItems
All items in the crate.
sourcepub fn hir_module_items(self, key: LocalModDefId) -> &'tcx ModuleItems
pub fn hir_module_items(self, key: LocalModDefId) -> &'tcx ModuleItems
The items in a module.
This can be conveniently accessed by tcx.hir().visit_item_likes_in_module
.
Avoid calling this query directly.
sourcepub fn local_def_id_to_hir_id(
self,
key: impl IntoQueryParam<LocalDefId>,
) -> HirId
pub fn local_def_id_to_hir_id( self, key: impl IntoQueryParam<LocalDefId>, ) -> HirId
Returns HIR ID for the given LocalDefId
.
sourcepub fn hir_owner_parent(self, key: OwnerId) -> HirId
pub fn hir_owner_parent(self, key: OwnerId) -> HirId
Gives access to the HIR node’s parent for the HIR owner key
.
This can be conveniently accessed by methods on tcx.hir()
.
Avoid calling this query directly.
sourcepub fn opt_hir_owner_nodes(
self,
key: impl IntoQueryParam<LocalDefId>,
) -> Option<&'tcx OwnerNodes<'tcx>>
pub fn opt_hir_owner_nodes( self, key: impl IntoQueryParam<LocalDefId>, ) -> Option<&'tcx OwnerNodes<'tcx>>
Gives access to the HIR nodes and bodies inside key
if it’s a HIR owner.
This can be conveniently accessed by methods on tcx.hir()
.
Avoid calling this query directly.
sourcepub fn hir_attrs(self, key: OwnerId) -> &'tcx AttributeMap<'tcx>
pub fn hir_attrs(self, key: OwnerId) -> &'tcx AttributeMap<'tcx>
Gives access to the HIR attributes inside the HIR owner key
.
This can be conveniently accessed by methods on tcx.hir()
.
Avoid calling this query directly.
sourcepub fn const_param_default(
self,
key: impl IntoQueryParam<DefId>,
) -> EarlyBinder<'tcx, Const<'tcx>>
pub fn const_param_default( self, key: impl IntoQueryParam<DefId>, ) -> EarlyBinder<'tcx, Const<'tcx>>
Given the def_id of a const-generic parameter, computes the associated default const
parameter. e.g. fn example<const N: usize=3>
called on N
would return 3
.
sourcepub fn type_of(
self,
key: impl IntoQueryParam<DefId>,
) -> EarlyBinder<'tcx, Ty<'tcx>>
pub fn type_of( self, key: impl IntoQueryParam<DefId>, ) -> EarlyBinder<'tcx, Ty<'tcx>>
sourcepub fn type_of_opaque(
self,
key: impl IntoQueryParam<DefId>,
) -> Result<EarlyBinder<'tcx, Ty<'tcx>>, CyclePlaceholder>
pub fn type_of_opaque( self, key: impl IntoQueryParam<DefId>, ) -> Result<EarlyBinder<'tcx, Ty<'tcx>>, CyclePlaceholder>
Specialized instance of type_of
that detects cycles that are due to
revealing opaque because of an auto trait bound. Unless CyclePlaceholder
needs
to be handled separately, call type_of
instead.
sourcepub fn type_alias_is_lazy(self, key: impl IntoQueryParam<DefId>) -> bool
pub fn type_alias_is_lazy(self, key: impl IntoQueryParam<DefId>) -> bool
[query description - consider adding a doc-comment!] computing whether {path}
is a lazy type alias
sourcepub fn collect_return_position_impl_trait_in_trait_tys(
self,
key: impl IntoQueryParam<DefId>,
) -> Result<&'tcx DefIdMap<EarlyBinder<'tcx, Ty<'tcx>>>, ErrorGuaranteed>
pub fn collect_return_position_impl_trait_in_trait_tys( self, key: impl IntoQueryParam<DefId>, ) -> Result<&'tcx DefIdMap<EarlyBinder<'tcx, Ty<'tcx>>>, ErrorGuaranteed>
[query description - consider adding a doc-comment!] comparing an impl and trait method signature, inferring any hidden impl Trait
types in the process
sourcepub fn is_type_alias_impl_trait(self, key: impl IntoQueryParam<DefId>) -> bool
pub fn is_type_alias_impl_trait(self, key: impl IntoQueryParam<DefId>) -> bool
[query description - consider adding a doc-comment!] determine whether the opaque is a type-alias impl trait
sourcepub fn unsizing_params_for_adt(
self,
key: impl IntoQueryParam<DefId>,
) -> &'tcx BitSet<u32>
pub fn unsizing_params_for_adt( self, key: impl IntoQueryParam<DefId>, ) -> &'tcx BitSet<u32>
[query description - consider adding a doc-comment!] determining what parameters of tcx.def_path_str(key)
can participate in unsizing
sourcepub fn analysis(self, key: ()) -> Result<(), ErrorGuaranteed>
pub fn analysis(self, key: ()) -> Result<(), ErrorGuaranteed>
The root query triggering all analysis passes like typeck or borrowck.
sourcepub fn check_expectations(self, key: Option<Symbol>)
pub fn check_expectations(self, key: Option<Symbol>)
This query checks the fulfillment of collected lint expectations. All lint emitting queries have to be done before this is executed to ensure that all expectations can be fulfilled.
This is an extra query to enable other drivers (like rustdoc) to
only execute a small subset of the analysis
query, while allowing
lints to be expected. In rustc, this query will be executed as part of
the analysis
query and doesn’t have to be called a second time.
Tools can additionally pass in a tool filter. That will restrict the
expectations to only trigger for lints starting with the listed tool
name. This is useful for cases were not all linting code from rustc
was called. With the default None
all registered lints will also
be checked for expectation fulfillment.
sourcepub fn generics_of(self, key: impl IntoQueryParam<DefId>) -> &'tcx Generics
pub fn generics_of(self, key: impl IntoQueryParam<DefId>) -> &'tcx Generics
Maps from the DefId
of an item (trait/struct/enum/fn) to its
associated generics.
sourcepub fn predicates_of(
self,
key: impl IntoQueryParam<DefId>,
) -> GenericPredicates<'tcx>
pub fn predicates_of( self, key: impl IntoQueryParam<DefId>, ) -> GenericPredicates<'tcx>
Maps from the DefId
of an item (trait/struct/enum/fn) to the
predicates (where-clauses) that must be proven true in order
to reference it. This is almost always the “predicates query”
that you want.
predicates_of
builds on predicates_defined_on
– in fact,
it is almost always the same as that query, except for the
case of traits. For traits, predicates_of
contains
an additional Self: Trait<...>
predicate that users don’t
actually write. This reflects the fact that to invoke the
trait (e.g., via Default::default
) you must supply types
that actually implement the trait. (However, this extra
predicate gets in the way of some checks, which are intended
to operate over only the actual where-clauses written by the
user.)
sourcepub fn opaque_types_defined_by(
self,
key: impl IntoQueryParam<LocalDefId>,
) -> &'tcx List<LocalDefId>
pub fn opaque_types_defined_by( self, key: impl IntoQueryParam<LocalDefId>, ) -> &'tcx List<LocalDefId>
[query description - consider adding a doc-comment!] computing the opaque types defined by tcx.def_path_str(key.to_def_id())
sourcepub fn explicit_item_bounds(
self,
key: impl IntoQueryParam<DefId>,
) -> EarlyBinder<'tcx, &'tcx [(Clause<'tcx>, Span)]>
pub fn explicit_item_bounds( self, key: impl IntoQueryParam<DefId>, ) -> EarlyBinder<'tcx, &'tcx [(Clause<'tcx>, Span)]>
Returns the list of bounds that are required to be satsified by a implementation or definition. For associated types, these must be satisfied for an implementation to be well-formed, and for opaque types, these are required to be satisfied by the hidden-type of the opaque.
Syntactially, these are the bounds written on the trait’s type
definition, or those after the impl
keyword for an opaque:
type X: Bound + 'lt
// ^^^^^^^^^^^
impl Debug + Display
// ^^^^^^^^^^^^^^^
key
is the DefId
of the associated type or opaque type.
Bounds from the parent (e.g. with nested impl trait) are not included.
sourcepub fn explicit_item_super_predicates(
self,
key: impl IntoQueryParam<DefId>,
) -> EarlyBinder<'tcx, &'tcx [(Clause<'tcx>, Span)]>
pub fn explicit_item_super_predicates( self, key: impl IntoQueryParam<DefId>, ) -> EarlyBinder<'tcx, &'tcx [(Clause<'tcx>, Span)]>
The set of item bounds (see TyCtxt::explicit_item_bounds
) that
share the Self
type of the item. These are a subset of the bounds
that may explicitly be used for things like closure signature
deduction.
sourcepub fn item_bounds(
self,
key: impl IntoQueryParam<DefId>,
) -> EarlyBinder<'tcx, Clauses<'tcx>>
pub fn item_bounds( self, key: impl IntoQueryParam<DefId>, ) -> EarlyBinder<'tcx, Clauses<'tcx>>
Elaborated version of the predicates from explicit_item_bounds
.
For example:
trait MyTrait {
type MyAType: Eq + ?Sized;
}
explicit_item_bounds
returns [<Self as MyTrait>::MyAType: Eq]
,
and item_bounds
returns
[
<Self as Trait>::MyAType: Eq,
<Self as Trait>::MyAType: PartialEq<<Self as Trait>::MyAType>
]
Bounds from the parent (e.g. with nested impl trait) are not included.
sourcepub fn item_super_predicates(
self,
key: impl IntoQueryParam<DefId>,
) -> EarlyBinder<'tcx, Clauses<'tcx>>
pub fn item_super_predicates( self, key: impl IntoQueryParam<DefId>, ) -> EarlyBinder<'tcx, Clauses<'tcx>>
[query description - consider adding a doc-comment!] elaborating item assumptions for tcx.def_path_str(key)
sourcepub fn item_non_self_assumptions(
self,
key: impl IntoQueryParam<DefId>,
) -> EarlyBinder<'tcx, Clauses<'tcx>>
pub fn item_non_self_assumptions( self, key: impl IntoQueryParam<DefId>, ) -> EarlyBinder<'tcx, Clauses<'tcx>>
[query description - consider adding a doc-comment!] elaborating item assumptions for tcx.def_path_str(key)
sourcepub fn native_libraries(self, key: CrateNum) -> &'tcx Vec<NativeLib>
pub fn native_libraries(self, key: CrateNum) -> &'tcx Vec<NativeLib>
Look up all native libraries this crate depends on. These are assembled from the following places:
extern
blocks (depending on theirlink
attributes)- the
libs
(-l
) option
sourcepub fn shallow_lint_levels_on(self, key: OwnerId) -> &'tcx ShallowLintLevelMap
pub fn shallow_lint_levels_on(self, key: OwnerId) -> &'tcx ShallowLintLevelMap
[query description - consider adding a doc-comment!] looking up lint levels for tcx.def_path_str(key)
sourcepub fn lint_expectations(
self,
key: (),
) -> &'tcx Vec<(LintExpectationId, LintExpectation)>
pub fn lint_expectations( self, key: (), ) -> &'tcx Vec<(LintExpectationId, LintExpectation)>
[query description - consider adding a doc-comment!] computing #[expect]
ed lints in this crate
sourcepub fn expn_that_defined(self, key: impl IntoQueryParam<DefId>) -> ExpnId
pub fn expn_that_defined(self, key: impl IntoQueryParam<DefId>) -> ExpnId
[query description - consider adding a doc-comment!] getting the expansion that defined tcx.def_path_str(key)
sourcepub fn is_panic_runtime(self, key: CrateNum) -> bool
pub fn is_panic_runtime(self, key: CrateNum) -> bool
[query description - consider adding a doc-comment!] checking if the crate is_panic_runtime
sourcepub fn representability(
self,
key: impl IntoQueryParam<LocalDefId>,
) -> Representability
pub fn representability( self, key: impl IntoQueryParam<LocalDefId>, ) -> Representability
Checks whether a type is representable or infinitely sized
sourcepub fn representability_adt_ty(self, key: Ty<'tcx>) -> Representability
pub fn representability_adt_ty(self, key: Ty<'tcx>) -> Representability
An implementation detail for the representability
query
sourcepub fn params_in_repr(
self,
key: impl IntoQueryParam<DefId>,
) -> &'tcx BitSet<u32>
pub fn params_in_repr( self, key: impl IntoQueryParam<DefId>, ) -> &'tcx BitSet<u32>
Set of param indexes for type params that are in the type’s representation
sourcepub fn thir_body(
self,
key: impl IntoQueryParam<LocalDefId>,
) -> Result<(&'tcx Steal<Thir<'tcx>>, ExprId), ErrorGuaranteed>
pub fn thir_body( self, key: impl IntoQueryParam<LocalDefId>, ) -> Result<(&'tcx Steal<Thir<'tcx>>, ExprId), ErrorGuaranteed>
Fetch the THIR for a given body. If typeck for that body failed, returns an empty Thir
.
sourcepub fn mir_keys(self, key: ()) -> &'tcx FxIndexSet<LocalDefId>
pub fn mir_keys(self, key: ()) -> &'tcx FxIndexSet<LocalDefId>
Set of all the DefId
s in this crate that have MIR associated with
them. This includes all the body owners, but also things like struct
constructors.
sourcepub fn mir_const_qualif(self, key: impl IntoQueryParam<DefId>) -> ConstQualifs
pub fn mir_const_qualif(self, key: impl IntoQueryParam<DefId>) -> ConstQualifs
Maps DefId’s that have an associated mir::Body
to the result
of the MIR const-checking pass. This is the set of qualifs in
the final value of a const
.
sourcepub fn mir_built(
self,
key: impl IntoQueryParam<LocalDefId>,
) -> &'tcx Steal<Body<'tcx>>
pub fn mir_built( self, key: impl IntoQueryParam<LocalDefId>, ) -> &'tcx Steal<Body<'tcx>>
Build the MIR for a given DefId
and prepare it for const qualification.
See the rustc dev guide for more info.
sourcepub fn thir_abstract_const(
self,
key: impl IntoQueryParam<DefId>,
) -> Result<Option<EarlyBinder<'tcx, Const<'tcx>>>, ErrorGuaranteed>
pub fn thir_abstract_const( self, key: impl IntoQueryParam<DefId>, ) -> Result<Option<EarlyBinder<'tcx, Const<'tcx>>>, ErrorGuaranteed>
Try to build an abstract representation of the given constant.
sourcepub fn mir_drops_elaborated_and_const_checked(
self,
key: impl IntoQueryParam<LocalDefId>,
) -> &'tcx Steal<Body<'tcx>>
pub fn mir_drops_elaborated_and_const_checked( self, key: impl IntoQueryParam<LocalDefId>, ) -> &'tcx Steal<Body<'tcx>>
[query description - consider adding a doc-comment!] elaborating drops for tcx.def_path_str(key)
sourcepub fn mir_for_ctfe(self, key: impl IntoQueryParam<DefId>) -> &'tcx Body<'tcx>
pub fn mir_for_ctfe(self, key: impl IntoQueryParam<DefId>) -> &'tcx Body<'tcx>
[query description - consider adding a doc-comment!] caching mir of tcx.def_path_str(key)
for CTFE
sourcepub fn mir_promoted(
self,
key: impl IntoQueryParam<LocalDefId>,
) -> (&'tcx Steal<Body<'tcx>>, &'tcx Steal<IndexVec<Promoted, Body<'tcx>>>)
pub fn mir_promoted( self, key: impl IntoQueryParam<LocalDefId>, ) -> (&'tcx Steal<Body<'tcx>>, &'tcx Steal<IndexVec<Promoted, Body<'tcx>>>)
[query description - consider adding a doc-comment!] promoting constants in MIR for tcx.def_path_str(key)
sourcepub fn closure_typeinfo(
self,
key: impl IntoQueryParam<LocalDefId>,
) -> ClosureTypeInfo<'tcx>
pub fn closure_typeinfo( self, key: impl IntoQueryParam<LocalDefId>, ) -> ClosureTypeInfo<'tcx>
[query description - consider adding a doc-comment!] finding symbols for captures of closure tcx.def_path_str(key)
sourcepub fn closure_saved_names_of_captured_variables(
self,
key: impl IntoQueryParam<DefId>,
) -> &'tcx IndexVec<FieldIdx, Symbol>
pub fn closure_saved_names_of_captured_variables( self, key: impl IntoQueryParam<DefId>, ) -> &'tcx IndexVec<FieldIdx, Symbol>
Returns names of captured upvars for closures and coroutines.
Here are some examples:
name__field1__field2
when the upvar is captured by value._ref__name__field
when the upvar is captured by reference.
For coroutines this only contains upvars that are shared by all states.
sourcepub fn mir_coroutine_witnesses(
self,
key: impl IntoQueryParam<DefId>,
) -> &'tcx Option<CoroutineLayout<'tcx>>
pub fn mir_coroutine_witnesses( self, key: impl IntoQueryParam<DefId>, ) -> &'tcx Option<CoroutineLayout<'tcx>>
[query description - consider adding a doc-comment!] coroutine witness types for tcx.def_path_str(key)
sourcepub fn check_coroutine_obligations(
self,
key: impl IntoQueryParam<LocalDefId>,
) -> Result<(), ErrorGuaranteed>
pub fn check_coroutine_obligations( self, key: impl IntoQueryParam<LocalDefId>, ) -> Result<(), ErrorGuaranteed>
[query description - consider adding a doc-comment!] verify auto trait bounds for coroutine interior type tcx.def_path_str(key)
sourcepub fn optimized_mir(self, key: impl IntoQueryParam<DefId>) -> &'tcx Body<'tcx>
pub fn optimized_mir(self, key: impl IntoQueryParam<DefId>) -> &'tcx Body<'tcx>
MIR after our optimization passes have run. This is MIR that is ready for codegen. This is also the only query that can fetch non-local MIR, at present.
sourcepub fn coverage_attr_on(self, key: impl IntoQueryParam<LocalDefId>) -> bool
pub fn coverage_attr_on(self, key: impl IntoQueryParam<LocalDefId>) -> bool
Checks for the nearest #[coverage(off)]
or #[coverage(on)]
on
this def and any enclosing defs, up to the crate root.
Returns false
if #[coverage(off)]
was found, or true
if
either #[coverage(on)]
or no coverage attribute was found.
sourcepub fn coverage_ids_info(self, key: InstanceKind<'tcx>) -> &'tcx CoverageIdsInfo
pub fn coverage_ids_info(self, key: InstanceKind<'tcx>) -> &'tcx CoverageIdsInfo
Summarizes coverage IDs inserted by the InstrumentCoverage
MIR pass
(for compiler option -Cinstrument-coverage
), after MIR optimizations
have had a chance to potentially remove some of them.
sourcepub fn promoted_mir(
self,
key: impl IntoQueryParam<DefId>,
) -> &'tcx IndexVec<Promoted, Body<'tcx>>
pub fn promoted_mir( self, key: impl IntoQueryParam<DefId>, ) -> &'tcx IndexVec<Promoted, Body<'tcx>>
The DefId
is the DefId
of the containing MIR body. Promoteds do not have their own
DefId
. This function returns all promoteds in the specified body. The body references
promoteds by the DefId
and the mir::Promoted
index. This is necessary, because
after inlining a body may refer to promoteds from other bodies. In that case you still
need to use the DefId
of the original body.
sourcepub fn erase_regions_ty(self, key: Ty<'tcx>) -> Ty<'tcx>
pub fn erase_regions_ty(self, key: Ty<'tcx>) -> Ty<'tcx>
Erases regions from ty
to yield a new type.
Normally you would just use tcx.erase_regions(value)
,
however, which uses this query as a kind of cache.
sourcepub fn wasm_import_module_map(self, key: CrateNum) -> &'tcx DefIdMap<String>
pub fn wasm_import_module_map(self, key: CrateNum) -> &'tcx DefIdMap<String>
[query description - consider adding a doc-comment!] getting wasm import module map
sourcepub fn predicates_defined_on(
self,
key: impl IntoQueryParam<DefId>,
) -> GenericPredicates<'tcx>
pub fn predicates_defined_on( self, key: impl IntoQueryParam<DefId>, ) -> GenericPredicates<'tcx>
Maps from the DefId
of an item (trait/struct/enum/fn) to the
predicates (where-clauses) directly defined on it. This is
equal to the explicit_predicates_of
predicates plus the
inferred_outlives_of
predicates.
sourcepub fn trait_explicit_predicates_and_bounds(
self,
key: impl IntoQueryParam<LocalDefId>,
) -> GenericPredicates<'tcx>
pub fn trait_explicit_predicates_and_bounds( self, key: impl IntoQueryParam<LocalDefId>, ) -> GenericPredicates<'tcx>
Returns everything that looks like a predicate written explicitly by the user on a trait item.
Traits are unusual, because predicates on associated types are converted into bounds on that type for backwards compatibility:
trait X where Self::U: Copy { type U; }
becomes
trait X { type U: Copy; }
explicit_predicates_of
and explicit_item_bounds
will then take
the appropriate subsets of the predicates here.
sourcepub fn explicit_predicates_of(
self,
key: impl IntoQueryParam<DefId>,
) -> GenericPredicates<'tcx>
pub fn explicit_predicates_of( self, key: impl IntoQueryParam<DefId>, ) -> GenericPredicates<'tcx>
Returns the predicates written explicitly by the user.
You should probably use predicates_of
unless you’re looking for
predicates with explicit spans for diagnostics purposes.
sourcepub fn inferred_outlives_of(
self,
key: impl IntoQueryParam<DefId>,
) -> &'tcx [(Clause<'tcx>, Span)]
pub fn inferred_outlives_of( self, key: impl IntoQueryParam<DefId>, ) -> &'tcx [(Clause<'tcx>, Span)]
Returns the inferred outlives predicates (e.g., for struct Foo<'a, T> { x: &'a T }
, this would return T: 'a
).
sourcepub fn explicit_super_predicates_of(
self,
key: impl IntoQueryParam<DefId>,
) -> GenericPredicates<'tcx>
pub fn explicit_super_predicates_of( self, key: impl IntoQueryParam<DefId>, ) -> GenericPredicates<'tcx>
Maps from the DefId
of a trait to the list of super-predicates of the trait,
before elaboration (so it doesn’t contain transitive super-predicates). This
is a subset of the full list of predicates. We store these in a separate map
because we must evaluate them even during type conversion, often before the full
predicates are available (note that super-predicates must not be cyclic).
sourcepub fn explicit_implied_predicates_of(
self,
key: impl IntoQueryParam<DefId>,
) -> GenericPredicates<'tcx>
pub fn explicit_implied_predicates_of( self, key: impl IntoQueryParam<DefId>, ) -> GenericPredicates<'tcx>
The predicates of the trait that are implied during elaboration. This is a superset of the super-predicates of the trait, but a subset of the predicates of the trait. For regular traits, this includes all super-predicates and their associated type bounds. For trait aliases, currently, this includes all of the predicates of the trait alias.
sourcepub fn explicit_supertraits_containing_assoc_item(
self,
key: (DefId, Ident),
) -> GenericPredicates<'tcx>
pub fn explicit_supertraits_containing_assoc_item( self, key: (DefId, Ident), ) -> GenericPredicates<'tcx>
The Ident is the name of an associated type.The query returns only the subset
of supertraits that define the given associated type. This is used to avoid
cycles in resolving type-dependent associated item paths like T::Item
.
sourcepub fn type_param_predicates(
self,
key: (LocalDefId, LocalDefId, Ident),
) -> GenericPredicates<'tcx>
pub fn type_param_predicates( self, key: (LocalDefId, LocalDefId, Ident), ) -> GenericPredicates<'tcx>
To avoid cycles within the predicates of a single item we compute
per-type-parameter predicates for resolving T::AssocTy
.
sourcepub fn trait_def(self, key: impl IntoQueryParam<DefId>) -> &'tcx TraitDef
pub fn trait_def(self, key: impl IntoQueryParam<DefId>) -> &'tcx TraitDef
[query description - consider adding a doc-comment!] computing trait definition for tcx.def_path_str(key)
sourcepub fn adt_def(self, key: impl IntoQueryParam<DefId>) -> AdtDef<'tcx>
pub fn adt_def(self, key: impl IntoQueryParam<DefId>) -> AdtDef<'tcx>
[query description - consider adding a doc-comment!] computing ADT definition for tcx.def_path_str(key)
sourcepub fn adt_destructor(
self,
key: impl IntoQueryParam<DefId>,
) -> Option<Destructor>
pub fn adt_destructor( self, key: impl IntoQueryParam<DefId>, ) -> Option<Destructor>
[query description - consider adding a doc-comment!] computing Drop
impl for tcx.def_path_str(key)
sourcepub fn adt_async_destructor(
self,
key: impl IntoQueryParam<DefId>,
) -> Option<AsyncDestructor>
pub fn adt_async_destructor( self, key: impl IntoQueryParam<DefId>, ) -> Option<AsyncDestructor>
[query description - consider adding a doc-comment!] computing AsyncDrop
impl for tcx.def_path_str(key)
sourcepub fn adt_sized_constraint(
self,
key: impl IntoQueryParam<DefId>,
) -> Option<EarlyBinder<'tcx, Ty<'tcx>>>
pub fn adt_sized_constraint( self, key: impl IntoQueryParam<DefId>, ) -> Option<EarlyBinder<'tcx, Ty<'tcx>>>
[query description - consider adding a doc-comment!] computing the Sized
constraint for tcx.def_path_str(key)
sourcepub fn adt_dtorck_constraint(
self,
key: impl IntoQueryParam<DefId>,
) -> Result<&'tcx DropckConstraint<'tcx>, NoSolution>
pub fn adt_dtorck_constraint( self, key: impl IntoQueryParam<DefId>, ) -> Result<&'tcx DropckConstraint<'tcx>, NoSolution>
[query description - consider adding a doc-comment!] computing drop-check constraints for tcx.def_path_str(key)
sourcepub fn constness(self, key: impl IntoQueryParam<DefId>) -> Constness
pub fn constness(self, key: impl IntoQueryParam<DefId>) -> Constness
Returns true
if this is a const fn, use the is_const_fn
to know whether your crate
actually sees it as const fn (e.g., the const-fn-ness might be unstable and you might
not have the feature gate active).
Do not call this function manually. It is only meant to cache the base data for the
is_const_fn
function. Consider using is_const_fn
or is_const_fn_raw
instead.
sourcepub fn asyncness(self, key: impl IntoQueryParam<DefId>) -> Asyncness
pub fn asyncness(self, key: impl IntoQueryParam<DefId>) -> Asyncness
[query description - consider adding a doc-comment!] checking if the function is async: tcx.def_path_str(key)
sourcepub fn is_promotable_const_fn(self, key: impl IntoQueryParam<DefId>) -> bool
pub fn is_promotable_const_fn(self, key: impl IntoQueryParam<DefId>) -> bool
Returns true
if calls to the function may be promoted.
This is either because the function is e.g., a tuple-struct or tuple-variant
constructor, or because it has the #[rustc_promotable]
attribute. The attribute should
be removed in the future in favour of some form of check which figures out whether the
function does not inspect the bits of any of its arguments (so is essentially just a
constructor function).
sourcepub fn coroutine_kind(
self,
key: impl IntoQueryParam<DefId>,
) -> Option<CoroutineKind>
pub fn coroutine_kind( self, key: impl IntoQueryParam<DefId>, ) -> Option<CoroutineKind>
Returns Some(coroutine_kind)
if the node pointed to by def_id
is a coroutine.
sourcepub fn coroutine_for_closure(self, key: impl IntoQueryParam<DefId>) -> DefId
pub fn coroutine_for_closure(self, key: impl IntoQueryParam<DefId>) -> DefId
[query description - consider adding a doc-comment!] Given a coroutine-closure def id, return the def id of the coroutine returned by it
sourcepub fn crate_variances(self, key: ()) -> &'tcx CrateVariancesMap<'tcx>
pub fn crate_variances(self, key: ()) -> &'tcx CrateVariancesMap<'tcx>
Gets a map with the variance of every item; use variances_of
instead.
sourcepub fn variances_of(self, key: impl IntoQueryParam<DefId>) -> &'tcx [Variance]
pub fn variances_of(self, key: impl IntoQueryParam<DefId>) -> &'tcx [Variance]
Maps from the DefId
of a type or region parameter to its (inferred) variance.
sourcepub fn inferred_outlives_crate(self, key: ()) -> &'tcx CratePredicatesMap<'tcx>
pub fn inferred_outlives_crate(self, key: ()) -> &'tcx CratePredicatesMap<'tcx>
Maps from thee DefId
of a type to its (inferred) outlives.
sourcepub fn associated_item_def_ids(
self,
key: impl IntoQueryParam<DefId>,
) -> &'tcx [DefId]
pub fn associated_item_def_ids( self, key: impl IntoQueryParam<DefId>, ) -> &'tcx [DefId]
Maps from an impl/trait or struct/variant DefId
to a list of the DefId
s of its associated items or fields.
sourcepub fn associated_item(self, key: impl IntoQueryParam<DefId>) -> AssocItem
pub fn associated_item(self, key: impl IntoQueryParam<DefId>) -> AssocItem
Maps from a trait/impl item to the trait/impl item “descriptor”.
sourcepub fn associated_items(
self,
key: impl IntoQueryParam<DefId>,
) -> &'tcx AssocItems
pub fn associated_items( self, key: impl IntoQueryParam<DefId>, ) -> &'tcx AssocItems
Collects the associated items defined on a trait or impl.
sourcepub fn impl_item_implementor_ids(
self,
key: impl IntoQueryParam<DefId>,
) -> &'tcx DefIdMap<DefId>
pub fn impl_item_implementor_ids( self, key: impl IntoQueryParam<DefId>, ) -> &'tcx DefIdMap<DefId>
Maps from associated items on a trait to the corresponding associated
item on the impl specified by impl_id
.
For example, with the following code
struct Type {}
// DefId
trait Trait { // trait_id
fn f(); // trait_f
fn g() {} // trait_g
}
impl Trait for Type { // impl_id
fn f() {} // impl_f
fn g() {} // impl_g
}
The map returned for tcx.impl_item_implementor_ids(impl_id)
would be
{ trait_f: impl_f, trait_g: impl_g }
sourcepub fn associated_types_for_impl_traits_in_associated_fn(
self,
key: impl IntoQueryParam<DefId>,
) -> &'tcx [DefId]
pub fn associated_types_for_impl_traits_in_associated_fn( self, key: impl IntoQueryParam<DefId>, ) -> &'tcx [DefId]
Given fn_def_id
of a trait or of an impl that implements a given trait:
if fn_def_id
is the def id of a function defined inside a trait, then it creates and returns
the associated items that correspond to each impl trait in return position for that trait.
if fn_def_id
is the def id of a function defined inside an impl that implements a trait, then it
creates and returns the associated items that correspond to each impl trait in return position
of the implemented trait.
sourcepub fn associated_type_for_effects(
self,
key: impl IntoQueryParam<DefId>,
) -> Option<DefId>
pub fn associated_type_for_effects( self, key: impl IntoQueryParam<DefId>, ) -> Option<DefId>
[query description - consider adding a doc-comment!] creating associated items for effects in tcx.def_path_str(def_id)
sourcepub fn associated_type_for_impl_trait_in_trait(
self,
key: impl IntoQueryParam<LocalDefId>,
) -> LocalDefId
pub fn associated_type_for_impl_trait_in_trait( self, key: impl IntoQueryParam<LocalDefId>, ) -> LocalDefId
Given an impl trait in trait opaque_ty_def_id
, create and return the corresponding
associated item.
sourcepub fn impl_trait_header(
self,
key: impl IntoQueryParam<DefId>,
) -> Option<ImplTraitHeader<'tcx>>
pub fn impl_trait_header( self, key: impl IntoQueryParam<DefId>, ) -> Option<ImplTraitHeader<'tcx>>
Given an impl_id
, return the trait it implements along with some header information.
Return None
if this is an inherent impl.
sourcepub fn self_ty_of_trait_impl_enabling_order_dep_trait_object_hack(
self,
key: impl IntoQueryParam<DefId>,
) -> Option<EarlyBinder<'tcx, Ty<'tcx>>>
pub fn self_ty_of_trait_impl_enabling_order_dep_trait_object_hack( self, key: impl IntoQueryParam<DefId>, ) -> Option<EarlyBinder<'tcx, Ty<'tcx>>>
[query description - consider adding a doc-comment!] computing self type wrt issue #33140 tcx.def_path_str(key)
sourcepub fn inherent_impls(
self,
key: impl IntoQueryParam<DefId>,
) -> Result<&'tcx [DefId], ErrorGuaranteed>
pub fn inherent_impls( self, key: impl IntoQueryParam<DefId>, ) -> Result<&'tcx [DefId], ErrorGuaranteed>
Maps a DefId
of a type to a list of its inherent impls.
Contains implementations of methods that are inherent to a type.
Methods in these implementations don’t need to be exported.
sourcepub fn incoherent_impls(
self,
key: SimplifiedType,
) -> Result<&'tcx [DefId], ErrorGuaranteed>
pub fn incoherent_impls( self, key: SimplifiedType, ) -> Result<&'tcx [DefId], ErrorGuaranteed>
[query description - consider adding a doc-comment!] collecting all inherent impls for {:?}
sourcepub fn check_unsafety(self, key: impl IntoQueryParam<LocalDefId>)
pub fn check_unsafety(self, key: impl IntoQueryParam<LocalDefId>)
Unsafety-check this LocalDefId
.
sourcepub fn assumed_wf_types(
self,
key: impl IntoQueryParam<LocalDefId>,
) -> &'tcx [(Ty<'tcx>, Span)]
pub fn assumed_wf_types( self, key: impl IntoQueryParam<LocalDefId>, ) -> &'tcx [(Ty<'tcx>, Span)]
Returns the types assumed to be well formed while “inside” of the given item.
Note that we’ve liberated the late bound regions of function signatures, so this can not be used to check whether these types are well formed.
sourcepub fn assumed_wf_types_for_rpitit(
self,
key: impl IntoQueryParam<DefId>,
) -> &'tcx [(Ty<'tcx>, Span)]
pub fn assumed_wf_types_for_rpitit( self, key: impl IntoQueryParam<DefId>, ) -> &'tcx [(Ty<'tcx>, Span)]
We need to store the assumed_wf_types for an RPITIT so that impls of foreign traits with return-position impl trait in traits can inherit the right wf types.
sourcepub fn fn_sig(
self,
key: impl IntoQueryParam<DefId>,
) -> EarlyBinder<'tcx, PolyFnSig<'tcx>>
pub fn fn_sig( self, key: impl IntoQueryParam<DefId>, ) -> EarlyBinder<'tcx, PolyFnSig<'tcx>>
Computes the signature of the function.
sourcepub fn lint_mod(self, key: LocalModDefId)
pub fn lint_mod(self, key: LocalModDefId)
Performs lint checking for the module.
sourcepub fn check_unused_traits(self, key: ())
pub fn check_unused_traits(self, key: ())
[query description - consider adding a doc-comment!] checking unused trait imports in crate
sourcepub fn check_mod_attrs(self, key: LocalModDefId)
pub fn check_mod_attrs(self, key: LocalModDefId)
Checks the attributes in the module.
sourcepub fn check_mod_unstable_api_usage(self, key: LocalModDefId)
pub fn check_mod_unstable_api_usage(self, key: LocalModDefId)
Checks for uses of unstable APIs in the module.
sourcepub fn check_mod_const_bodies(self, key: LocalModDefId)
pub fn check_mod_const_bodies(self, key: LocalModDefId)
Checks the const bodies in the module for illegal operations (e.g. if
or loop
).
sourcepub fn check_mod_loops(self, key: LocalModDefId)
pub fn check_mod_loops(self, key: LocalModDefId)
Checks the loops in the module.
sourcepub fn check_mod_naked_functions(self, key: LocalModDefId)
pub fn check_mod_naked_functions(self, key: LocalModDefId)
[query description - consider adding a doc-comment!] checking naked functions in describe_as_module(key, tcx)
sourcepub fn check_mod_privacy(self, key: LocalModDefId)
pub fn check_mod_privacy(self, key: LocalModDefId)
[query description - consider adding a doc-comment!] checking privacy in describe_as_module(key.to_local_def_id(), tcx)
sourcepub fn check_liveness(self, key: impl IntoQueryParam<LocalDefId>)
pub fn check_liveness(self, key: impl IntoQueryParam<LocalDefId>)
[query description - consider adding a doc-comment!] checking liveness of variables in tcx.def_path_str(key)
sourcepub fn live_symbols_and_ignored_derived_traits(
self,
key: (),
) -> &'tcx (LocalDefIdSet, LocalDefIdMap<Vec<(DefId, DefId)>>)
pub fn live_symbols_and_ignored_derived_traits( self, key: (), ) -> &'tcx (LocalDefIdSet, LocalDefIdMap<Vec<(DefId, DefId)>>)
Return the live symbols in the crate for dead code check.
The second return value maps from ADTs to ignored derived traits (e.g. Debug and Clone) and their respective impl (i.e., part of the derive macro)
sourcepub fn check_mod_deathness(self, key: LocalModDefId)
pub fn check_mod_deathness(self, key: LocalModDefId)
[query description - consider adding a doc-comment!] checking deathness of variables in describe_as_module(key, tcx)
sourcepub fn check_mod_type_wf(
self,
key: LocalModDefId,
) -> Result<(), ErrorGuaranteed>
pub fn check_mod_type_wf( self, key: LocalModDefId, ) -> Result<(), ErrorGuaranteed>
[query description - consider adding a doc-comment!] checking that types are well-formed in describe_as_module(key, tcx)
sourcepub fn coerce_unsized_info(
self,
key: impl IntoQueryParam<DefId>,
) -> Result<CoerceUnsizedInfo, ErrorGuaranteed>
pub fn coerce_unsized_info( self, key: impl IntoQueryParam<DefId>, ) -> Result<CoerceUnsizedInfo, ErrorGuaranteed>
Caches CoerceUnsized
kinds for impls on custom types.
sourcepub fn typeck(
self,
key: impl IntoQueryParam<LocalDefId>,
) -> &'tcx TypeckResults<'tcx>
pub fn typeck( self, key: impl IntoQueryParam<LocalDefId>, ) -> &'tcx TypeckResults<'tcx>
[query description - consider adding a doc-comment!] type-checking tcx.def_path_str(key)
sourcepub fn diagnostic_only_typeck(
self,
key: impl IntoQueryParam<LocalDefId>,
) -> &'tcx TypeckResults<'tcx>
pub fn diagnostic_only_typeck( self, key: impl IntoQueryParam<LocalDefId>, ) -> &'tcx TypeckResults<'tcx>
[query description - consider adding a doc-comment!] type-checking tcx.def_path_str(key)
sourcepub fn used_trait_imports(
self,
key: impl IntoQueryParam<LocalDefId>,
) -> &'tcx UnordSet<LocalDefId>
pub fn used_trait_imports( self, key: impl IntoQueryParam<LocalDefId>, ) -> &'tcx UnordSet<LocalDefId>
[query description - consider adding a doc-comment!] finding used_trait_imports tcx.def_path_str(key)
sourcepub fn coherent_trait(
self,
key: impl IntoQueryParam<DefId>,
) -> Result<(), ErrorGuaranteed>
pub fn coherent_trait( self, key: impl IntoQueryParam<DefId>, ) -> Result<(), ErrorGuaranteed>
[query description - consider adding a doc-comment!] coherence checking all impls of trait tcx.def_path_str(def_id)
sourcepub fn mir_borrowck(
self,
key: impl IntoQueryParam<LocalDefId>,
) -> &'tcx BorrowCheckResult<'tcx>
pub fn mir_borrowck( self, key: impl IntoQueryParam<LocalDefId>, ) -> &'tcx BorrowCheckResult<'tcx>
Borrow-checks the function body. If this is a closure, returns additional requirements that the closure’s creator must verify.
sourcepub fn crate_inherent_impls(
self,
key: (),
) -> Result<&'tcx CrateInherentImpls, ErrorGuaranteed>
pub fn crate_inherent_impls( self, key: (), ) -> Result<&'tcx CrateInherentImpls, ErrorGuaranteed>
Gets a complete map from all types to their inherent impls. Not meant to be used directly outside of coherence.
sourcepub fn crate_inherent_impls_overlap_check(
self,
key: (),
) -> Result<(), ErrorGuaranteed>
pub fn crate_inherent_impls_overlap_check( self, key: (), ) -> Result<(), ErrorGuaranteed>
Checks all types in the crate for overlap in their inherent impls. Reports errors. Not meant to be used directly outside of coherence.
sourcepub fn orphan_check_impl(
self,
key: impl IntoQueryParam<LocalDefId>,
) -> Result<(), ErrorGuaranteed>
pub fn orphan_check_impl( self, key: impl IntoQueryParam<LocalDefId>, ) -> Result<(), ErrorGuaranteed>
Checks whether all impls in the crate pass the overlap check, returning which impls fail it. If all impls are correct, the returned slice is empty.
sourcepub fn mir_callgraph_reachable(self, key: (Instance<'tcx>, LocalDefId)) -> bool
pub fn mir_callgraph_reachable(self, key: (Instance<'tcx>, LocalDefId)) -> bool
Check whether the function has any recursion that could cause the inliner to trigger a cycle. Returns the call stack causing the cycle. The call stack does not contain the current function, just all intermediate functions.
sourcepub fn mir_inliner_callees(
self,
key: InstanceKind<'tcx>,
) -> &'tcx [(DefId, GenericArgsRef<'tcx>)]
pub fn mir_inliner_callees( self, key: InstanceKind<'tcx>, ) -> &'tcx [(DefId, GenericArgsRef<'tcx>)]
Obtain all the calls into other local functions
sourcepub fn tag_for_variant(self, key: (Ty<'tcx>, VariantIdx)) -> Option<ScalarInt>
pub fn tag_for_variant(self, key: (Ty<'tcx>, VariantIdx)) -> Option<ScalarInt>
Computes the tag (if any) for a given type and variant.
sourcepub fn eval_to_allocation_raw(
self,
key: ParamEnvAnd<'tcx, GlobalId<'tcx>>,
) -> EvalToAllocationRawResult<'tcx>
pub fn eval_to_allocation_raw( self, key: ParamEnvAnd<'tcx, GlobalId<'tcx>>, ) -> EvalToAllocationRawResult<'tcx>
Evaluates a constant and returns the computed allocation.
Do not use this directly, use the eval_to_const_value
or eval_to_valtree
instead.
sourcepub fn eval_static_initializer(
self,
key: impl IntoQueryParam<DefId>,
) -> EvalStaticInitializerRawResult<'tcx>
pub fn eval_static_initializer( self, key: impl IntoQueryParam<DefId>, ) -> EvalStaticInitializerRawResult<'tcx>
Evaluate a static’s initializer, returning the allocation of the initializer’s memory.
sourcepub fn eval_to_const_value_raw(
self,
key: ParamEnvAnd<'tcx, GlobalId<'tcx>>,
) -> EvalToConstValueResult<'tcx>
pub fn eval_to_const_value_raw( self, key: ParamEnvAnd<'tcx, GlobalId<'tcx>>, ) -> EvalToConstValueResult<'tcx>
Evaluates const items or anonymous constants (such as enum variant explicit discriminants or array lengths) into a representation suitable for the type system and const generics.
Do not use this directly, use one of the following wrappers: tcx.const_eval_poly
,
tcx.const_eval_resolve
, tcx.const_eval_instance
, or tcx.const_eval_global_id
.
sourcepub fn eval_to_valtree(
self,
key: ParamEnvAnd<'tcx, GlobalId<'tcx>>,
) -> EvalToValTreeResult<'tcx>
pub fn eval_to_valtree( self, key: ParamEnvAnd<'tcx, GlobalId<'tcx>>, ) -> EvalToValTreeResult<'tcx>
Evaluate a constant and convert it to a type level constant or
return None
if that is not possible.
sourcepub fn valtree_to_const_val(
self,
key: (Ty<'tcx>, ValTree<'tcx>),
) -> ConstValue<'tcx>
pub fn valtree_to_const_val( self, key: (Ty<'tcx>, ValTree<'tcx>), ) -> ConstValue<'tcx>
Converts a type level constant value into ConstValue
sourcepub fn destructure_const(self, key: Const<'tcx>) -> DestructuredConst<'tcx>
pub fn destructure_const(self, key: Const<'tcx>) -> DestructuredConst<'tcx>
Destructures array, ADT or tuple constants into the constants of their fields.
sourcepub fn lit_to_const(
self,
key: LitToConstInput<'tcx>,
) -> Result<Const<'tcx>, LitToConstError>
pub fn lit_to_const( self, key: LitToConstInput<'tcx>, ) -> Result<Const<'tcx>, LitToConstError>
[query description - consider adding a doc-comment!] converting literal to const
sourcepub fn check_match(
self,
key: impl IntoQueryParam<LocalDefId>,
) -> Result<(), ErrorGuaranteed>
pub fn check_match( self, key: impl IntoQueryParam<LocalDefId>, ) -> Result<(), ErrorGuaranteed>
[query description - consider adding a doc-comment!] match-checking tcx.def_path_str(key)
sourcepub fn effective_visibilities(self, key: ()) -> &'tcx EffectiveVisibilities
pub fn effective_visibilities(self, key: ()) -> &'tcx EffectiveVisibilities
Performs part of the privacy check and computes effective visibilities.
sourcepub fn check_private_in_public(self, key: ())
pub fn check_private_in_public(self, key: ())
[query description - consider adding a doc-comment!] checking for private elements in public interfaces
sourcepub fn reachable_set(self, key: ()) -> &'tcx LocalDefIdSet
pub fn reachable_set(self, key: ()) -> &'tcx LocalDefIdSet
[query description - consider adding a doc-comment!] reachability
sourcepub fn region_scope_tree(
self,
key: impl IntoQueryParam<DefId>,
) -> &'tcx ScopeTree
pub fn region_scope_tree( self, key: impl IntoQueryParam<DefId>, ) -> &'tcx ScopeTree
Per-body region::ScopeTree
. The DefId
should be the owner DefId
for the body;
in the case of closures, this will be redirected to the enclosing function.
sourcepub fn mir_shims(self, key: InstanceKind<'tcx>) -> &'tcx Body<'tcx>
pub fn mir_shims(self, key: InstanceKind<'tcx>) -> &'tcx Body<'tcx>
Generates a MIR body for the shim.
sourcepub fn symbol_name(self, key: Instance<'tcx>) -> SymbolName<'tcx>
pub fn symbol_name(self, key: Instance<'tcx>) -> SymbolName<'tcx>
The symbol_name
query provides the symbol name for calling a
given instance from the local crate. In particular, it will also
look up the correct symbol name of instances from upstream crates.
sourcepub fn def_kind(self, key: impl IntoQueryParam<DefId>) -> DefKind
pub fn def_kind(self, key: impl IntoQueryParam<DefId>) -> DefKind
[query description - consider adding a doc-comment!] looking up definition kind of tcx.def_path_str(def_id)
sourcepub fn def_span(self, key: impl IntoQueryParam<DefId>) -> Span
pub fn def_span(self, key: impl IntoQueryParam<DefId>) -> Span
Gets the span for the definition.
sourcepub fn def_ident_span(self, key: impl IntoQueryParam<DefId>) -> Option<Span>
pub fn def_ident_span(self, key: impl IntoQueryParam<DefId>) -> Option<Span>
Gets the span for the identifier of the definition.
sourcepub fn lookup_stability(
self,
key: impl IntoQueryParam<DefId>,
) -> Option<Stability>
pub fn lookup_stability( self, key: impl IntoQueryParam<DefId>, ) -> Option<Stability>
[query description - consider adding a doc-comment!] looking up stability of tcx.def_path_str(def_id)
sourcepub fn lookup_const_stability(
self,
key: impl IntoQueryParam<DefId>,
) -> Option<ConstStability>
pub fn lookup_const_stability( self, key: impl IntoQueryParam<DefId>, ) -> Option<ConstStability>
[query description - consider adding a doc-comment!] looking up const stability of tcx.def_path_str(def_id)
sourcepub fn lookup_default_body_stability(
self,
key: impl IntoQueryParam<DefId>,
) -> Option<DefaultBodyStability>
pub fn lookup_default_body_stability( self, key: impl IntoQueryParam<DefId>, ) -> Option<DefaultBodyStability>
[query description - consider adding a doc-comment!] looking up default body stability of tcx.def_path_str(def_id)
sourcepub fn should_inherit_track_caller(
self,
key: impl IntoQueryParam<DefId>,
) -> bool
pub fn should_inherit_track_caller( self, key: impl IntoQueryParam<DefId>, ) -> bool
[query description - consider adding a doc-comment!] computing should_inherit_track_caller of tcx.def_path_str(def_id)
sourcepub fn lookup_deprecation_entry(
self,
key: impl IntoQueryParam<DefId>,
) -> Option<DeprecationEntry>
pub fn lookup_deprecation_entry( self, key: impl IntoQueryParam<DefId>, ) -> Option<DeprecationEntry>
[query description - consider adding a doc-comment!] checking whether tcx.def_path_str(def_id)
is deprecated
Determines whether an item is annotated with doc(hidden)
.
sourcepub fn is_doc_notable_trait(self, key: impl IntoQueryParam<DefId>) -> bool
pub fn is_doc_notable_trait(self, key: impl IntoQueryParam<DefId>) -> bool
Determines whether an item is annotated with doc(notable_trait)
.
sourcepub fn item_attrs(self, key: impl IntoQueryParam<DefId>) -> &'tcx [Attribute]
pub fn item_attrs(self, key: impl IntoQueryParam<DefId>) -> &'tcx [Attribute]
Returns the attributes on the item at def_id
.
Do not use this directly, use tcx.get_attrs
instead.
sourcepub fn codegen_fn_attrs(
self,
key: impl IntoQueryParam<DefId>,
) -> &'tcx CodegenFnAttrs
pub fn codegen_fn_attrs( self, key: impl IntoQueryParam<DefId>, ) -> &'tcx CodegenFnAttrs
[query description - consider adding a doc-comment!] computing codegen attributes of tcx.def_path_str(def_id)
sourcepub fn asm_target_features(
self,
key: impl IntoQueryParam<DefId>,
) -> &'tcx FxIndexSet<Symbol>
pub fn asm_target_features( self, key: impl IntoQueryParam<DefId>, ) -> &'tcx FxIndexSet<Symbol>
[query description - consider adding a doc-comment!] computing target features for inline asm of tcx.def_path_str(def_id)
sourcepub fn fn_arg_names(self, key: impl IntoQueryParam<DefId>) -> &'tcx [Ident]
pub fn fn_arg_names(self, key: impl IntoQueryParam<DefId>) -> &'tcx [Ident]
[query description - consider adding a doc-comment!] looking up function parameter names for tcx.def_path_str(def_id)
sourcepub fn rendered_const(self, key: impl IntoQueryParam<DefId>) -> &'tcx String
pub fn rendered_const(self, key: impl IntoQueryParam<DefId>) -> &'tcx String
Gets the rendered value of the specified constant or associated constant. Used by rustdoc.
sourcepub fn rendered_precise_capturing_args(
self,
key: impl IntoQueryParam<DefId>,
) -> Option<&'tcx [Symbol]>
pub fn rendered_precise_capturing_args( self, key: impl IntoQueryParam<DefId>, ) -> Option<&'tcx [Symbol]>
Gets the rendered precise capturing args for an opaque for use in rustdoc.
sourcepub fn impl_parent(self, key: impl IntoQueryParam<DefId>) -> Option<DefId>
pub fn impl_parent(self, key: impl IntoQueryParam<DefId>) -> Option<DefId>
[query description - consider adding a doc-comment!] computing specialization parent impl of tcx.def_path_str(def_id)
sourcepub fn is_ctfe_mir_available(self, key: impl IntoQueryParam<DefId>) -> bool
pub fn is_ctfe_mir_available(self, key: impl IntoQueryParam<DefId>) -> bool
[query description - consider adding a doc-comment!] checking if item has CTFE MIR available: tcx.def_path_str(key)
sourcepub fn is_mir_available(self, key: impl IntoQueryParam<DefId>) -> bool
pub fn is_mir_available(self, key: impl IntoQueryParam<DefId>) -> bool
[query description - consider adding a doc-comment!] checking if item has MIR available: tcx.def_path_str(key)
sourcepub fn own_existential_vtable_entries(
self,
key: impl IntoQueryParam<DefId>,
) -> &'tcx [DefId]
pub fn own_existential_vtable_entries( self, key: impl IntoQueryParam<DefId>, ) -> &'tcx [DefId]
[query description - consider adding a doc-comment!] finding all existential vtable entries for trait tcx.def_path_str(key)
sourcepub fn vtable_entries(self, key: PolyTraitRef<'tcx>) -> &'tcx [VtblEntry<'tcx>]
pub fn vtable_entries(self, key: PolyTraitRef<'tcx>) -> &'tcx [VtblEntry<'tcx>]
[query description - consider adding a doc-comment!] finding all vtable entries for trait tcx.def_path_str(key.def_id())
sourcepub fn first_method_vtable_slot(self, key: TraitRef<'tcx>) -> usize
pub fn first_method_vtable_slot(self, key: TraitRef<'tcx>) -> usize
[query description - consider adding a doc-comment!] finding the slot within the vtable of key.self_ty()
for the implementation of key.print_only_trait_name()
sourcepub fn supertrait_vtable_slot(self, key: (Ty<'tcx>, Ty<'tcx>)) -> Option<usize>
pub fn supertrait_vtable_slot(self, key: (Ty<'tcx>, Ty<'tcx>)) -> Option<usize>
[query description - consider adding a doc-comment!] finding the slot within vtable for trait object key.1
vtable ptr during trait upcasting coercion from key.0
vtable
sourcepub fn vtable_allocation(
self,
key: (Ty<'tcx>, Option<PolyExistentialTraitRef<'tcx>>),
) -> AllocId
pub fn vtable_allocation( self, key: (Ty<'tcx>, Option<PolyExistentialTraitRef<'tcx>>), ) -> AllocId
[query description - consider adding a doc-comment!] vtable const allocation for < key.0
as key.1.map(| trait_ref | format! ("{trait_ref}")).unwrap_or("_".to_owned())
>
sourcepub fn codegen_select_candidate(
self,
key: (ParamEnv<'tcx>, TraitRef<'tcx>),
) -> Result<&'tcx ImplSource<'tcx, ()>, CodegenObligationError>
pub fn codegen_select_candidate( self, key: (ParamEnv<'tcx>, TraitRef<'tcx>), ) -> Result<&'tcx ImplSource<'tcx, ()>, CodegenObligationError>
[query description - consider adding a doc-comment!] computing candidate for key.1
sourcepub fn all_local_trait_impls(
self,
key: (),
) -> &'tcx FxIndexMap<DefId, Vec<LocalDefId>>
pub fn all_local_trait_impls( self, key: (), ) -> &'tcx FxIndexMap<DefId, Vec<LocalDefId>>
Return all impl
blocks in the current crate.
sourcepub fn trait_impls_of(self, key: impl IntoQueryParam<DefId>) -> &'tcx TraitImpls
pub fn trait_impls_of(self, key: impl IntoQueryParam<DefId>) -> &'tcx TraitImpls
Given a trait trait_id
, return all known impl
blocks.
sourcepub fn specialization_graph_of(
self,
key: impl IntoQueryParam<DefId>,
) -> Result<&'tcx Graph, ErrorGuaranteed>
pub fn specialization_graph_of( self, key: impl IntoQueryParam<DefId>, ) -> Result<&'tcx Graph, ErrorGuaranteed>
[query description - consider adding a doc-comment!] building specialization graph of trait tcx.def_path_str(trait_id)
sourcepub fn object_safety_violations(
self,
key: impl IntoQueryParam<DefId>,
) -> &'tcx [ObjectSafetyViolation]
pub fn object_safety_violations( self, key: impl IntoQueryParam<DefId>, ) -> &'tcx [ObjectSafetyViolation]
[query description - consider adding a doc-comment!] determining object safety of trait tcx.def_path_str(trait_id)
sourcepub fn is_object_safe(self, key: impl IntoQueryParam<DefId>) -> bool
pub fn is_object_safe(self, key: impl IntoQueryParam<DefId>) -> bool
[query description - consider adding a doc-comment!] checking if trait tcx.def_path_str(trait_id)
is object safe
sourcepub fn param_env(self, key: impl IntoQueryParam<DefId>) -> ParamEnv<'tcx>
pub fn param_env(self, key: impl IntoQueryParam<DefId>) -> ParamEnv<'tcx>
Gets the ParameterEnvironment for a given item; this environment
will be in “user-facing” mode, meaning that it is suitable for
type-checking etc, and it does not normalize specializable
associated types. This is almost always what you want,
unless you are doing MIR optimizations, in which case you
might want to use reveal_all()
method to change modes.
sourcepub fn param_env_reveal_all_normalized(
self,
key: impl IntoQueryParam<DefId>,
) -> ParamEnv<'tcx>
pub fn param_env_reveal_all_normalized( self, key: impl IntoQueryParam<DefId>, ) -> ParamEnv<'tcx>
Like param_env
, but returns the ParamEnv
in Reveal::All
mode.
Prefer this over tcx.param_env(def_id).with_reveal_all_normalized(tcx)
,
as this method is more efficient.
sourcepub fn is_copy_raw(self, key: ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool
pub fn is_copy_raw(self, key: ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool
Trait selection queries. These are best used by invoking ty.is_copy_modulo_regions()
,
ty.is_copy()
, etc, since that will prune the environment where possible.
sourcepub fn is_sized_raw(self, key: ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool
pub fn is_sized_raw(self, key: ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool
Query backing Ty::is_sized
.
sourcepub fn is_freeze_raw(self, key: ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool
pub fn is_freeze_raw(self, key: ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool
Query backing Ty::is_freeze
.
sourcepub fn is_unpin_raw(self, key: ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool
pub fn is_unpin_raw(self, key: ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool
Query backing Ty::is_unpin
.
sourcepub fn needs_drop_raw(self, key: ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool
pub fn needs_drop_raw(self, key: ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool
Query backing Ty::needs_drop
.
sourcepub fn needs_async_drop_raw(self, key: ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool
pub fn needs_async_drop_raw(self, key: ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool
Query backing Ty::needs_async_drop
.
sourcepub fn has_significant_drop_raw(self, key: ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool
pub fn has_significant_drop_raw(self, key: ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool
Query backing Ty::has_significant_drop_raw
.
sourcepub fn has_structural_eq_impl(self, key: Ty<'tcx>) -> bool
pub fn has_structural_eq_impl(self, key: Ty<'tcx>) -> bool
Query backing Ty::is_structural_eq_shallow
.
This is only correct for ADTs. Call is_structural_eq_shallow
to handle all types
correctly.
sourcepub fn adt_drop_tys(
self,
key: impl IntoQueryParam<DefId>,
) -> Result<&'tcx List<Ty<'tcx>>, AlwaysRequiresDrop>
pub fn adt_drop_tys( self, key: impl IntoQueryParam<DefId>, ) -> Result<&'tcx List<Ty<'tcx>>, AlwaysRequiresDrop>
A list of types where the ADT requires drop if and only if any of
those types require drop. If the ADT is known to always need drop
then Err(AlwaysRequiresDrop)
is returned.
sourcepub fn adt_significant_drop_tys(
self,
key: impl IntoQueryParam<DefId>,
) -> Result<&'tcx List<Ty<'tcx>>, AlwaysRequiresDrop>
pub fn adt_significant_drop_tys( self, key: impl IntoQueryParam<DefId>, ) -> Result<&'tcx List<Ty<'tcx>>, AlwaysRequiresDrop>
A list of types where the ADT requires drop if and only if any of those types
has significant drop. A type marked with the attribute rustc_insignificant_dtor
is considered to not be significant. A drop is significant if it is implemented
by the user or does anything that will have any observable behavior (other than
freeing up memory). If the ADT is known to have a significant destructor then
Err(AlwaysRequiresDrop)
is returned.
sourcepub fn layout_of(
self,
key: ParamEnvAnd<'tcx, Ty<'tcx>>,
) -> Result<TyAndLayout<'tcx>, &'tcx LayoutError<'tcx>>
pub fn layout_of( self, key: ParamEnvAnd<'tcx, Ty<'tcx>>, ) -> Result<TyAndLayout<'tcx>, &'tcx LayoutError<'tcx>>
Computes the layout of a type. Note that this implicitly executes in “reveal all” mode, and will normalize the input type.
sourcepub fn fn_abi_of_fn_ptr(
self,
key: ParamEnvAnd<'tcx, (PolyFnSig<'tcx>, &'tcx List<Ty<'tcx>>)>,
) -> Result<&'tcx FnAbi<'tcx, Ty<'tcx>>, &'tcx FnAbiError<'tcx>>
pub fn fn_abi_of_fn_ptr( self, key: ParamEnvAnd<'tcx, (PolyFnSig<'tcx>, &'tcx List<Ty<'tcx>>)>, ) -> Result<&'tcx FnAbi<'tcx, Ty<'tcx>>, &'tcx FnAbiError<'tcx>>
Compute a FnAbi
suitable for indirect calls, i.e. to fn
pointers.
NB: this doesn’t handle virtual calls - those should use fn_abi_of_instance
instead, where the instance is an InstanceKind::Virtual
.
sourcepub fn fn_abi_of_instance(
self,
key: ParamEnvAnd<'tcx, (Instance<'tcx>, &'tcx List<Ty<'tcx>>)>,
) -> Result<&'tcx FnAbi<'tcx, Ty<'tcx>>, &'tcx FnAbiError<'tcx>>
pub fn fn_abi_of_instance( self, key: ParamEnvAnd<'tcx, (Instance<'tcx>, &'tcx List<Ty<'tcx>>)>, ) -> Result<&'tcx FnAbi<'tcx, Ty<'tcx>>, &'tcx FnAbiError<'tcx>>
Compute a FnAbi
suitable for declaring/defining an fn
instance, and for
direct calls to an fn
.
NB: that includes virtual calls, which are represented by “direct calls”
to an InstanceKind::Virtual
instance (of <dyn Trait as Trait>::fn
).
sourcepub fn dylib_dependency_formats(
self,
key: CrateNum,
) -> &'tcx [(CrateNum, LinkagePreference)]
pub fn dylib_dependency_formats( self, key: CrateNum, ) -> &'tcx [(CrateNum, LinkagePreference)]
[query description - consider adding a doc-comment!] getting dylib dependency formats of crate
sourcepub fn dependency_formats(self, key: ()) -> &'tcx Lrc<Dependencies>
pub fn dependency_formats(self, key: ()) -> &'tcx Lrc<Dependencies>
[query description - consider adding a doc-comment!] getting the linkage format of all dependencies
sourcepub fn is_compiler_builtins(self, key: CrateNum) -> bool
pub fn is_compiler_builtins(self, key: CrateNum) -> bool
[query description - consider adding a doc-comment!] checking if the crate is_compiler_builtins
sourcepub fn has_global_allocator(self, key: CrateNum) -> bool
pub fn has_global_allocator(self, key: CrateNum) -> bool
[query description - consider adding a doc-comment!] checking if the crate has_global_allocator
sourcepub fn has_alloc_error_handler(self, key: CrateNum) -> bool
pub fn has_alloc_error_handler(self, key: CrateNum) -> bool
[query description - consider adding a doc-comment!] checking if the crate has_alloc_error_handler
sourcepub fn has_panic_handler(self, key: CrateNum) -> bool
pub fn has_panic_handler(self, key: CrateNum) -> bool
[query description - consider adding a doc-comment!] checking if the crate has_panic_handler
sourcepub fn is_profiler_runtime(self, key: CrateNum) -> bool
pub fn is_profiler_runtime(self, key: CrateNum) -> bool
[query description - consider adding a doc-comment!] checking if a crate is #![profiler_runtime]
sourcepub fn has_ffi_unwind_calls(self, key: impl IntoQueryParam<LocalDefId>) -> bool
pub fn has_ffi_unwind_calls(self, key: impl IntoQueryParam<LocalDefId>) -> bool
[query description - consider adding a doc-comment!] checking if tcx.def_path_str(key)
contains FFI-unwind calls
sourcepub fn required_panic_strategy(self, key: CrateNum) -> Option<PanicStrategy>
pub fn required_panic_strategy(self, key: CrateNum) -> Option<PanicStrategy>
[query description - consider adding a doc-comment!] getting a crate’s required panic strategy
sourcepub fn panic_in_drop_strategy(self, key: CrateNum) -> PanicStrategy
pub fn panic_in_drop_strategy(self, key: CrateNum) -> PanicStrategy
[query description - consider adding a doc-comment!] getting a crate’s configured panic-in-drop strategy
sourcepub fn is_no_builtins(self, key: CrateNum) -> bool
pub fn is_no_builtins(self, key: CrateNum) -> bool
[query description - consider adding a doc-comment!] getting whether a crate has #![no_builtins]
sourcepub fn symbol_mangling_version(self, key: CrateNum) -> SymbolManglingVersion
pub fn symbol_mangling_version(self, key: CrateNum) -> SymbolManglingVersion
[query description - consider adding a doc-comment!] getting a crate’s symbol mangling version
sourcepub fn extern_crate(
self,
key: impl IntoQueryParam<DefId>,
) -> Option<&'tcx ExternCrate>
pub fn extern_crate( self, key: impl IntoQueryParam<DefId>, ) -> Option<&'tcx ExternCrate>
[query description - consider adding a doc-comment!] getting crate’s ExternCrateData
sourcepub fn specialization_enabled_in(self, key: CrateNum) -> bool
pub fn specialization_enabled_in(self, key: CrateNum) -> bool
[query description - consider adding a doc-comment!] checking whether the crate enabled specialization
/min_specialization
sourcepub fn specializes(self, key: (DefId, DefId)) -> bool
pub fn specializes(self, key: (DefId, DefId)) -> bool
[query description - consider adding a doc-comment!] computing whether impls specialize one another
sourcepub fn in_scope_traits_map(
self,
key: OwnerId,
) -> Option<&'tcx ItemLocalMap<Box<[TraitCandidate]>>>
pub fn in_scope_traits_map( self, key: OwnerId, ) -> Option<&'tcx ItemLocalMap<Box<[TraitCandidate]>>>
[query description - consider adding a doc-comment!] getting traits in scope at a block
sourcepub fn defaultness(self, key: impl IntoQueryParam<DefId>) -> Defaultness
pub fn defaultness(self, key: impl IntoQueryParam<DefId>) -> Defaultness
Returns whether the impl or associated function has the default
keyword.
sourcepub fn check_well_formed(self, key: OwnerId) -> Result<(), ErrorGuaranteed>
pub fn check_well_formed(self, key: OwnerId) -> Result<(), ErrorGuaranteed>
[query description - consider adding a doc-comment!] checking that tcx.def_path_str(key)
is well-formed
sourcepub fn reachable_non_generics(
self,
key: CrateNum,
) -> &'tcx DefIdMap<SymbolExportInfo>
pub fn reachable_non_generics( self, key: CrateNum, ) -> &'tcx DefIdMap<SymbolExportInfo>
[query description - consider adding a doc-comment!] looking up the exported symbols of a crate
sourcepub fn is_reachable_non_generic(self, key: impl IntoQueryParam<DefId>) -> bool
pub fn is_reachable_non_generic(self, key: impl IntoQueryParam<DefId>) -> bool
[query description - consider adding a doc-comment!] checking whether tcx.def_path_str(def_id)
is an exported symbol
sourcepub fn is_unreachable_local_definition(
self,
key: impl IntoQueryParam<LocalDefId>,
) -> bool
pub fn is_unreachable_local_definition( self, key: impl IntoQueryParam<LocalDefId>, ) -> bool
[query description - consider adding a doc-comment!] checking whether tcx.def_path_str(def_id)
is reachable from outside the crate
sourcepub fn upstream_monomorphizations(
self,
key: (),
) -> &'tcx DefIdMap<UnordMap<GenericArgsRef<'tcx>, CrateNum>>
pub fn upstream_monomorphizations( self, key: (), ) -> &'tcx DefIdMap<UnordMap<GenericArgsRef<'tcx>, CrateNum>>
The entire set of monomorphizations the local crate can safely
link to because they are exported from upstream crates. Do
not depend on this directly, as its value changes anytime
a monomorphization gets added or removed in any upstream
crate. Instead use the narrower upstream_monomorphizations_for
,
upstream_drop_glue_for
, upstream_async_drop_glue_for
, or,
even better, Instance::upstream_monomorphization()
.
sourcepub fn upstream_monomorphizations_for(
self,
key: impl IntoQueryParam<DefId>,
) -> Option<&'tcx UnordMap<GenericArgsRef<'tcx>, CrateNum>>
pub fn upstream_monomorphizations_for( self, key: impl IntoQueryParam<DefId>, ) -> Option<&'tcx UnordMap<GenericArgsRef<'tcx>, CrateNum>>
Returns the set of upstream monomorphizations available for the
generic function identified by the given def_id
. The query makes
sure to make a stable selection if the same monomorphization is
available in multiple upstream crates.
You likely want to call Instance::upstream_monomorphization()
instead of invoking this query directly.
sourcepub fn upstream_drop_glue_for(
self,
key: GenericArgsRef<'tcx>,
) -> Option<CrateNum>
pub fn upstream_drop_glue_for( self, key: GenericArgsRef<'tcx>, ) -> Option<CrateNum>
Returns the upstream crate that exports drop-glue for the given
type (args
is expected to be a single-item list containing the
type one wants drop-glue for).
This is a subset of upstream_monomorphizations_for
in order to
increase dep-tracking granularity. Otherwise adding or removing any
type with drop-glue in any upstream crate would invalidate all
functions calling drop-glue of an upstream type.
You likely want to call Instance::upstream_monomorphization()
instead of invoking this query directly.
NOTE: This query could easily be extended to also support other
common functions that have are large set of monomorphizations
(like Clone::clone
for example).
sourcepub fn upstream_async_drop_glue_for(
self,
key: GenericArgsRef<'tcx>,
) -> Option<CrateNum>
pub fn upstream_async_drop_glue_for( self, key: GenericArgsRef<'tcx>, ) -> Option<CrateNum>
Returns the upstream crate that exports async-drop-glue for
the given type (args
is expected to be a single-item list
containing the type one wants async-drop-glue for).
This is a subset of upstream_monomorphizations_for
in order
to increase dep-tracking granularity. Otherwise adding or
removing any type with async-drop-glue in any upstream crate
would invalidate all functions calling async-drop-glue of an
upstream type.
You likely want to call Instance::upstream_monomorphization()
instead of invoking this query directly.
NOTE: This query could easily be extended to also support other
common functions that have are large set of monomorphizations
(like Clone::clone
for example).
sourcepub fn foreign_modules(
self,
key: CrateNum,
) -> &'tcx FxIndexMap<DefId, ForeignModule>
pub fn foreign_modules( self, key: CrateNum, ) -> &'tcx FxIndexMap<DefId, ForeignModule>
Returns a list of all extern
blocks of a crate.
sourcepub fn clashing_extern_declarations(self, key: ())
pub fn clashing_extern_declarations(self, key: ())
Lint against extern fn
declarations having incompatible types.
sourcepub fn entry_fn(self, key: ()) -> Option<(DefId, EntryFnType)>
pub fn entry_fn(self, key: ()) -> Option<(DefId, EntryFnType)>
Identifies the entry-point (e.g., the main
function) for a given
crate, returning None
if there is no entry point (such as for library crates).
sourcepub fn proc_macro_decls_static(self, key: ()) -> Option<LocalDefId>
pub fn proc_macro_decls_static(self, key: ()) -> Option<LocalDefId>
Finds the rustc_proc_macro_decls
item of a crate.
sourcepub fn crate_hash(self, key: CrateNum) -> Svh
pub fn crate_hash(self, key: CrateNum) -> Svh
[query description - consider adding a doc-comment!] looking up the hash a crate
sourcepub fn crate_host_hash(self, key: CrateNum) -> Option<Svh>
pub fn crate_host_hash(self, key: CrateNum) -> Option<Svh>
Gets the hash for the host proc macro. Used to support -Z dual-proc-macro.
sourcepub fn extra_filename(self, key: CrateNum) -> &'tcx String
pub fn extra_filename(self, key: CrateNum) -> &'tcx String
Gets the extra data to put in each output filename for a crate.
For example, compiling the foo
crate with extra-filename=-a
creates a libfoo-b.rlib
file.
sourcepub fn crate_extern_paths(self, key: CrateNum) -> &'tcx Vec<PathBuf>
pub fn crate_extern_paths(self, key: CrateNum) -> &'tcx Vec<PathBuf>
Gets the paths where the crate came from in the file system.
sourcepub fn implementations_of_trait(
self,
key: (CrateNum, DefId),
) -> &'tcx [(DefId, Option<SimplifiedType>)]
pub fn implementations_of_trait( self, key: (CrateNum, DefId), ) -> &'tcx [(DefId, Option<SimplifiedType>)]
Given a crate and a trait, look up all impls of that trait in the crate.
Return (impl_id, self_ty)
.
sourcepub fn crate_incoherent_impls(
self,
key: (CrateNum, SimplifiedType),
) -> Result<&'tcx [DefId], ErrorGuaranteed>
pub fn crate_incoherent_impls( self, key: (CrateNum, SimplifiedType), ) -> Result<&'tcx [DefId], ErrorGuaranteed>
Collects all incoherent impls for the given crate and type.
Do not call this directly, but instead use the incoherent_impls
query.
This query is only used to get the data necessary for that query.
sourcepub fn native_library(
self,
key: impl IntoQueryParam<DefId>,
) -> Option<&'tcx NativeLib>
pub fn native_library( self, key: impl IntoQueryParam<DefId>, ) -> Option<&'tcx NativeLib>
Get the corresponding native library from the native_libraries
query
sourcepub fn resolve_bound_vars(self, key: OwnerId) -> &'tcx ResolveBoundVars
pub fn resolve_bound_vars(self, key: OwnerId) -> &'tcx ResolveBoundVars
Does lifetime resolution on items. Importantly, we can’t resolve
lifetimes directly on things like trait methods, because of trait params.
See rustc_resolve::late::lifetimes
for details.
sourcepub fn named_variable_map(
self,
key: OwnerId,
) -> Option<&'tcx FxIndexMap<ItemLocalId, ResolvedArg>>
pub fn named_variable_map( self, key: OwnerId, ) -> Option<&'tcx FxIndexMap<ItemLocalId, ResolvedArg>>
[query description - consider adding a doc-comment!] looking up a named region
sourcepub fn is_late_bound_map(
self,
key: OwnerId,
) -> Option<&'tcx FxIndexSet<ItemLocalId>>
pub fn is_late_bound_map( self, key: OwnerId, ) -> Option<&'tcx FxIndexSet<ItemLocalId>>
[query description - consider adding a doc-comment!] testing if a region is late bound
sourcepub fn object_lifetime_default(
self,
key: impl IntoQueryParam<DefId>,
) -> ObjectLifetimeDefault
pub fn object_lifetime_default( self, key: impl IntoQueryParam<DefId>, ) -> ObjectLifetimeDefault
For a given item’s generic parameter, gets the default lifetimes to be used
for each parameter if a trait object were to be passed for that parameter.
For example, for T
in struct Foo<'a, T>
, this would be 'static
.
For T
in struct Foo<'a, T: 'a>
, this would instead be 'a
.
This query will panic if passed something that is not a type parameter.
sourcepub fn late_bound_vars_map(
self,
key: OwnerId,
) -> Option<&'tcx FxIndexMap<ItemLocalId, Vec<BoundVariableKind>>>
pub fn late_bound_vars_map( self, key: OwnerId, ) -> Option<&'tcx FxIndexMap<ItemLocalId, Vec<BoundVariableKind>>>
[query description - consider adding a doc-comment!] looking up late bound vars
sourcepub fn visibility(self, key: impl IntoQueryParam<DefId>) -> Visibility<DefId>
pub fn visibility(self, key: impl IntoQueryParam<DefId>) -> Visibility<DefId>
Computes the visibility of the provided def_id
.
If the item from the def_id
doesn’t have a visibility, it will panic. For example
a generic type parameter will panic if you call this method on it:
use std::fmt::Debug;
pub trait Foo<T: Debug> {}
In here, if you call visibility
on T
, it’ll panic.
sourcepub fn inhabited_predicate_adt(
self,
key: impl IntoQueryParam<DefId>,
) -> InhabitedPredicate<'tcx>
pub fn inhabited_predicate_adt( self, key: impl IntoQueryParam<DefId>, ) -> InhabitedPredicate<'tcx>
[query description - consider adding a doc-comment!] computing the uninhabited predicate of {:?}
sourcepub fn inhabited_predicate_type(self, key: Ty<'tcx>) -> InhabitedPredicate<'tcx>
pub fn inhabited_predicate_type(self, key: Ty<'tcx>) -> InhabitedPredicate<'tcx>
Do not call this query directly: invoke Ty::inhabited_predicate
instead.
sourcepub fn dep_kind(self, key: CrateNum) -> CrateDepKind
pub fn dep_kind(self, key: CrateNum) -> CrateDepKind
[query description - consider adding a doc-comment!] fetching what a dependency looks like
sourcepub fn crate_name(self, key: CrateNum) -> Symbol
pub fn crate_name(self, key: CrateNum) -> Symbol
Gets the name of the crate.
sourcepub fn module_children(
self,
key: impl IntoQueryParam<DefId>,
) -> &'tcx [ModChild]
pub fn module_children( self, key: impl IntoQueryParam<DefId>, ) -> &'tcx [ModChild]
[query description - consider adding a doc-comment!] collecting child items of module tcx.def_path_str(def_id)
sourcepub fn extern_mod_stmt_cnum(
self,
key: impl IntoQueryParam<LocalDefId>,
) -> Option<CrateNum>
pub fn extern_mod_stmt_cnum( self, key: impl IntoQueryParam<LocalDefId>, ) -> Option<CrateNum>
[query description - consider adding a doc-comment!] computing crate imported by tcx.def_path_str(def_id)
sourcepub fn lib_features(self, key: CrateNum) -> &'tcx LibFeatures
pub fn lib_features(self, key: CrateNum) -> &'tcx LibFeatures
[query description - consider adding a doc-comment!] calculating the lib features defined in a crate
sourcepub fn stability_implications(
self,
key: CrateNum,
) -> &'tcx UnordMap<Symbol, Symbol>
pub fn stability_implications( self, key: CrateNum, ) -> &'tcx UnordMap<Symbol, Symbol>
[query description - consider adding a doc-comment!] calculating the implications between #[unstable]
features defined in a crate
sourcepub fn intrinsic_raw(
self,
key: impl IntoQueryParam<DefId>,
) -> Option<IntrinsicDef>
pub fn intrinsic_raw( self, key: impl IntoQueryParam<DefId>, ) -> Option<IntrinsicDef>
Whether the function is an intrinsic
sourcepub fn get_lang_items(self, key: ()) -> &'tcx LanguageItems
pub fn get_lang_items(self, key: ()) -> &'tcx LanguageItems
Returns the lang items defined in another crate by loading it from metadata.
sourcepub fn all_diagnostic_items(self, key: ()) -> &'tcx DiagnosticItems
pub fn all_diagnostic_items(self, key: ()) -> &'tcx DiagnosticItems
Returns all diagnostic items defined in all crates.
sourcepub fn defined_lang_items(self, key: CrateNum) -> &'tcx [(DefId, LangItem)]
pub fn defined_lang_items(self, key: CrateNum) -> &'tcx [(DefId, LangItem)]
Returns the lang items defined in another crate by loading it from metadata.
sourcepub fn diagnostic_items(self, key: CrateNum) -> &'tcx DiagnosticItems
pub fn diagnostic_items(self, key: CrateNum) -> &'tcx DiagnosticItems
Returns the diagnostic items defined in a crate.
sourcepub fn missing_lang_items(self, key: CrateNum) -> &'tcx [LangItem]
pub fn missing_lang_items(self, key: CrateNum) -> &'tcx [LangItem]
[query description - consider adding a doc-comment!] calculating the missing lang items in a crate
sourcepub fn visible_parent_map(self, key: ()) -> &'tcx DefIdMap<DefId>
pub fn visible_parent_map(self, key: ()) -> &'tcx DefIdMap<DefId>
The visible parent map is a map from every item to a visible parent. It prefers the shortest visible path to an item. Used for diagnostics, for example path trimming. The parents are modules, enums or traits.
sourcepub fn trimmed_def_paths(self, key: ()) -> &'tcx DefIdMap<Symbol>
pub fn trimmed_def_paths(self, key: ()) -> &'tcx DefIdMap<Symbol>
Collects the “trimmed”, shortest accessible paths to all items for diagnostics. See the provider docs for more info.
sourcepub fn missing_extern_crate_item(self, key: CrateNum) -> bool
pub fn missing_extern_crate_item(self, key: CrateNum) -> bool
[query description - consider adding a doc-comment!] seeing if we’re missing an extern crate
item for this crate
sourcepub fn used_crate_source(self, key: CrateNum) -> &'tcx Lrc<CrateSource>
pub fn used_crate_source(self, key: CrateNum) -> &'tcx Lrc<CrateSource>
[query description - consider adding a doc-comment!] looking at the source for a crate
sourcepub fn debugger_visualizers(
self,
key: CrateNum,
) -> &'tcx Vec<DebuggerVisualizerFile>
pub fn debugger_visualizers( self, key: CrateNum, ) -> &'tcx Vec<DebuggerVisualizerFile>
Returns the debugger visualizers defined for this crate.
NOTE: This query has to be marked eval_always
because it reads data
directly from disk that is not tracked anywhere else. I.e. it
represents a genuine input to the query system.
sourcepub fn postorder_cnums(self, key: ()) -> &'tcx [CrateNum]
pub fn postorder_cnums(self, key: ()) -> &'tcx [CrateNum]
[query description - consider adding a doc-comment!] generating a postorder list of CrateNums
sourcepub fn is_private_dep(self, key: CrateNum) -> bool
pub fn is_private_dep(self, key: CrateNum) -> bool
Returns whether or not the crate with CrateNum ‘cnum’ is marked as a private dependency
sourcepub fn allocator_kind(self, key: ()) -> Option<AllocatorKind>
pub fn allocator_kind(self, key: ()) -> Option<AllocatorKind>
[query description - consider adding a doc-comment!] getting the allocator kind for the current crate
sourcepub fn alloc_error_handler_kind(self, key: ()) -> Option<AllocatorKind>
pub fn alloc_error_handler_kind(self, key: ()) -> Option<AllocatorKind>
[query description - consider adding a doc-comment!] alloc error handler kind for the current crate
sourcepub fn upvars_mentioned(
self,
key: impl IntoQueryParam<DefId>,
) -> Option<&'tcx FxIndexMap<HirId, Upvar>>
pub fn upvars_mentioned( self, key: impl IntoQueryParam<DefId>, ) -> Option<&'tcx FxIndexMap<HirId, Upvar>>
[query description - consider adding a doc-comment!] collecting upvars mentioned in tcx.def_path_str(def_id)
sourcepub fn maybe_unused_trait_imports(self, key: ()) -> &'tcx FxIndexSet<LocalDefId>
pub fn maybe_unused_trait_imports(self, key: ()) -> &'tcx FxIndexSet<LocalDefId>
[query description - consider adding a doc-comment!] fetching potentially unused trait imports
sourcepub fn names_imported_by_glob_use(
self,
key: impl IntoQueryParam<LocalDefId>,
) -> &'tcx UnordSet<Symbol>
pub fn names_imported_by_glob_use( self, key: impl IntoQueryParam<LocalDefId>, ) -> &'tcx UnordSet<Symbol>
[query description - consider adding a doc-comment!] finding names imported by glob use for tcx.def_path_str(def_id)
sourcepub fn stability_index(self, key: ()) -> &'tcx Index
pub fn stability_index(self, key: ()) -> &'tcx Index
[query description - consider adding a doc-comment!] calculating the stability index for the local crate
sourcepub fn crates(self, key: ()) -> &'tcx [CrateNum]
pub fn crates(self, key: ()) -> &'tcx [CrateNum]
[query description - consider adding a doc-comment!] fetching all foreign CrateNum instances
sourcepub fn used_crates(self, key: ()) -> &'tcx [CrateNum]
pub fn used_crates(self, key: ()) -> &'tcx [CrateNum]
[query description - consider adding a doc-comment!] fetching CrateNum
s for all crates loaded non-speculatively
sourcepub fn traits(self, key: CrateNum) -> &'tcx [DefId]
pub fn traits(self, key: CrateNum) -> &'tcx [DefId]
A list of all traits in a crate, used by rustdoc and error reporting.
sourcepub fn trait_impls_in_crate(self, key: CrateNum) -> &'tcx [DefId]
pub fn trait_impls_in_crate(self, key: CrateNum) -> &'tcx [DefId]
[query description - consider adding a doc-comment!] fetching all trait impls in a crate
sourcepub fn exported_symbols(
self,
key: CrateNum,
) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportInfo)]
pub fn exported_symbols( self, key: CrateNum, ) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportInfo)]
The list of symbols exported from the given crate.
- All names contained in
exported_symbols(cnum)
are guaranteed to correspond to a publicly visible symbol incnum
machine code. - The
exported_symbols
sets of different crates do not intersect.
sourcepub fn collect_and_partition_mono_items(
self,
key: (),
) -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'tcx>])
pub fn collect_and_partition_mono_items( self, key: (), ) -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'tcx>])
[query description - consider adding a doc-comment!] collect_and_partition_mono_items
sourcepub fn is_codegened_item(self, key: impl IntoQueryParam<DefId>) -> bool
pub fn is_codegened_item(self, key: impl IntoQueryParam<DefId>) -> bool
[query description - consider adding a doc-comment!] determining whether tcx.def_path_str(def_id)
needs codegen
sourcepub fn codegen_unit(self, key: Symbol) -> &'tcx CodegenUnit<'tcx>
pub fn codegen_unit(self, key: Symbol) -> &'tcx CodegenUnit<'tcx>
[query description - consider adding a doc-comment!] getting codegen unit {sym}
sourcepub fn unused_generic_params(
self,
key: InstanceKind<'tcx>,
) -> UnusedGenericParams
pub fn unused_generic_params( self, key: InstanceKind<'tcx>, ) -> UnusedGenericParams
[query description - consider adding a doc-comment!] determining which generic parameters are unused by tcx.def_path_str(key.def_id())
sourcepub fn backend_optimization_level(self, key: ()) -> OptLevel
pub fn backend_optimization_level(self, key: ()) -> OptLevel
[query description - consider adding a doc-comment!] optimization level used by backend
sourcepub fn output_filenames(self, key: ()) -> &'tcx Arc<OutputFilenames>
pub fn output_filenames(self, key: ()) -> &'tcx Arc<OutputFilenames>
Return the filenames where output artefacts shall be stored.
This query returns an &Arc
because codegen backends need the value even after the TyCtxt
has been destroyed.
sourcepub fn normalize_canonicalized_projection_ty(
self,
key: CanonicalAliasGoal<'tcx>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, NormalizationResult<'tcx>>>, NoSolution>
pub fn normalize_canonicalized_projection_ty( self, key: CanonicalAliasGoal<'tcx>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, NormalizationResult<'tcx>>>, NoSolution>
Do not call this query directly: Invoke normalize
instead.
sourcepub fn normalize_canonicalized_weak_ty(
self,
key: CanonicalAliasGoal<'tcx>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, NormalizationResult<'tcx>>>, NoSolution>
pub fn normalize_canonicalized_weak_ty( self, key: CanonicalAliasGoal<'tcx>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, NormalizationResult<'tcx>>>, NoSolution>
Do not call this query directly: Invoke normalize
instead.
sourcepub fn normalize_canonicalized_inherent_projection_ty(
self,
key: CanonicalAliasGoal<'tcx>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, NormalizationResult<'tcx>>>, NoSolution>
pub fn normalize_canonicalized_inherent_projection_ty( self, key: CanonicalAliasGoal<'tcx>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, NormalizationResult<'tcx>>>, NoSolution>
Do not call this query directly: Invoke normalize
instead.
sourcepub fn try_normalize_generic_arg_after_erasing_regions(
self,
key: ParamEnvAnd<'tcx, GenericArg<'tcx>>,
) -> Result<GenericArg<'tcx>, NoSolution>
pub fn try_normalize_generic_arg_after_erasing_regions( self, key: ParamEnvAnd<'tcx, GenericArg<'tcx>>, ) -> Result<GenericArg<'tcx>, NoSolution>
Do not call this query directly: invoke try_normalize_erasing_regions
instead.
sourcepub fn implied_outlives_bounds_compat(
self,
key: CanonicalTyGoal<'tcx>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>, NoSolution>
pub fn implied_outlives_bounds_compat( self, key: CanonicalTyGoal<'tcx>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>, NoSolution>
[query description - consider adding a doc-comment!] computing implied outlives bounds for goal.value.value
sourcepub fn implied_outlives_bounds(
self,
key: CanonicalTyGoal<'tcx>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>, NoSolution>
pub fn implied_outlives_bounds( self, key: CanonicalTyGoal<'tcx>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>, NoSolution>
[query description - consider adding a doc-comment!] computing implied outlives bounds v2 for goal.value.value
sourcepub fn dropck_outlives(
self,
key: CanonicalTyGoal<'tcx>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>, NoSolution>
pub fn dropck_outlives( self, key: CanonicalTyGoal<'tcx>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>, NoSolution>
Do not call this query directly:
invoke DropckOutlives::new(dropped_ty)).fully_perform(typeck.infcx)
instead.
sourcepub fn evaluate_obligation(
self,
key: CanonicalPredicateGoal<'tcx>,
) -> Result<EvaluationResult, OverflowError>
pub fn evaluate_obligation( self, key: CanonicalPredicateGoal<'tcx>, ) -> Result<EvaluationResult, OverflowError>
Do not call this query directly: invoke infcx.predicate_may_hold()
or
infcx.predicate_must_hold()
instead.
sourcepub fn type_op_ascribe_user_type(
self,
key: CanonicalTypeOpAscribeUserTypeGoal<'tcx>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution>
pub fn type_op_ascribe_user_type( self, key: CanonicalTypeOpAscribeUserTypeGoal<'tcx>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution>
Do not call this query directly: part of the Eq
type-op
sourcepub fn type_op_eq(
self,
key: CanonicalTypeOpEqGoal<'tcx>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution>
pub fn type_op_eq( self, key: CanonicalTypeOpEqGoal<'tcx>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution>
Do not call this query directly: part of the Eq
type-op
sourcepub fn type_op_subtype(
self,
key: CanonicalTypeOpSubtypeGoal<'tcx>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution>
pub fn type_op_subtype( self, key: CanonicalTypeOpSubtypeGoal<'tcx>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution>
Do not call this query directly: part of the Subtype
type-op
sourcepub fn type_op_prove_predicate(
self,
key: CanonicalTypeOpProvePredicateGoal<'tcx>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution>
pub fn type_op_prove_predicate( self, key: CanonicalTypeOpProvePredicateGoal<'tcx>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution>
Do not call this query directly: part of the ProvePredicate
type-op
sourcepub fn type_op_normalize_ty(
self,
key: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, Ty<'tcx>>>, NoSolution>
pub fn type_op_normalize_ty( self, key: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, Ty<'tcx>>>, NoSolution>
Do not call this query directly: part of the Normalize
type-op
sourcepub fn type_op_normalize_clause(
self,
key: CanonicalTypeOpNormalizeGoal<'tcx, Clause<'tcx>>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, Clause<'tcx>>>, NoSolution>
pub fn type_op_normalize_clause( self, key: CanonicalTypeOpNormalizeGoal<'tcx, Clause<'tcx>>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, Clause<'tcx>>>, NoSolution>
Do not call this query directly: part of the Normalize
type-op
sourcepub fn type_op_normalize_poly_fn_sig(
self,
key: CanonicalTypeOpNormalizeGoal<'tcx, PolyFnSig<'tcx>>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, PolyFnSig<'tcx>>>, NoSolution>
pub fn type_op_normalize_poly_fn_sig( self, key: CanonicalTypeOpNormalizeGoal<'tcx, PolyFnSig<'tcx>>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, PolyFnSig<'tcx>>>, NoSolution>
Do not call this query directly: part of the Normalize
type-op
sourcepub fn type_op_normalize_fn_sig(
self,
key: CanonicalTypeOpNormalizeGoal<'tcx, FnSig<'tcx>>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, FnSig<'tcx>>>, NoSolution>
pub fn type_op_normalize_fn_sig( self, key: CanonicalTypeOpNormalizeGoal<'tcx, FnSig<'tcx>>, ) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, FnSig<'tcx>>>, NoSolution>
Do not call this query directly: part of the Normalize
type-op
sourcepub fn instantiate_and_check_impossible_predicates(
self,
key: (DefId, GenericArgsRef<'tcx>),
) -> bool
pub fn instantiate_and_check_impossible_predicates( self, key: (DefId, GenericArgsRef<'tcx>), ) -> bool
[query description - consider adding a doc-comment!] checking impossible instantiated predicates: tcx.def_path_str(key.0)
sourcepub fn is_impossible_associated_item(self, key: (DefId, DefId)) -> bool
pub fn is_impossible_associated_item(self, key: (DefId, DefId)) -> bool
[query description - consider adding a doc-comment!] checking if tcx.def_path_str(key.1)
is impossible to reference within tcx.def_path_str(key.0)
sourcepub fn method_autoderef_steps(
self,
key: CanonicalTyGoal<'tcx>,
) -> MethodAutoderefStepsResult<'tcx>
pub fn method_autoderef_steps( self, key: CanonicalTyGoal<'tcx>, ) -> MethodAutoderefStepsResult<'tcx>
[query description - consider adding a doc-comment!] computing autoderef types for goal.value.value
sourcepub fn supported_target_features(
self,
key: CrateNum,
) -> &'tcx UnordMap<String, Option<Symbol>>
pub fn supported_target_features( self, key: CrateNum, ) -> &'tcx UnordMap<String, Option<Symbol>>
[query description - consider adding a doc-comment!] looking up supported target features
sourcepub fn features_query(self, key: ()) -> &'tcx Features
pub fn features_query(self, key: ()) -> &'tcx Features
[query description - consider adding a doc-comment!] looking up enabled feature gates
sourcepub fn crate_for_resolver(self, key: ()) -> &'tcx Steal<(Crate, AttrVec)>
pub fn crate_for_resolver(self, key: ()) -> &'tcx Steal<(Crate, AttrVec)>
[query description - consider adding a doc-comment!] the ast before macro expansion and name resolution
sourcepub fn resolve_instance_raw(
self,
key: ParamEnvAnd<'tcx, (DefId, GenericArgsRef<'tcx>)>,
) -> Result<Option<Instance<'tcx>>, ErrorGuaranteed>
pub fn resolve_instance_raw( self, key: ParamEnvAnd<'tcx, (DefId, GenericArgsRef<'tcx>)>, ) -> Result<Option<Instance<'tcx>>, ErrorGuaranteed>
Attempt to resolve the given DefId
to an Instance
, for the
given generics args (GenericArgsRef
), returning one of:
Ok(Some(instance))
on successOk(None)
when theGenericArgsRef
are still too generic, and therefore don’t allow finding the finalInstance
Err(ErrorGuaranteed)
when theInstance
resolution process couldn’t complete due to errors elsewhere - this is distinct fromOk(None)
to avoid misleading diagnostics when an error has already been/will be emitted, for the original cause.
sourcepub fn reveal_opaque_types_in_bounds(self, key: Clauses<'tcx>) -> Clauses<'tcx>
pub fn reveal_opaque_types_in_bounds(self, key: Clauses<'tcx>) -> Clauses<'tcx>
[query description - consider adding a doc-comment!] revealing opaque types in {:?}
sourcepub fn limits(self, key: ()) -> Limits
pub fn limits(self, key: ()) -> Limits
[query description - consider adding a doc-comment!] looking up limits
sourcepub fn diagnostic_hir_wf_check(
self,
key: (Predicate<'tcx>, WellFormedLoc),
) -> &'tcx Option<ObligationCause<'tcx>>
pub fn diagnostic_hir_wf_check( self, key: (Predicate<'tcx>, WellFormedLoc), ) -> &'tcx Option<ObligationCause<'tcx>>
Performs an HIR-based well-formed check on the item with the given HirId
. If
we get an Unimplemented
error that matches the provided Predicate
, return
the cause of the newly created obligation.
This is only used by error-reporting code to get a better cause (in particular, a better
span) for an existing error. Therefore, it is best-effort, and may never handle
all of the cases that the normal ty::Ty
-based wfcheck does. This is fine,
because the ty::Ty
-based wfcheck is always run.
sourcepub fn global_backend_features(self, key: ()) -> &'tcx Vec<String>
pub fn global_backend_features(self, key: ()) -> &'tcx Vec<String>
The list of backend features computed from CLI flags (-Ctarget-cpu
, -Ctarget-feature
,
--target
and similar).
sourcepub fn check_validity_requirement(
self,
key: (ValidityRequirement, ParamEnvAnd<'tcx, Ty<'tcx>>),
) -> Result<bool, &'tcx LayoutError<'tcx>>
pub fn check_validity_requirement( self, key: (ValidityRequirement, ParamEnvAnd<'tcx, Ty<'tcx>>), ) -> Result<bool, &'tcx LayoutError<'tcx>>
[query description - consider adding a doc-comment!] checking validity requirement for key.1.value
: key.0
sourcepub fn compare_impl_const(
self,
key: (LocalDefId, DefId),
) -> Result<(), ErrorGuaranteed>
pub fn compare_impl_const( self, key: (LocalDefId, DefId), ) -> Result<(), ErrorGuaranteed>
[query description - consider adding a doc-comment!] checking assoc const tcx.def_path_str(key.0)
has the same type as trait item
sourcepub fn deduced_param_attrs(
self,
key: impl IntoQueryParam<DefId>,
) -> &'tcx [DeducedParamAttrs]
pub fn deduced_param_attrs( self, key: impl IntoQueryParam<DefId>, ) -> &'tcx [DeducedParamAttrs]
[query description - consider adding a doc-comment!] deducing parameter attributes for tcx.def_path_str(def_id)
sourcepub fn doc_link_resolutions(
self,
key: impl IntoQueryParam<DefId>,
) -> &'tcx DocLinkResMap
pub fn doc_link_resolutions( self, key: impl IntoQueryParam<DefId>, ) -> &'tcx DocLinkResMap
[query description - consider adding a doc-comment!] resolutions for documentation links for a module
sourcepub fn doc_link_traits_in_scope(
self,
key: impl IntoQueryParam<DefId>,
) -> &'tcx [DefId]
pub fn doc_link_traits_in_scope( self, key: impl IntoQueryParam<DefId>, ) -> &'tcx [DefId]
[query description - consider adding a doc-comment!] traits in scope for documentation links for a module
sourcepub fn stripped_cfg_items(self, key: CrateNum) -> &'tcx [StrippedCfgItem]
pub fn stripped_cfg_items(self, key: CrateNum) -> &'tcx [StrippedCfgItem]
Get all item paths that were stripped by a #[cfg]
in a particular crate.
Should not be called for the local crate before the resolver outputs are created, as it
is only fed there.
sourcepub fn generics_require_sized_self(
self,
key: impl IntoQueryParam<DefId>,
) -> bool
pub fn generics_require_sized_self( self, key: impl IntoQueryParam<DefId>, ) -> bool
[query description - consider adding a doc-comment!] check whether the item has a where Self: Sized
bound
sourcepub fn cross_crate_inlinable(self, key: impl IntoQueryParam<DefId>) -> bool
pub fn cross_crate_inlinable(self, key: impl IntoQueryParam<DefId>) -> bool
[query description - consider adding a doc-comment!] whether the item should be made inlinable across crates
Methods from Deref<Target = TyCtxt<'tcx>>§
pub const COMMON_VTABLE_ENTRIES: &'tcx [VtblEntry<'tcx>] = _
Methods from Deref<Target = &'tcx GlobalCtxt<'tcx>>§
sourcepub fn enter<F, R>(&'tcx self, f: F) -> R
pub fn enter<F, R>(&'tcx self, f: F) -> R
Installs self
in a TyCtxt
and ImplicitCtxt
for the duration of
f
.
pub fn finish(&self) -> FileEncodeResult
Trait Implementations§
source§impl<'tcx> HasDataLayout for TyCtxtAt<'tcx>
impl<'tcx> HasDataLayout for TyCtxtAt<'tcx>
fn data_layout(&self) -> &TargetDataLayout
source§impl<'tcx> HasTargetSpec for TyCtxtAt<'tcx>
impl<'tcx> HasTargetSpec for TyCtxtAt<'tcx>
fn target_spec(&self) -> &Target
impl<'tcx> Copy for TyCtxtAt<'tcx>
Auto Trait Implementations§
impl<'tcx> DynSend for TyCtxtAt<'tcx>
impl<'tcx> DynSync for TyCtxtAt<'tcx>
impl<'tcx> Freeze for TyCtxtAt<'tcx>
impl<'tcx> !RefUnwindSafe for TyCtxtAt<'tcx>
impl<'tcx> !Send for TyCtxtAt<'tcx>
impl<'tcx> !Sync for TyCtxtAt<'tcx>
impl<'tcx> Unpin for TyCtxtAt<'tcx>
impl<'tcx> !UnwindSafe for TyCtxtAt<'tcx>
Blanket Implementations§
source§impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut T
fn allocate_from_iter<'a>( arena: &'a Arena<'tcx>, iter: impl IntoIterator<Item = T>, ) -> &'a mut [T]
source§impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut T
fn allocate_from_iter<'a>( arena: &'a Arena<'tcx>, iter: impl IntoIterator<Item = T>, ) -> &'a mut [T]
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
source§impl<T> Filterable for T
impl<T> Filterable for T
source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
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<P> IntoQueryParam<P> for P
impl<P> IntoQueryParam<P> for P
fn into_query_param(self) -> P
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<T> PointerArithmetic for Twhere
T: HasDataLayout,
impl<T> PointerArithmetic for Twhere
T: HasDataLayout,
fn pointer_size(&self) -> Size
fn max_size_of_val(&self) -> Size
fn target_usize_max(&self) -> u64
fn target_isize_min(&self) -> i64
fn target_isize_max(&self) -> i64
fn target_usize_to_isize(&self, val: u64) -> i64
source§fn truncate_to_ptr(&self, (val, over): (u64, bool)) -> (u64, bool)
fn truncate_to_ptr(&self, (val, over): (u64, bool)) -> (u64, bool)
fn overflowing_offset(&self, val: u64, i: u64) -> (u64, bool)
fn overflowing_signed_offset(&self, val: u64, i: i64) -> (u64, bool)
fn offset<'tcx>(&self, val: u64, i: u64) -> InterpResult<'tcx, u64>
fn signed_offset<'tcx>(&self, val: u64, i: i64) -> InterpResult<'tcx, u64>
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<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> 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>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<T> ErasedDestructor for Twhere
T: 'static,
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: 16 bytes