[−][src]Enum rustc_middle::ty::query::Query
Variants
trigger_delay_span_bug(DefId)hir_crate(CrateNum)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().
index_hir(CrateNum)The indexed HIR. This can be conveniently accessed by tcx.hir().
Avoid calling this query directly.
hir_module_items(LocalDefId)The items in a module.
This can be conveniently accessed by tcx.hir().visit_item_likes_in_module.
Avoid calling this query directly.
hir_owner(LocalDefId)Gives access to the HIR node for the HIR owner key.
This can be conveniently accessed by methods on tcx.hir().
Avoid calling this query directly.
hir_owner_nodes(LocalDefId)Gives access to the HIR nodes and bodies inside the HIR owner key.
This can be conveniently accessed by methods on tcx.hir().
Avoid calling this query directly.
opt_const_param_of(LocalDefId)Computes the DefId of the corresponding const parameter in case the key is a
const argument and returns None otherwise.
let a = foo::<7>(); // ^ Calling `opt_const_param_of` for this argument, fn foo<const N: usize>() // ^ returns this `DefId`. fn bar() { // ^ While calling `opt_const_param_of` for other bodies returns `None`. }
type_of(DefId)Records the type of every item.
analysis(CrateNum)generics_of(DefId)Maps from the DefId of an item (trait/struct/enum/fn) to its
associated generics.
predicates_of(DefId)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.)
explicit_item_bounds(DefId)Returns the list of bounds that can be used for
SelectionCandidate::ProjectionCandidate(_) and
ProjectionTyCandidate::TraitDef.
Specifically this is the bounds written on the trait's type
definition, or those after the impl keyword
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.
item_bounds(DefId)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.
native_libraries(CrateNum)lint_levels(CrateNum)parent_module_from_def_id(LocalDefId)expn_that_defined(DefId)Internal helper query. Use tcx.expansion_that_defined instead
is_panic_runtime(CrateNum)mir_keys(CrateNum)Set of all the DefIds in this crate that have MIR associated with
them. This includes all the body owners, but also things like struct
constructors.
mir_const_qualif(DefId)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.
mir_const_qualif_const_arg((LocalDefId, DefId))mir_built(WithOptConstParam<LocalDefId>)Fetch the MIR for a given DefId right after it's built - this includes
unreachable code.
mir_const(WithOptConstParam<LocalDefId>)Fetch the MIR for a given DefId up till the point where it is
ready for const qualification.
See the README for the mir module for details.
mir_abstract_const(DefId)Try to build an abstract representation of the given constant.
mir_abstract_const_of_const_arg((LocalDefId, DefId))Try to build an abstract representation of the given constant.
try_unify_abstract_consts(((WithOptConstParam<DefId>, SubstsRef<'tcx>), (WithOptConstParam<DefId>, SubstsRef<'tcx>)))mir_drops_elaborated_and_const_checked(WithOptConstParam<LocalDefId>)mir_promoted(WithOptConstParam<LocalDefId>)optimized_mir(DefId)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.
optimized_mir_of_const_arg((LocalDefId, DefId))coverageinfo(DefId)Returns coverage summary info for a function, after executing the InstrumentCoverage
MIR pass (assuming the -Zinstrument-coverage option is enabled).
promoted_mir(DefId)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.
promoted_mir_of_const_arg((LocalDefId, DefId))erase_regions_ty(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.
wasm_import_module_map(CrateNum)predicates_defined_on(DefId)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.
trait_explicit_predicates_and_bounds(LocalDefId)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.
explicit_predicates_of(DefId)Returns the predicates written explicitly by the user.
inferred_outlives_of(DefId)Returns the inferred outlives predicates (e.g., for struct Foo<'a, T> { x: &'a T }, this would return T: 'a).
super_predicates_of(DefId)Maps from the DefId of a trait to the list of
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 supertraits have
additional acyclicity requirements).
type_param_predicates((DefId, LocalDefId))To avoid cycles within the predicates of a single item we compute
per-type-parameter predicates for resolving T::AssocTy.
trait_def(DefId)adt_def(DefId)adt_destructor(DefId)adt_sized_constraint(DefId)adt_dtorck_constraint(DefId)is_const_fn_raw(DefId)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.
is_const_impl_raw(DefId)Returns true if this is a const impl. Do not call this function manually.
This query caches the base data for the is_const_impl helper function, which also
takes into account stability attributes (e.g., #[rustc_const_unstable]).
asyncness(DefId)is_promotable_const_fn(DefId)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).
is_foreign_item(DefId)Returns true if this is a foreign item (i.e., linked via extern { ... }).
static_mutability(DefId)Returns Some(mutability) if the node pointed to by def_id is a static item.
generator_kind(DefId)Returns Some(generator_kind) if the node pointed to by def_id is a generator.
crate_variances(CrateNum)Gets a map with the variance of every item; use item_variance instead.
variances_of(DefId)Maps from the DefId of a type or region parameter to its (inferred) variance.
inferred_outlives_crate(CrateNum)Maps from thee DefId of a type to its (inferred) outlives.
associated_item_def_ids(DefId)Maps from an impl/trait DefId to a list of the DefId`s of its items.
associated_item(DefId)Maps from a trait item to the trait item "descriptor".
associated_items(DefId)Collects the associated items defined on a trait or impl.
impl_trait_ref(DefId)impl_polarity(DefId)issue33140_self_ty(DefId)inherent_impls(DefId)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.
unsafety_check_result(LocalDefId)The result of unsafety-checking this LocalDefId.
unsafety_check_result_for_const_arg((LocalDefId, DefId))unsafe_derive_on_repr_packed(LocalDefId)HACK: when evaluated, this reports a "unsafe derive on repr(packed)" error.
Unsafety checking is executed for each method separately, but we only want to emit this error once per derive. As there are some impls with multiple methods, we use a query for deduplication.
fn_sig(DefId)The signature of functions.
lint_mod(LocalDefId)check_mod_attrs(LocalDefId)Checks the attributes in the module.
check_mod_unstable_api_usage(LocalDefId)check_mod_const_bodies(LocalDefId)Checks the const bodies in the module for illegal operations (e.g. if or loop).
check_mod_loops(LocalDefId)Checks the loops in the module.
check_mod_item_types(LocalDefId)check_mod_privacy(LocalDefId)check_mod_intrinsics(LocalDefId)check_mod_liveness(LocalDefId)check_mod_impl_wf(LocalDefId)collect_mod_item_types(LocalDefId)coerce_unsized_info(DefId)Caches CoerceUnsized kinds for impls on custom types.
typeck_item_bodies(CrateNum)typeck(LocalDefId)typeck_const_arg((LocalDefId, DefId))diagnostic_only_typeck(LocalDefId)used_trait_imports(LocalDefId)has_typeck_results(DefId)coherent_trait(DefId)mir_borrowck(LocalDefId)Borrow-checks the function body. If this is a closure, returns additional requirements that the closure's creator must verify.
mir_borrowck_const_arg((LocalDefId, DefId))crate_inherent_impls(CrateNum)Gets a complete map from all types to their inherent impls.
Not meant to be used directly outside of coherence.
(Defined only for LOCAL_CRATE.)
crate_inherent_impls_overlap_check(CrateNum)Checks all types in the crate for overlap in their inherent impls. Reports errors.
Not meant to be used directly outside of coherence.
(Defined only for LOCAL_CRATE.)
eval_to_allocation_raw(ParamEnvAnd<'tcx, GlobalId<'tcx>>)Evaluates a constant and returns the computed allocation.
Do not use this directly, use the tcx.eval_static_initializer wrapper.
eval_to_const_value_raw(ParamEnvAnd<'tcx, GlobalId<'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.
destructure_const(ParamEnvAnd<'tcx, &'tcx Const<'tcx>>)Destructure a constant ADT or array into its variant index and its field values.
deref_const(ParamEnvAnd<'tcx, &'tcx Const<'tcx>>)Dereference a constant reference or raw pointer and turn the result into a constant again.
lit_to_const(LitToConstInput<'tcx>)check_match(DefId)privacy_access_levels(CrateNum)Performs part of the privacy check and computes "access levels".
check_private_in_public(CrateNum)reachable_set(CrateNum)region_scope_tree(DefId)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.
mir_shims(InstanceDef<'tcx>)symbol_name(Instance<'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.
def_kind(DefId)def_span(DefId)lookup_stability(DefId)lookup_const_stability(DefId)lookup_deprecation_entry(DefId)item_attrs(DefId)codegen_fn_attrs(DefId)fn_arg_names(DefId)rendered_const(DefId)Gets the rendered value of the specified constant or associated constant. Used by rustdoc.
impl_parent(DefId)trait_of_item(DefId)is_mir_available(DefId)vtable_methods(PolyTraitRef<'tcx>)codegen_fulfill_obligation((ParamEnv<'tcx>, PolyTraitRef<'tcx>))all_local_trait_impls(CrateNum)trait_impls_of(DefId)specialization_graph_of(DefId)object_safety_violations(DefId)param_env(DefId)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
param_env_reveal_all_normalized(DefId)Like param_env, but returns the ParamEnv in Reveal::Allmode. Prefer this overtcx.param_env(def_id).with_reveal_all_normalized(tcx)`,
as this method is more efficient.
is_copy_raw(ParamEnvAnd<'tcx, Ty<'tcx>>)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.
is_sized_raw(ParamEnvAnd<'tcx, Ty<'tcx>>)Query backing TyS::is_sized.
is_freeze_raw(ParamEnvAnd<'tcx, Ty<'tcx>>)Query backing TyS::is_freeze.
needs_drop_raw(ParamEnvAnd<'tcx, Ty<'tcx>>)Query backing TyS::needs_drop.
has_structural_eq_impls(Ty<'tcx>)Query backing TyS::is_structural_eq_shallow.
This is only correct for ADTs. Call is_structural_eq_shallow to handle all types
correctly.
adt_drop_tys(DefId)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.
layout_raw(ParamEnvAnd<'tcx, Ty<'tcx>>)dylib_dependency_formats(CrateNum)dependency_formats(CrateNum)is_compiler_builtins(CrateNum)has_global_allocator(CrateNum)has_panic_handler(CrateNum)is_profiler_runtime(CrateNum)panic_strategy(CrateNum)is_no_builtins(CrateNum)symbol_mangling_version(CrateNum)extern_crate(DefId)in_scope_traits_map(LocalDefId)module_exports(LocalDefId)impl_defaultness(DefId)check_item_well_formed(LocalDefId)check_trait_item_well_formed(LocalDefId)check_impl_item_well_formed(LocalDefId)reachable_non_generics(CrateNum)is_reachable_non_generic(DefId)is_unreachable_local_definition(DefId)upstream_monomorphizations(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, or, even
better, Instance::upstream_monomorphization().
upstream_monomorphizations_for(DefId)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.
upstream_drop_glue_for(SubstsRef<'tcx>)Returns the upstream crate that exports drop-glue for the given
type (substs 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).
foreign_modules(CrateNum)entry_fn(CrateNum)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).
plugin_registrar_fn(CrateNum)proc_macro_decls_static(CrateNum)crate_disambiguator(CrateNum)crate_hash(CrateNum)crate_host_hash(CrateNum)original_crate_name(CrateNum)extra_filename(CrateNum)crate_extern_paths(CrateNum)all_trait_implementations(CrateNum)dllimport_foreign_items(CrateNum)is_dllimport_foreign_item(DefId)is_statically_included_foreign_item(DefId)native_library_kind(DefId)link_args(CrateNum)resolve_lifetimes(CrateNum)Lifetime resolution. See middle::resolve_lifetimes.
named_region_map(LocalDefId)is_late_bound_map(LocalDefId)object_lifetime_defaults_map(LocalDefId)visibility(DefId)dep_kind(CrateNum)crate_name(CrateNum)item_children(DefId)extern_mod_stmt_cnum(LocalDefId)get_lib_features(CrateNum)defined_lib_features(CrateNum)get_lang_items(CrateNum)Returns the lang items defined in another crate by loading it from metadata.
all_diagnostic_items(CrateNum)Returns all diagnostic items defined in all crates.
defined_lang_items(CrateNum)Returns the lang items defined in another crate by loading it from metadata.
diagnostic_items(CrateNum)Returns the diagnostic items defined in a crate.
missing_lang_items(CrateNum)visible_parent_map(CrateNum)trimmed_def_paths(CrateNum)missing_extern_crate_item(CrateNum)used_crate_source(CrateNum)postorder_cnums(CrateNum)upvars_mentioned(DefId)maybe_unused_trait_import(LocalDefId)maybe_unused_extern_crates(CrateNum)names_imported_by_glob_use(LocalDefId)stability_index(CrateNum)all_crate_nums(CrateNum)all_traits(CrateNum)A vector of every trait accessible in the whole crate (i.e., including those from subcrates). This is used only for error reporting.
exported_symbols(CrateNum)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 incnummachine code. - The
exported_symbolssets of different crates do not intersect.
collect_and_partition_mono_items(CrateNum)is_codegened_item(DefId)codegen_unit(Symbol)unused_generic_params(DefId)backend_optimization_level(CrateNum)output_filenames(CrateNum)normalize_projection_ty(CanonicalProjectionGoal<'tcx>)Do not call this query directly: invoke normalize instead.
normalize_generic_arg_after_erasing_regions(ParamEnvAnd<'tcx, GenericArg<'tcx>>)Do not call this query directly: invoke normalize_erasing_regions instead.
implied_outlives_bounds(CanonicalTyGoal<'tcx>)dropck_outlives(CanonicalTyGoal<'tcx>)Do not call this query directly: invoke infcx.at().dropck_outlives() instead.
evaluate_obligation(CanonicalPredicateGoal<'tcx>)Do not call this query directly: invoke infcx.predicate_may_hold() or
infcx.predicate_must_hold() instead.
evaluate_goal(CanonicalChalkEnvironmentAndGoal<'tcx>)type_op_ascribe_user_type(CanonicalTypeOpAscribeUserTypeGoal<'tcx>)Do not call this query directly: part of the Eq type-op
type_op_eq(CanonicalTypeOpEqGoal<'tcx>)Do not call this query directly: part of the Eq type-op
type_op_subtype(CanonicalTypeOpSubtypeGoal<'tcx>)Do not call this query directly: part of the Subtype type-op
type_op_prove_predicate(CanonicalTypeOpProvePredicateGoal<'tcx>)Do not call this query directly: part of the ProvePredicate type-op
type_op_normalize_ty(CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>)Do not call this query directly: part of the Normalize type-op
type_op_normalize_predicate(CanonicalTypeOpNormalizeGoal<'tcx, Predicate<'tcx>>)Do not call this query directly: part of the Normalize type-op
type_op_normalize_poly_fn_sig(CanonicalTypeOpNormalizeGoal<'tcx, PolyFnSig<'tcx>>)Do not call this query directly: part of the Normalize type-op
type_op_normalize_fn_sig(CanonicalTypeOpNormalizeGoal<'tcx, FnSig<'tcx>>)Do not call this query directly: part of the Normalize type-op
method_autoderef_steps(CanonicalTyGoal<'tcx>)supported_target_features(CrateNum)instance_def_size_estimate(InstanceDef<'tcx>)Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning.
features_query(CrateNum)resolve_instance(ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)>)Attempt to resolve the given DefId to an Instance, for the
given generics args (SubstsRef), returning one of:
Ok(Some(instance))on successOk(None)when theSubstsRefare still too generic, and therefore don't allow finding the finalInstanceErr(ErrorReported)when theInstanceresolution 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
resolve_instance_of_const_arg(ParamEnvAnd<'tcx, (LocalDefId, DefId, SubstsRef<'tcx>)>)Implementations
impl<'tcx> Query<'tcx>[src]
pub fn name(&self) -> &'static str[src]
pub fn describe(&self, tcx: TyCtxt<'tcx>) -> Cow<'static, str>[src]
pub fn default_span(&self, tcx: TyCtxt<'tcx>, span: Span) -> Span[src]
Trait Implementations
impl<'tcx> Clone for Query<'tcx>[src]
impl<'tcx> Debug for Query<'tcx>[src]
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Query<'tcx>[src]
pub fn hash_stable(
&self,
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher
)[src]
&self,
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher
)
Auto Trait Implementations
impl<'tcx> !RefUnwindSafe for Query<'tcx>
impl<'tcx> !Send for Query<'tcx>
impl<'tcx> !Sync for Query<'tcx>
impl<'tcx> Unpin for Query<'tcx>
impl<'tcx> !UnwindSafe for Query<'tcx>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<'a, T> Captures<'a> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> MaybeResult<T> for T[src]
type Error = !
pub fn from(Result<T, <T as MaybeResult<T>>::Error>) -> T[src]
pub fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>[src]
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.