Struct rustc_middle::ty::context::TyCtxt
source · pub struct TyCtxt<'tcx> {
gcx: &'tcx GlobalCtxt<'tcx>,
}
Expand description
The central data structure of the compiler. It stores references to the various arenas and also houses the results of the various compiler queries that have been performed. See the rustc dev guide for more details.
Fields§
§gcx: &'tcx GlobalCtxt<'tcx>
Implementations§
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
pub fn hir(self) -> Map<'tcx>
pub fn parent_module(self, id: HirId) -> LocalDefId
pub fn impl_subject(self, def_id: DefId) -> ImplSubject<'tcx>
source§impl TyCtxt<'_>
impl TyCtxt<'_>
sourcepub fn lint_level_at_node(
self,
lint: &'static Lint,
id: HirId
) -> (Level, LintLevelSource)
pub fn lint_level_at_node(
self,
lint: &'static Lint,
id: HirId
) -> (Level, LintLevelSource)
Fetch and return the user-visible lint level for the given lint at the given HirId.
sourcepub fn maybe_lint_level_root_bounded(self, id: HirId, bound: HirId) -> HirId
pub fn maybe_lint_level_root_bounded(self, id: HirId, bound: HirId) -> HirId
Walks upwards from id
to find a node which might change lint levels with attributes.
It stops at bound
and just returns it if reached.
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
sourcepub fn require_lang_item(self, lang_item: LangItem, span: Option<Span>) -> DefId
pub fn require_lang_item(self, lang_item: LangItem, span: Option<Span>) -> DefId
Returns the DefId
for a given LangItem
.
If not found, fatally aborts compilation.
sourcepub fn fn_trait_kind_from_def_id(self, id: DefId) -> Option<ClosureKind>
pub fn fn_trait_kind_from_def_id(self, id: DefId) -> Option<ClosureKind>
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
sourcepub fn eval_stability(
self,
def_id: DefId,
id: Option<HirId>,
span: Span,
method_span: Option<Span>
) -> EvalResult
pub fn eval_stability(
self,
def_id: DefId,
id: Option<HirId>,
span: Span,
method_span: Option<Span>
) -> EvalResult
Evaluates the stability of an item.
Returns EvalResult::Allow
if the item is stable, or unstable but the corresponding
#![feature]
has been provided. Returns EvalResult::Deny
which describes the offending
unstable feature otherwise.
If id
is Some(_)
, this function will also check if the item at def_id
has been
deprecated. If the item is indeed deprecated, we will emit a deprecation lint attached to
id
.
sourcepub fn eval_stability_allow_unstable(
self,
def_id: DefId,
id: Option<HirId>,
span: Span,
method_span: Option<Span>,
allow_unstable: AllowUnstable
) -> EvalResult
pub fn eval_stability_allow_unstable(
self,
def_id: DefId,
id: Option<HirId>,
span: Span,
method_span: Option<Span>,
allow_unstable: AllowUnstable
) -> EvalResult
Evaluates the stability of an item.
Returns EvalResult::Allow
if the item is stable, or unstable but the corresponding
#![feature]
has been provided. Returns EvalResult::Deny
which describes the offending
unstable feature otherwise.
If id
is Some(_)
, this function will also check if the item at def_id
has been
deprecated. If the item is indeed deprecated, we will emit a deprecation lint attached to
id
.
Pass AllowUnstable::Yes
to allow_unstable
to force an unstable item to be allowed. Deprecation warnings will be emitted normally.
sourcepub fn eval_default_body_stability(self, def_id: DefId, span: Span) -> EvalResult
pub fn eval_default_body_stability(self, def_id: DefId, span: Span) -> EvalResult
Evaluates the default-impl stability of an item.
Returns EvalResult::Allow
if the item’s default implementation is stable, or unstable but the corresponding
#![feature]
has been provided. Returns EvalResult::Deny
which describes the offending
unstable feature otherwise.
sourcepub fn check_stability(
self,
def_id: DefId,
id: Option<HirId>,
span: Span,
method_span: Option<Span>
) -> bool
pub fn check_stability(
self,
def_id: DefId,
id: Option<HirId>,
span: Span,
method_span: Option<Span>
) -> bool
Checks if an item is stable or error out.
If the item defined by def_id
is unstable and the corresponding #![feature]
does not
exist, emits an error.
This function will also check if the item is deprecated.
If so, and id
is not None
, a deprecated lint attached to id
will be emitted.
Returns true
if item is allowed aka, stable or unstable under an enabled feature.
sourcepub fn check_stability_allow_unstable(
self,
def_id: DefId,
id: Option<HirId>,
span: Span,
method_span: Option<Span>,
allow_unstable: AllowUnstable
) -> bool
pub fn check_stability_allow_unstable(
self,
def_id: DefId,
id: Option<HirId>,
span: Span,
method_span: Option<Span>,
allow_unstable: AllowUnstable
) -> bool
Checks if an item is stable or error out.
If the item defined by def_id
is unstable and the corresponding #![feature]
does not
exist, emits an error.
This function will also check if the item is deprecated.
If so, and id
is not None
, a deprecated lint attached to id
will be emitted.
Pass AllowUnstable::Yes
to allow_unstable
to force an unstable item to be allowed. Deprecation warnings will be emitted normally.
Returns true
if item is allowed aka, stable or unstable under an enabled feature.
sourcepub fn check_optional_stability(
self,
def_id: DefId,
id: Option<HirId>,
span: Span,
method_span: Option<Span>,
allow_unstable: AllowUnstable,
unmarked: impl FnOnce(Span, DefId)
) -> bool
pub fn check_optional_stability(
self,
def_id: DefId,
id: Option<HirId>,
span: Span,
method_span: Option<Span>,
allow_unstable: AllowUnstable,
unmarked: impl FnOnce(Span, DefId)
) -> bool
Like check_stability
, except that we permit items to have custom behaviour for
missing stability attributes (not necessarily just emit a bug!
). This is necessary
for default generic parameters, which only have stability attributes if they were
added after the type on which they’re defined.
Returns true
if item is allowed aka, stable or unstable under an enabled feature.
pub fn lookup_deprecation(self, id: DefId) -> Option<Deprecation>
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
sourcepub fn const_eval_poly(self, def_id: DefId) -> EvalToConstValueResult<'tcx>
pub fn const_eval_poly(self, def_id: DefId) -> EvalToConstValueResult<'tcx>
Evaluates a constant without providing any substitutions. This is useful to evaluate consts
that can’t take any generic arguments like statics, const items or enum discriminants. If a
generic parameter is used within the constant ErrorHandled::ToGeneric
will be returned.
sourcepub fn const_eval_resolve(
self,
param_env: ParamEnv<'tcx>,
ct: UnevaluatedConst<'tcx>,
span: Option<Span>
) -> EvalToConstValueResult<'tcx>
pub fn const_eval_resolve(
self,
param_env: ParamEnv<'tcx>,
ct: UnevaluatedConst<'tcx>,
span: Option<Span>
) -> EvalToConstValueResult<'tcx>
Resolves and evaluates a constant.
The constant can be located on a trait like <A as B>::C
, in which case the given
substitutions and environment are used to resolve the constant. Alternatively if the
constant has generic parameters in scope the substitutions are used to evaluate the value of
the constant. For example in fn foo<T>() { let _ = [0; bar::<T>()]; }
the repeat count
constant bar::<T>()
requires a substitution for T
, if the substitution for T
is still
too generic for the constant to be evaluated then Err(ErrorHandled::TooGeneric)
is
returned.
pub fn const_eval_resolve_for_typeck(
self,
param_env: ParamEnv<'tcx>,
ct: UnevaluatedConst<'tcx>,
span: Option<Span>
) -> EvalToValTreeResult<'tcx>
pub fn const_eval_instance(
self,
param_env: ParamEnv<'tcx>,
instance: Instance<'tcx>,
span: Option<Span>
) -> EvalToConstValueResult<'tcx>
sourcepub fn const_eval_global_id(
self,
param_env: ParamEnv<'tcx>,
cid: GlobalId<'tcx>,
span: Option<Span>
) -> EvalToConstValueResult<'tcx>
pub fn const_eval_global_id(
self,
param_env: ParamEnv<'tcx>,
cid: GlobalId<'tcx>,
span: Option<Span>
) -> EvalToConstValueResult<'tcx>
Evaluate a constant to a ConstValue
.
sourcepub fn const_eval_global_id_for_typeck(
self,
param_env: ParamEnv<'tcx>,
cid: GlobalId<'tcx>,
span: Option<Span>
) -> EvalToValTreeResult<'tcx>
pub fn const_eval_global_id_for_typeck(
self,
param_env: ParamEnv<'tcx>,
cid: GlobalId<'tcx>,
span: Option<Span>
) -> EvalToValTreeResult<'tcx>
Evaluate a constant to a type-level constant.
sourcepub fn eval_static_initializer(
self,
def_id: DefId
) -> Result<ConstAllocation<'tcx>, ErrorHandled>
pub fn eval_static_initializer(
self,
def_id: DefId
) -> Result<ConstAllocation<'tcx>, ErrorHandled>
Evaluate a static’s initializer, returning the allocation of the initializer’s memory.
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
sourcepub fn destructure_mir_constant(
self,
param_env: ParamEnv<'tcx>,
constant: ConstantKind<'tcx>
) -> DestructuredConstant<'tcx>
pub fn destructure_mir_constant(
self,
param_env: ParamEnv<'tcx>,
constant: ConstantKind<'tcx>
) -> DestructuredConstant<'tcx>
Destructure a mir constant ADT or array into its variant index and its field values.
Panics if the destructuring fails, use try_destructure_mir_constant
for fallible version.
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
sourcepub fn reserve_alloc_id(self) -> AllocId
pub fn reserve_alloc_id(self) -> AllocId
Obtains a new allocation ID that can be referenced but does not yet have an allocation backing it.
Make sure to call set_alloc_id_memory
or set_alloc_id_same_memory
before returning such
an AllocId
from a query.
sourcefn reserve_and_set_dedup(self, alloc: GlobalAlloc<'tcx>) -> AllocId
fn reserve_and_set_dedup(self, alloc: GlobalAlloc<'tcx>) -> AllocId
Reserves a new ID if this allocation has not been dedup-reserved before. Should only be used for “symbolic” allocations (function pointers, vtables, statics), we don’t want to dedup IDs for “real” memory!
sourcepub fn create_static_alloc(self, static_id: DefId) -> AllocId
pub fn create_static_alloc(self, static_id: DefId) -> AllocId
Generates an AllocId
for a static or return a cached one in case this function has been
called on the same static before.
sourcepub fn create_fn_alloc(self, instance: Instance<'tcx>) -> AllocId
pub fn create_fn_alloc(self, instance: Instance<'tcx>) -> AllocId
Generates an AllocId
for a function. Depending on the function type,
this might get deduplicated or assigned a new ID each time.
sourcepub fn create_vtable_alloc(
self,
ty: Ty<'tcx>,
poly_trait_ref: Option<PolyExistentialTraitRef<'tcx>>
) -> AllocId
pub fn create_vtable_alloc(
self,
ty: Ty<'tcx>,
poly_trait_ref: Option<PolyExistentialTraitRef<'tcx>>
) -> AllocId
Generates an AllocId
for a (symbolic, not-reified) vtable. Will get deduplicated.
sourcepub fn create_memory_alloc(self, mem: ConstAllocation<'tcx>) -> AllocId
pub fn create_memory_alloc(self, mem: ConstAllocation<'tcx>) -> AllocId
Interns the Allocation
and return a new AllocId
, even if there’s already an identical
Allocation
with a different AllocId
.
Statics with identical content will still point to the same Allocation
, i.e.,
their data will be deduplicated through Allocation
interning – but they
are different places in memory and as such need different IDs.
sourcepub fn try_get_global_alloc(self, id: AllocId) -> Option<GlobalAlloc<'tcx>>
pub fn try_get_global_alloc(self, id: AllocId) -> Option<GlobalAlloc<'tcx>>
Returns None
in case the AllocId
is dangling. An InterpretCx
can still have a
local Allocation
for that AllocId
, but having such an AllocId
in a constant is
illegal and will likely ICE.
This function exists to allow const eval to detect the difference between evaluation-
local dangling pointers and allocations in constants/statics.
sourcepub fn global_alloc(self, id: AllocId) -> GlobalAlloc<'tcx>
pub fn global_alloc(self, id: AllocId) -> GlobalAlloc<'tcx>
Panics in case the AllocId
is dangling. Since that is impossible for AllocId
s in
constants (as all constants must pass interning and validation that check for dangling
ids), this function is frequently used throughout rustc, but should not be used within
the miri engine.
sourcepub fn set_alloc_id_memory(self, id: AllocId, mem: ConstAllocation<'tcx>)
pub fn set_alloc_id_memory(self, id: AllocId, mem: ConstAllocation<'tcx>)
Freezes an AllocId
created with reserve
by pointing it at an Allocation
. Trying to
call this function twice, even with the same Allocation
will ICE the compiler.
sourcefn set_alloc_id_same_memory(self, id: AllocId, mem: ConstAllocation<'tcx>)
fn set_alloc_id_same_memory(self, id: AllocId, mem: ConstAllocation<'tcx>)
Freezes an AllocId
created with reserve
by pointing it at an Allocation
. May be called
twice for the same (AllocId, Allocation)
pair.
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
Shims which make dealing with WithOptConstParam
easier.
For more information on why this is needed, consider looking
at the docs for WithOptConstParam
itself.
pub fn mir_const_qualif_opt_const_arg(
self,
def: WithOptConstParam<LocalDefId>
) -> ConstQualifs
pub fn promoted_mir_opt_const_arg(
self,
def: WithOptConstParam<DefId>
) -> &'tcx IndexVec<Promoted, Body<'tcx>>
pub fn mir_for_ctfe_opt_const_arg(
self,
def: WithOptConstParam<DefId>
) -> &'tcx Body<'tcx>
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
sourcepub fn bound_abstract_const(
self,
uv: WithOptConstParam<DefId>
) -> BoundAbstractConst<'tcx>
pub fn bound_abstract_const(
self,
uv: WithOptConstParam<DefId>
) -> BoundAbstractConst<'tcx>
Returns a const without substs applied
pub fn expand_abstract_consts<T: TypeFoldable<'tcx>>(self, ac: T) -> T
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
pub fn note_and_explain_type_err(
self,
diag: &mut Diagnostic,
err: TypeError<'tcx>,
cause: &ObligationCause<'tcx>,
sp: Span,
body_owner_def_id: DefId
)
fn suggest_constraint(
self,
diag: &mut Diagnostic,
msg: &str,
body_owner_def_id: DefId,
proj_ty: &AliasTy<'tcx>,
ty: Ty<'tcx>
) -> bool
sourcefn expected_projection(
self,
diag: &mut Diagnostic,
proj_ty: &AliasTy<'tcx>,
values: ExpectedFound<Ty<'tcx>>,
body_owner_def_id: DefId,
cause_code: &ObligationCauseCode<'_>
)
fn expected_projection(
self,
diag: &mut Diagnostic,
proj_ty: &AliasTy<'tcx>,
values: ExpectedFound<Ty<'tcx>>,
body_owner_def_id: DefId,
cause_code: &ObligationCauseCode<'_>
)
An associated type was expected and a different type was found.
We perform a few different checks to see what we can suggest:
- In the current item, look for associated functions that return the expected type and suggest calling them. (Not a structured suggestion.)
- If any of the item’s generic bounds can be constrained, we suggest constraining the associated type to the found type.
- If the associated type has a default type and was expected inside of a
trait
, we mention that this is disallowed. - If all other things fail, and the error is not because of a mismatch between the
trait
and theimpl
, we provide a generichelp
to constrain the assoc type or call an assoc fn that returns the type.
sourcefn suggest_constraining_opaque_associated_type(
self,
diag: &mut Diagnostic,
msg: &str,
proj_ty: &AliasTy<'tcx>,
ty: Ty<'tcx>
) -> bool
fn suggest_constraining_opaque_associated_type(
self,
diag: &mut Diagnostic,
msg: &str,
proj_ty: &AliasTy<'tcx>,
ty: Ty<'tcx>
) -> bool
When the expected impl Trait
is not defined in the current item, it will come from
a return type. This can occur when dealing with TryStream
(#71035).
fn point_at_methods_that_satisfy_associated_type(
self,
diag: &mut Diagnostic,
assoc_container_id: DefId,
current_method_ident: Option<Symbol>,
proj_ty_item_def_id: DefId,
expected: Ty<'tcx>
) -> bool
fn point_at_associated_type(
self,
diag: &mut Diagnostic,
body_owner_def_id: DefId,
found: Ty<'tcx>
) -> bool
sourcefn constrain_generic_bound_associated_type_structured_suggestion(
self,
diag: &mut Diagnostic,
trait_ref: &TraitRef<'tcx>,
bounds: GenericBounds<'_>,
assoc: &AssocItem,
assoc_substs: &[GenericArg<'tcx>],
ty: Ty<'tcx>,
msg: &str,
is_bound_surely_present: bool
) -> bool
fn constrain_generic_bound_associated_type_structured_suggestion(
self,
diag: &mut Diagnostic,
trait_ref: &TraitRef<'tcx>,
bounds: GenericBounds<'_>,
assoc: &AssocItem,
assoc_substs: &[GenericArg<'tcx>],
ty: Ty<'tcx>,
msg: &str,
is_bound_surely_present: bool
) -> bool
Given a slice of hir::GenericBound
s, if any of them corresponds to the trait_ref
requirement, provide a structured suggestion to constrain it to a given type ty
.
is_bound_surely_present
indicates whether we know the bound we’re looking for is
inside bounds
. If that’s the case then we can consider bounds
containing only one
trait bound as the one we’re looking for. This can help in cases where the associated
type is defined on a supertrait of the one present in the bounds.
sourcefn constrain_associated_type_structured_suggestion(
self,
diag: &mut Diagnostic,
span: Span,
assoc: &AssocItem,
assoc_substs: &[GenericArg<'tcx>],
ty: Ty<'tcx>,
msg: &str
) -> bool
fn constrain_associated_type_structured_suggestion(
self,
diag: &mut Diagnostic,
span: Span,
assoc: &AssocItem,
assoc_substs: &[GenericArg<'tcx>],
ty: Ty<'tcx>,
msg: &str
) -> bool
Given a span corresponding to a bound, provide a structured suggestion to set an
associated type to a given type ty
.
pub fn short_ty_string(self, ty: Ty<'tcx>) -> (String, Option<PathBuf>)
fn format_generic_args(self, args: &[GenericArg<'tcx>]) -> String
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
sourcepub fn fold_regions<T>(
self,
value: T,
f: impl FnMut(Region<'tcx>, DebruijnIndex) -> Region<'tcx>
) -> Twhere
T: TypeFoldable<'tcx>,
pub fn fold_regions<T>(
self,
value: T,
f: impl FnMut(Region<'tcx>, DebruijnIndex) -> Region<'tcx>
) -> Twhere
T: TypeFoldable<'tcx>,
Folds the escaping and free regions in value
using f
, and
sets skipped_regions
to true if any late-bound region was found
and skipped.
pub fn super_fold_regions<T>(
self,
value: T,
f: impl FnMut(Region<'tcx>, DebruijnIndex) -> Region<'tcx>
) -> Twhere
T: TypeSuperFoldable<'tcx>,
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
sourcepub fn replace_late_bound_regions<T, F>(
self,
value: Binder<'tcx, T>,
fld_r: F
) -> (T, BTreeMap<BoundRegion, Region<'tcx>>)where
F: FnMut(BoundRegion) -> Region<'tcx>,
T: TypeFoldable<'tcx>,
pub fn replace_late_bound_regions<T, F>(
self,
value: Binder<'tcx, T>,
fld_r: F
) -> (T, BTreeMap<BoundRegion, Region<'tcx>>)where
F: FnMut(BoundRegion) -> Region<'tcx>,
T: TypeFoldable<'tcx>,
Replaces all regions bound by the given Binder
with the
results returned by the closure; the closure is expected to
return a free region (relative to this binder), and hence the
binder is removed in the return type. The closure is invoked
once for each unique BoundRegionKind
; multiple references to the
same BoundRegionKind
will reuse the previous result. A map is
returned at the end with each bound region and the free region
that replaced it.
Panics
This method only replaces late bound regions. Any types or
constants bound by value
will cause an ICE.
pub fn replace_late_bound_regions_uncached<T, F>(
self,
value: Binder<'tcx, T>,
replace_regions: F
) -> Twhere
F: FnMut(BoundRegion) -> Region<'tcx>,
T: TypeFoldable<'tcx>,
sourcepub fn replace_escaping_bound_vars_uncached<T: TypeFoldable<'tcx>>(
self,
value: T,
delegate: impl BoundVarReplacerDelegate<'tcx>
) -> T
pub fn replace_escaping_bound_vars_uncached<T: TypeFoldable<'tcx>>(
self,
value: T,
delegate: impl BoundVarReplacerDelegate<'tcx>
) -> T
Replaces all escaping bound vars. The fld_r
closure replaces escaping
bound regions; the fld_t
closure replaces escaping bound types and the fld_c
closure replaces escaping bound consts.
sourcepub fn replace_bound_vars_uncached<T: TypeFoldable<'tcx>>(
self,
value: Binder<'tcx, T>,
delegate: impl BoundVarReplacerDelegate<'tcx>
) -> T
pub fn replace_bound_vars_uncached<T: TypeFoldable<'tcx>>(
self,
value: Binder<'tcx, T>,
delegate: impl BoundVarReplacerDelegate<'tcx>
) -> T
Replaces all types or regions bound by the given Binder
. The fld_r
closure replaces bound regions, the fld_t
closure replaces bound
types, and fld_c
replaces bound constants.
sourcepub fn liberate_late_bound_regions<T>(
self,
all_outlive_scope: DefId,
value: Binder<'tcx, T>
) -> Twhere
T: TypeFoldable<'tcx>,
pub fn liberate_late_bound_regions<T>(
self,
all_outlive_scope: DefId,
value: Binder<'tcx, T>
) -> Twhere
T: TypeFoldable<'tcx>,
Replaces any late-bound regions bound in value
with
free variants attached to all_outlive_scope
.
pub fn shift_bound_var_indices<T>(self, bound_vars: usize, value: T) -> Twhere
T: TypeFoldable<'tcx>,
sourcepub fn erase_late_bound_regions<T>(self, value: Binder<'tcx, T>) -> Twhere
T: TypeFoldable<'tcx>,
pub fn erase_late_bound_regions<T>(self, value: Binder<'tcx, T>) -> Twhere
T: TypeFoldable<'tcx>,
Replaces any late-bound regions bound in value
with 'erased
. Useful in codegen but also
method lookup and a few other places where precise region relationships are not required.
sourcepub fn anonymize_bound_vars<T>(self, value: Binder<'tcx, T>) -> Binder<'tcx, T>where
T: TypeFoldable<'tcx>,
pub fn anonymize_bound_vars<T>(self, value: Binder<'tcx, T>) -> Binder<'tcx, T>where
T: TypeFoldable<'tcx>,
Anonymize all bound variables in value
, this is mostly used to improve caching.
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
sourcepub fn normalize_erasing_regions<T>(
self,
param_env: ParamEnv<'tcx>,
value: T
) -> Twhere
T: TypeFoldable<'tcx>,
pub fn normalize_erasing_regions<T>(
self,
param_env: ParamEnv<'tcx>,
value: T
) -> Twhere
T: TypeFoldable<'tcx>,
Erase the regions in value
and then fully normalize all the
types found within. The result will also have regions erased.
This should only be used outside of type inference. For example, it assumes that normalization will succeed.
sourcepub fn try_normalize_erasing_regions<T>(
self,
param_env: ParamEnv<'tcx>,
value: T
) -> Result<T, NormalizationError<'tcx>>where
T: TypeFoldable<'tcx>,
pub fn try_normalize_erasing_regions<T>(
self,
param_env: ParamEnv<'tcx>,
value: T
) -> Result<T, NormalizationError<'tcx>>where
T: TypeFoldable<'tcx>,
Tries to erase the regions in value
and then fully normalize all the
types found within. The result will also have regions erased.
Contrary to normalize_erasing_regions
this function does not assume that normalization
succeeds.
sourcepub fn normalize_erasing_late_bound_regions<T>(
self,
param_env: ParamEnv<'tcx>,
value: Binder<'tcx, T>
) -> Twhere
T: TypeFoldable<'tcx>,
pub fn normalize_erasing_late_bound_regions<T>(
self,
param_env: ParamEnv<'tcx>,
value: Binder<'tcx, T>
) -> Twhere
T: TypeFoldable<'tcx>,
If you have a Binder<'tcx, T>
, you can do this to strip out the
late-bound regions and then normalize the result, yielding up
a T
(with regions erased). This is appropriate when the
binder is being instantiated at the call site.
N.B., currently, higher-ranked type bounds inhibit normalization. Therefore, each time we erase them in codegen, we need to normalize the contents.
sourcepub fn try_normalize_erasing_late_bound_regions<T>(
self,
param_env: ParamEnv<'tcx>,
value: Binder<'tcx, T>
) -> Result<T, NormalizationError<'tcx>>where
T: TypeFoldable<'tcx>,
pub fn try_normalize_erasing_late_bound_regions<T>(
self,
param_env: ParamEnv<'tcx>,
value: Binder<'tcx, T>
) -> Result<T, NormalizationError<'tcx>>where
T: TypeFoldable<'tcx>,
If you have a Binder<'tcx, T>
, you can do this to strip out the
late-bound regions and then normalize the result, yielding up
a T
(with regions erased). This is appropriate when the
binder is being instantiated at the call site.
N.B., currently, higher-ranked type bounds inhibit normalization. Therefore, each time we erase them in codegen, we need to normalize the contents.
sourcepub fn subst_and_normalize_erasing_regions<T>(
self,
param_substs: SubstsRef<'tcx>,
param_env: ParamEnv<'tcx>,
value: T
) -> Twhere
T: TypeFoldable<'tcx>,
pub fn subst_and_normalize_erasing_regions<T>(
self,
param_substs: SubstsRef<'tcx>,
param_env: ParamEnv<'tcx>,
value: T
) -> Twhere
T: TypeFoldable<'tcx>,
Monomorphizes a type from the AST by first applying the
in-scope substitutions and then normalizing any associated
types.
Panics if normalization fails. In case normalization might fail
use try_subst_and_normalize_erasing_regions
instead.
sourcepub fn try_subst_and_normalize_erasing_regions<T>(
self,
param_substs: SubstsRef<'tcx>,
param_env: ParamEnv<'tcx>,
value: T
) -> Result<T, NormalizationError<'tcx>>where
T: TypeFoldable<'tcx>,
pub fn try_subst_and_normalize_erasing_regions<T>(
self,
param_substs: SubstsRef<'tcx>,
param_env: ParamEnv<'tcx>,
value: T
) -> Result<T, NormalizationError<'tcx>>where
T: TypeFoldable<'tcx>,
Monomorphizes a type from the AST by first applying the
in-scope substitutions and then trying to normalize any associated
types. Contrary to subst_and_normalize_erasing_regions
this does
not assume that normalization succeeds.
source§impl<'t> TyCtxt<'t>
impl<'t> TyCtxt<'t>
sourcepub fn def_path_str(self, def_id: DefId) -> String
pub fn def_path_str(self, def_id: DefId) -> String
Returns a string identifying this DefId
. This string is
suitable for user output.
pub fn def_path_str_with_substs(
self,
def_id: DefId,
substs: &'t [GenericArg<'t>]
) -> String
pub fn value_path_str_with_substs(
self,
def_id: DefId,
substs: &'t [GenericArg<'t>]
) -> String
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
sourcepub fn ensure(self) -> TyCtxtEnsure<'tcx>
pub fn ensure(self) -> TyCtxtEnsure<'tcx>
Returns a transparent wrapper for TyCtxt
, which ensures queries
are executed instead of just returning their results.
sourcepub fn at(self, span: Span) -> TyCtxtAt<'tcx>
pub fn at(self, span: Span) -> TyCtxtAt<'tcx>
Returns a transparent wrapper for TyCtxt
which uses
span
as the location of queries performed through it.
pub fn try_mark_green(self, dep_node: &DepNode) -> bool
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
sourcepub fn trigger_delay_span_bug(
self,
key: impl IntoQueryParam<DefId>
) -> trigger_delay_span_bug<'tcx>
pub fn trigger_delay_span_bug(
self,
key: impl IntoQueryParam<DefId>
) -> trigger_delay_span_bug<'tcx>
[query description - consider adding a doc-comment!] triggering a delay span bug
sourcepub fn resolutions(self, key: ()) -> resolutions<'tcx>
pub fn resolutions(self, key: ()) -> resolutions<'tcx>
[query description - consider adding a doc-comment!] getting the resolver outputs
sourcepub fn resolver_for_lowering(self, key: ()) -> resolver_for_lowering<'tcx>
pub fn resolver_for_lowering(self, key: ()) -> resolver_for_lowering<'tcx>
[query description - consider adding a doc-comment!] getting the resolver for lowering
sourcepub fn source_span(self, key: LocalDefId) -> source_span<'tcx>
pub fn source_span(self, key: LocalDefId) -> source_span<'tcx>
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: ()) -> hir_crate<'tcx>
pub fn hir_crate(self, key: ()) -> hir_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: ()) -> hir_crate_items<'tcx>
pub fn hir_crate_items(self, key: ()) -> hir_crate_items<'tcx>
All items in the crate.
sourcepub fn hir_module_items(self, key: LocalDefId) -> hir_module_items<'tcx>
pub fn hir_module_items(self, key: LocalDefId) -> hir_module_items<'tcx>
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 hir_owner(self, key: OwnerId) -> hir_owner<'tcx>
pub fn hir_owner(self, key: OwnerId) -> hir_owner<'tcx>
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.
sourcepub fn local_def_id_to_hir_id(
self,
key: LocalDefId
) -> local_def_id_to_hir_id<'tcx>
pub fn local_def_id_to_hir_id(
self,
key: LocalDefId
) -> local_def_id_to_hir_id<'tcx>
Gives access to the HIR ID for the given LocalDefId
owner key
.
This can be conveniently accessed by methods on tcx.hir()
.
Avoid calling this query directly.
sourcepub fn hir_owner_parent(self, key: OwnerId) -> hir_owner_parent<'tcx>
pub fn hir_owner_parent(self, key: OwnerId) -> hir_owner_parent<'tcx>
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 hir_owner_nodes(self, key: OwnerId) -> hir_owner_nodes<'tcx>
pub fn hir_owner_nodes(self, key: OwnerId) -> hir_owner_nodes<'tcx>
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.
sourcepub fn hir_attrs(self, key: OwnerId) -> hir_attrs<'tcx>
pub fn hir_attrs(self, key: OwnerId) -> hir_attrs<'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 opt_const_param_of(self, key: LocalDefId) -> opt_const_param_of<'tcx>
pub fn opt_const_param_of(self, key: LocalDefId) -> opt_const_param_of<'tcx>
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`.
}
sourcepub fn const_param_default(
self,
key: impl IntoQueryParam<DefId>
) -> const_param_default<'tcx>
pub fn const_param_default(
self,
key: impl IntoQueryParam<DefId>
) -> const_param_default<'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>) -> type_of<'tcx>
pub fn type_of(self, key: impl IntoQueryParam<DefId>) -> type_of<'tcx>
sourcepub fn collect_trait_impl_trait_tys(
self,
key: impl IntoQueryParam<DefId>
) -> collect_trait_impl_trait_tys<'tcx>
pub fn collect_trait_impl_trait_tys(
self,
key: impl IntoQueryParam<DefId>
) -> collect_trait_impl_trait_tys<'tcx>
[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 analysis(self, key: ()) -> analysis<'tcx>
pub fn analysis(self, key: ()) -> analysis<'tcx>
[query description - consider adding a doc-comment!] running analysis passes on this crate
sourcepub fn check_expectations(self, key: Option<Symbol>) -> check_expectations<'tcx>
pub fn check_expectations(self, key: Option<Symbol>) -> check_expectations<'tcx>
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>) -> generics_of<'tcx>
pub fn generics_of(self, key: impl IntoQueryParam<DefId>) -> generics_of<'tcx>
Maps from the DefId
of an item (trait/struct/enum/fn) to its
associated generics.
sourcepub fn predicates_of(
self,
key: impl IntoQueryParam<DefId>
) -> predicates_of<'tcx>
pub fn predicates_of(
self,
key: impl IntoQueryParam<DefId>
) -> predicates_of<'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 explicit_item_bounds(
self,
key: impl IntoQueryParam<DefId>
) -> explicit_item_bounds<'tcx>
pub fn explicit_item_bounds(
self,
key: impl IntoQueryParam<DefId>
) -> explicit_item_bounds<'tcx>
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.
sourcepub fn item_bounds(self, key: impl IntoQueryParam<DefId>) -> item_bounds<'tcx>
pub fn item_bounds(self, key: impl IntoQueryParam<DefId>) -> item_bounds<'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 native_libraries(self, key: CrateNum) -> native_libraries<'tcx>
pub fn native_libraries(self, key: CrateNum) -> native_libraries<'tcx>
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) -> shallow_lint_levels_on<'tcx>
pub fn shallow_lint_levels_on(self, key: OwnerId) -> shallow_lint_levels_on<'tcx>
[query description - consider adding a doc-comment!] looking up lint levels for tcx.def_path_str(key.to_def_id())
sourcepub fn lint_expectations(self, key: ()) -> lint_expectations<'tcx>
pub fn lint_expectations(self, key: ()) -> lint_expectations<'tcx>
[query description - consider adding a doc-comment!] computing #[expect]
ed lints in this crate
sourcepub fn parent_module_from_def_id(
self,
key: LocalDefId
) -> parent_module_from_def_id<'tcx>
pub fn parent_module_from_def_id(
self,
key: LocalDefId
) -> parent_module_from_def_id<'tcx>
[query description - consider adding a doc-comment!] getting the parent module of tcx.def_path_str(key.to_def_id())
sourcepub fn expn_that_defined(
self,
key: impl IntoQueryParam<DefId>
) -> expn_that_defined<'tcx>
pub fn expn_that_defined(
self,
key: impl IntoQueryParam<DefId>
) -> expn_that_defined<'tcx>
[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) -> is_panic_runtime<'tcx>
pub fn is_panic_runtime(self, key: CrateNum) -> is_panic_runtime<'tcx>
[query description - consider adding a doc-comment!] checking if the crate is_panic_runtime
sourcepub fn representability(self, key: LocalDefId) -> representability<'tcx>
pub fn representability(self, key: LocalDefId) -> representability<'tcx>
Checks whether a type is representable or infinitely sized
sourcepub fn representability_adt_ty(
self,
key: Ty<'tcx>
) -> representability_adt_ty<'tcx>
pub fn representability_adt_ty(
self,
key: Ty<'tcx>
) -> representability_adt_ty<'tcx>
An implementation detail for the representability
query
sourcepub fn params_in_repr(
self,
key: impl IntoQueryParam<DefId>
) -> params_in_repr<'tcx>
pub fn params_in_repr(
self,
key: impl IntoQueryParam<DefId>
) -> params_in_repr<'tcx>
Set of param indexes for type params that are in the type’s representation
sourcepub fn thir_body(self, key: WithOptConstParam<LocalDefId>) -> thir_body<'tcx>
pub fn thir_body(self, key: WithOptConstParam<LocalDefId>) -> thir_body<'tcx>
Fetch the THIR for a given body. If typeck for that body failed, returns an empty Thir
.
sourcepub fn thir_tree(self, key: WithOptConstParam<LocalDefId>) -> thir_tree<'tcx>
pub fn thir_tree(self, key: WithOptConstParam<LocalDefId>) -> thir_tree<'tcx>
Create a THIR tree for debugging.
sourcepub fn mir_keys(self, key: ()) -> mir_keys<'tcx>
pub fn mir_keys(self, key: ()) -> mir_keys<'tcx>
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>
) -> mir_const_qualif<'tcx>
pub fn mir_const_qualif(
self,
key: impl IntoQueryParam<DefId>
) -> mir_const_qualif<'tcx>
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_const_qualif_const_arg(
self,
key: (LocalDefId, DefId)
) -> mir_const_qualif_const_arg<'tcx>
pub fn mir_const_qualif_const_arg(
self,
key: (LocalDefId, DefId)
) -> mir_const_qualif_const_arg<'tcx>
[query description - consider adding a doc-comment!] const checking the const argument tcx.def_path_str(key.0.to_def_id())
sourcepub fn mir_built(self, key: WithOptConstParam<LocalDefId>) -> mir_built<'tcx>
pub fn mir_built(self, key: WithOptConstParam<LocalDefId>) -> mir_built<'tcx>
Fetch the MIR for a given DefId
right after it’s built - this includes
unreachable code.
sourcepub fn mir_const(self, key: WithOptConstParam<LocalDefId>) -> mir_const<'tcx>
pub fn mir_const(self, key: WithOptConstParam<LocalDefId>) -> mir_const<'tcx>
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.
sourcepub fn thir_abstract_const(
self,
key: impl IntoQueryParam<DefId>
) -> thir_abstract_const<'tcx>
pub fn thir_abstract_const(
self,
key: impl IntoQueryParam<DefId>
) -> thir_abstract_const<'tcx>
Try to build an abstract representation of the given constant.
sourcepub fn thir_abstract_const_of_const_arg(
self,
key: (LocalDefId, DefId)
) -> thir_abstract_const_of_const_arg<'tcx>
pub fn thir_abstract_const_of_const_arg(
self,
key: (LocalDefId, DefId)
) -> thir_abstract_const_of_const_arg<'tcx>
Try to build an abstract representation of the given constant.
sourcepub fn mir_drops_elaborated_and_const_checked(
self,
key: WithOptConstParam<LocalDefId>
) -> mir_drops_elaborated_and_const_checked<'tcx>
pub fn mir_drops_elaborated_and_const_checked(
self,
key: WithOptConstParam<LocalDefId>
) -> mir_drops_elaborated_and_const_checked<'tcx>
[query description - consider adding a doc-comment!] elaborating drops for tcx.def_path_str(key.did.to_def_id())
sourcepub fn mir_for_ctfe(self, key: impl IntoQueryParam<DefId>) -> mir_for_ctfe<'tcx>
pub fn mir_for_ctfe(self, key: impl IntoQueryParam<DefId>) -> mir_for_ctfe<'tcx>
[query description - consider adding a doc-comment!] caching mir of tcx.def_path_str(key)
for CTFE
sourcepub fn mir_for_ctfe_of_const_arg(
self,
key: (LocalDefId, DefId)
) -> mir_for_ctfe_of_const_arg<'tcx>
pub fn mir_for_ctfe_of_const_arg(
self,
key: (LocalDefId, DefId)
) -> mir_for_ctfe_of_const_arg<'tcx>
[query description - consider adding a doc-comment!] caching MIR for CTFE of the const argument tcx.def_path_str(key.0.to_def_id())
sourcepub fn mir_promoted(
self,
key: WithOptConstParam<LocalDefId>
) -> mir_promoted<'tcx>
pub fn mir_promoted(
self,
key: WithOptConstParam<LocalDefId>
) -> mir_promoted<'tcx>
[query description - consider adding a doc-comment!] processing MIR for if key.const_param_did.is_some() { "the const argument " } else { "" }
tcx.def_path_str(key.did.to_def_id())
sourcepub fn symbols_for_closure_captures(
self,
key: (LocalDefId, LocalDefId)
) -> symbols_for_closure_captures<'tcx>
pub fn symbols_for_closure_captures(
self,
key: (LocalDefId, LocalDefId)
) -> symbols_for_closure_captures<'tcx>
[query description - consider adding a doc-comment!] finding symbols for captures of closure tcx.def_path_str(key.1.to_def_id())
in tcx.def_path_str(key.0.to_def_id())
sourcepub fn optimized_mir(
self,
key: impl IntoQueryParam<DefId>
) -> optimized_mir<'tcx>
pub fn optimized_mir(
self,
key: impl IntoQueryParam<DefId>
) -> optimized_mir<'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 coverageinfo(self, key: InstanceDef<'tcx>) -> coverageinfo<'tcx>
pub fn coverageinfo(self, key: InstanceDef<'tcx>) -> coverageinfo<'tcx>
Returns coverage summary info for a function, after executing the InstrumentCoverage
MIR pass (assuming the -Cinstrument-coverage option is enabled).
sourcepub fn covered_code_regions(
self,
key: impl IntoQueryParam<DefId>
) -> covered_code_regions<'tcx>
pub fn covered_code_regions(
self,
key: impl IntoQueryParam<DefId>
) -> covered_code_regions<'tcx>
Returns the CodeRegions
for a function that has instrumented coverage, in case the
function was optimized out before codegen, and before being added to the Coverage Map.
sourcepub fn promoted_mir(self, key: impl IntoQueryParam<DefId>) -> promoted_mir<'tcx>
pub fn promoted_mir(self, key: impl IntoQueryParam<DefId>) -> promoted_mir<'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 promoted_mir_of_const_arg(
self,
key: (LocalDefId, DefId)
) -> promoted_mir_of_const_arg<'tcx>
pub fn promoted_mir_of_const_arg(
self,
key: (LocalDefId, DefId)
) -> promoted_mir_of_const_arg<'tcx>
[query description - consider adding a doc-comment!] optimizing promoted MIR for the const argument tcx.def_path_str(key.0.to_def_id())
sourcepub fn erase_regions_ty(self, key: Ty<'tcx>) -> erase_regions_ty<'tcx>
pub fn erase_regions_ty(self, key: Ty<'tcx>) -> erase_regions_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
) -> wasm_import_module_map<'tcx>
pub fn wasm_import_module_map(
self,
key: CrateNum
) -> wasm_import_module_map<'tcx>
[query description - consider adding a doc-comment!] getting wasm import module map
sourcepub fn predicates_defined_on(
self,
key: impl IntoQueryParam<DefId>
) -> predicates_defined_on<'tcx>
pub fn predicates_defined_on(
self,
key: impl IntoQueryParam<DefId>
) -> predicates_defined_on<'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: LocalDefId
) -> trait_explicit_predicates_and_bounds<'tcx>
pub fn trait_explicit_predicates_and_bounds(
self,
key: LocalDefId
) -> trait_explicit_predicates_and_bounds<'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>
) -> explicit_predicates_of<'tcx>
pub fn explicit_predicates_of(
self,
key: impl IntoQueryParam<DefId>
) -> explicit_predicates_of<'tcx>
Returns the predicates written explicitly by the user.
sourcepub fn inferred_outlives_of(
self,
key: impl IntoQueryParam<DefId>
) -> inferred_outlives_of<'tcx>
pub fn inferred_outlives_of(
self,
key: impl IntoQueryParam<DefId>
) -> inferred_outlives_of<'tcx>
Returns the inferred outlives predicates (e.g., for struct Foo<'a, T> { x: &'a T }
, this would return T: 'a
).
sourcepub fn super_predicates_of(
self,
key: impl IntoQueryParam<DefId>
) -> super_predicates_of<'tcx>
pub fn super_predicates_of(
self,
key: impl IntoQueryParam<DefId>
) -> super_predicates_of<'tcx>
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).
sourcepub fn super_predicates_that_define_assoc_type(
self,
key: (DefId, Option<Ident>)
) -> super_predicates_that_define_assoc_type<'tcx>
pub fn super_predicates_that_define_assoc_type(
self,
key: (DefId, Option<Ident>)
) -> super_predicates_that_define_assoc_type<'tcx>
The Option<Ident>
is the name of an associated type. If it is None
, then this query
returns the full set of predicates. If Some<Ident>
, then the query returns only the
subset of super-predicates that reference traits that define the given associated type.
This is used to avoid cycles in resolving types like T::Item
.
sourcepub fn type_param_predicates(
self,
key: (DefId, LocalDefId, Ident)
) -> type_param_predicates<'tcx>
pub fn type_param_predicates(
self,
key: (DefId, LocalDefId, Ident)
) -> type_param_predicates<'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>) -> trait_def<'tcx>
pub fn trait_def(self, key: impl IntoQueryParam<DefId>) -> trait_def<'tcx>
[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>) -> adt_def<'tcx>
pub fn adt_def(self, key: impl IntoQueryParam<DefId>) -> adt_def<'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>
) -> adt_destructor<'tcx>
pub fn adt_destructor(
self,
key: impl IntoQueryParam<DefId>
) -> adt_destructor<'tcx>
[query description - consider adding a doc-comment!] computing Drop
impl for tcx.def_path_str(key)
sourcepub fn adt_sized_constraint(
self,
key: impl IntoQueryParam<DefId>
) -> adt_sized_constraint<'tcx>
pub fn adt_sized_constraint(
self,
key: impl IntoQueryParam<DefId>
) -> adt_sized_constraint<'tcx>
[query description - consider adding a doc-comment!] computing Sized
constraints for tcx.def_path_str(key)
sourcepub fn adt_dtorck_constraint(
self,
key: impl IntoQueryParam<DefId>
) -> adt_dtorck_constraint<'tcx>
pub fn adt_dtorck_constraint(
self,
key: impl IntoQueryParam<DefId>
) -> adt_dtorck_constraint<'tcx>
[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<'tcx>
pub fn constness(self, key: impl IntoQueryParam<DefId>) -> constness<'tcx>
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<'tcx>
pub fn asyncness(self, key: impl IntoQueryParam<DefId>) -> asyncness<'tcx>
[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>
) -> is_promotable_const_fn<'tcx>
pub fn is_promotable_const_fn(
self,
key: impl IntoQueryParam<DefId>
) -> is_promotable_const_fn<'tcx>
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 is_foreign_item(
self,
key: impl IntoQueryParam<DefId>
) -> is_foreign_item<'tcx>
pub fn is_foreign_item(
self,
key: impl IntoQueryParam<DefId>
) -> is_foreign_item<'tcx>
Returns true
if this is a foreign item (i.e., linked via extern { ... }
).
sourcepub fn generator_kind(
self,
key: impl IntoQueryParam<DefId>
) -> generator_kind<'tcx>
pub fn generator_kind(
self,
key: impl IntoQueryParam<DefId>
) -> generator_kind<'tcx>
Returns Some(generator_kind)
if the node pointed to by def_id
is a generator.
sourcepub fn crate_variances(self, key: ()) -> crate_variances<'tcx>
pub fn crate_variances(self, key: ()) -> crate_variances<'tcx>
Gets a map with the variance of every item; use item_variance
instead.
sourcepub fn variances_of(self, key: impl IntoQueryParam<DefId>) -> variances_of<'tcx>
pub fn variances_of(self, key: impl IntoQueryParam<DefId>) -> variances_of<'tcx>
Maps from the DefId
of a type or region parameter to its (inferred) variance.
sourcepub fn inferred_outlives_crate(self, key: ()) -> inferred_outlives_crate<'tcx>
pub fn inferred_outlives_crate(self, key: ()) -> inferred_outlives_crate<'tcx>
Maps from thee DefId
of a type to its (inferred) outlives.
sourcepub fn associated_item_def_ids(
self,
key: impl IntoQueryParam<DefId>
) -> associated_item_def_ids<'tcx>
pub fn associated_item_def_ids(
self,
key: impl IntoQueryParam<DefId>
) -> associated_item_def_ids<'tcx>
Maps from an impl/trait DefId
to a list of the DefId
s of its items.
sourcepub fn associated_item(
self,
key: impl IntoQueryParam<DefId>
) -> associated_item<'tcx>
pub fn associated_item(
self,
key: impl IntoQueryParam<DefId>
) -> associated_item<'tcx>
Maps from a trait item to the trait item “descriptor”.
sourcepub fn associated_items(
self,
key: impl IntoQueryParam<DefId>
) -> associated_items<'tcx>
pub fn associated_items(
self,
key: impl IntoQueryParam<DefId>
) -> associated_items<'tcx>
Collects the associated items defined on a trait or impl.
sourcepub fn impl_item_implementor_ids(
self,
key: impl IntoQueryParam<DefId>
) -> impl_item_implementor_ids<'tcx>
pub fn impl_item_implementor_ids(
self,
key: impl IntoQueryParam<DefId>
) -> impl_item_implementor_ids<'tcx>
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 impl_trait_ref(
self,
key: impl IntoQueryParam<DefId>
) -> impl_trait_ref<'tcx>
pub fn impl_trait_ref(
self,
key: impl IntoQueryParam<DefId>
) -> impl_trait_ref<'tcx>
Given an impl_id
, return the trait it implements.
Return None
if this is an inherent impl.
sourcepub fn impl_polarity(
self,
key: impl IntoQueryParam<DefId>
) -> impl_polarity<'tcx>
pub fn impl_polarity(
self,
key: impl IntoQueryParam<DefId>
) -> impl_polarity<'tcx>
[query description - consider adding a doc-comment!] computing implementation polarity of tcx.def_path_str(impl_id)
sourcepub fn issue33140_self_ty(
self,
key: impl IntoQueryParam<DefId>
) -> issue33140_self_ty<'tcx>
pub fn issue33140_self_ty(
self,
key: impl IntoQueryParam<DefId>
) -> issue33140_self_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>
) -> inherent_impls<'tcx>
pub fn inherent_impls(
self,
key: impl IntoQueryParam<DefId>
) -> inherent_impls<'tcx>
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) -> incoherent_impls<'tcx>
pub fn incoherent_impls(self, key: SimplifiedType) -> incoherent_impls<'tcx>
[query description - consider adding a doc-comment!] collecting all inherent impls for {:?}
sourcepub fn unsafety_check_result(
self,
key: LocalDefId
) -> unsafety_check_result<'tcx>
pub fn unsafety_check_result(
self,
key: LocalDefId
) -> unsafety_check_result<'tcx>
The result of unsafety-checking this LocalDefId
.
sourcepub fn unsafety_check_result_for_const_arg(
self,
key: (LocalDefId, DefId)
) -> unsafety_check_result_for_const_arg<'tcx>
pub fn unsafety_check_result_for_const_arg(
self,
key: (LocalDefId, DefId)
) -> unsafety_check_result_for_const_arg<'tcx>
[query description - consider adding a doc-comment!] unsafety-checking the const argument tcx.def_path_str(key.0.to_def_id())
sourcepub fn thir_check_unsafety(self, key: LocalDefId) -> thir_check_unsafety<'tcx>
pub fn thir_check_unsafety(self, key: LocalDefId) -> thir_check_unsafety<'tcx>
Unsafety-check this LocalDefId
with THIR unsafeck. This should be
used with -Zthir-unsafeck
.
sourcepub fn thir_check_unsafety_for_const_arg(
self,
key: (LocalDefId, DefId)
) -> thir_check_unsafety_for_const_arg<'tcx>
pub fn thir_check_unsafety_for_const_arg(
self,
key: (LocalDefId, DefId)
) -> thir_check_unsafety_for_const_arg<'tcx>
[query description - consider adding a doc-comment!] unsafety-checking the const argument tcx.def_path_str(key.0.to_def_id())
sourcepub fn unsafe_derive_on_repr_packed(
self,
key: LocalDefId
) -> unsafe_derive_on_repr_packed<'tcx>
pub fn unsafe_derive_on_repr_packed(
self,
key: LocalDefId
) -> unsafe_derive_on_repr_packed<'tcx>
HACK: when evaluated, this reports an “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.
sourcepub fn assumed_wf_types(
self,
key: impl IntoQueryParam<DefId>
) -> assumed_wf_types<'tcx>
pub fn assumed_wf_types(
self,
key: impl IntoQueryParam<DefId>
) -> assumed_wf_types<'tcx>
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 fn_sig(self, key: impl IntoQueryParam<DefId>) -> fn_sig<'tcx>
pub fn fn_sig(self, key: impl IntoQueryParam<DefId>) -> fn_sig<'tcx>
Computes the signature of the function.
sourcepub fn lint_mod(self, key: LocalDefId) -> lint_mod<'tcx>
pub fn lint_mod(self, key: LocalDefId) -> lint_mod<'tcx>
Performs lint checking for the module.
sourcepub fn check_mod_attrs(self, key: LocalDefId) -> check_mod_attrs<'tcx>
pub fn check_mod_attrs(self, key: LocalDefId) -> check_mod_attrs<'tcx>
Checks the attributes in the module.
sourcepub fn check_mod_unstable_api_usage(
self,
key: LocalDefId
) -> check_mod_unstable_api_usage<'tcx>
pub fn check_mod_unstable_api_usage(
self,
key: LocalDefId
) -> check_mod_unstable_api_usage<'tcx>
Checks for uses of unstable APIs in the module.
sourcepub fn check_mod_const_bodies(
self,
key: LocalDefId
) -> check_mod_const_bodies<'tcx>
pub fn check_mod_const_bodies(
self,
key: LocalDefId
) -> check_mod_const_bodies<'tcx>
Checks the const bodies in the module for illegal operations (e.g. if
or loop
).
sourcepub fn check_mod_loops(self, key: LocalDefId) -> check_mod_loops<'tcx>
pub fn check_mod_loops(self, key: LocalDefId) -> check_mod_loops<'tcx>
Checks the loops in the module.
sourcepub fn check_mod_naked_functions(
self,
key: LocalDefId
) -> check_mod_naked_functions<'tcx>
pub fn check_mod_naked_functions(
self,
key: LocalDefId
) -> check_mod_naked_functions<'tcx>
[query description - consider adding a doc-comment!] checking naked functions in describe_as_module(key, tcx)
sourcepub fn check_mod_item_types(self, key: LocalDefId) -> check_mod_item_types<'tcx>
pub fn check_mod_item_types(self, key: LocalDefId) -> check_mod_item_types<'tcx>
[query description - consider adding a doc-comment!] checking item types in describe_as_module(key, tcx)
sourcepub fn check_mod_privacy(self, key: LocalDefId) -> check_mod_privacy<'tcx>
pub fn check_mod_privacy(self, key: LocalDefId) -> check_mod_privacy<'tcx>
[query description - consider adding a doc-comment!] checking privacy in describe_as_module(key, tcx)
sourcepub fn check_liveness(
self,
key: impl IntoQueryParam<DefId>
) -> check_liveness<'tcx>
pub fn check_liveness(
self,
key: impl IntoQueryParam<DefId>
) -> check_liveness<'tcx>
[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: ()
) -> live_symbols_and_ignored_derived_traits<'tcx>
pub fn live_symbols_and_ignored_derived_traits(
self,
key: ()
) -> live_symbols_and_ignored_derived_traits<'tcx>
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: LocalDefId) -> check_mod_deathness<'tcx>
pub fn check_mod_deathness(self, key: LocalDefId) -> check_mod_deathness<'tcx>
[query description - consider adding a doc-comment!] checking deathness of variables in describe_as_module(key, tcx)
sourcepub fn check_mod_impl_wf(self, key: LocalDefId) -> check_mod_impl_wf<'tcx>
pub fn check_mod_impl_wf(self, key: LocalDefId) -> check_mod_impl_wf<'tcx>
[query description - consider adding a doc-comment!] checking that impls are well-formed in describe_as_module(key, tcx)
sourcepub fn check_mod_type_wf(self, key: LocalDefId) -> check_mod_type_wf<'tcx>
pub fn check_mod_type_wf(self, key: LocalDefId) -> check_mod_type_wf<'tcx>
[query description - consider adding a doc-comment!] checking that types are well-formed in describe_as_module(key, tcx)
sourcepub fn collect_mod_item_types(
self,
key: LocalDefId
) -> collect_mod_item_types<'tcx>
pub fn collect_mod_item_types(
self,
key: LocalDefId
) -> collect_mod_item_types<'tcx>
[query description - consider adding a doc-comment!] collecting item types in describe_as_module(key, tcx)
sourcepub fn coerce_unsized_info(
self,
key: impl IntoQueryParam<DefId>
) -> coerce_unsized_info<'tcx>
pub fn coerce_unsized_info(
self,
key: impl IntoQueryParam<DefId>
) -> coerce_unsized_info<'tcx>
Caches CoerceUnsized
kinds for impls on custom types.
sourcepub fn typeck_item_bodies(self, key: ()) -> typeck_item_bodies<'tcx>
pub fn typeck_item_bodies(self, key: ()) -> typeck_item_bodies<'tcx>
[query description - consider adding a doc-comment!] type-checking all item bodies
sourcepub fn typeck(self, key: LocalDefId) -> typeck<'tcx>
pub fn typeck(self, key: LocalDefId) -> typeck<'tcx>
[query description - consider adding a doc-comment!] type-checking tcx.def_path_str(key.to_def_id())
sourcepub fn typeck_const_arg(self, key: (LocalDefId, DefId)) -> typeck_const_arg<'tcx>
pub fn typeck_const_arg(self, key: (LocalDefId, DefId)) -> typeck_const_arg<'tcx>
[query description - consider adding a doc-comment!] type-checking the const argument tcx.def_path_str(key.0.to_def_id())
sourcepub fn diagnostic_only_typeck(
self,
key: LocalDefId
) -> diagnostic_only_typeck<'tcx>
pub fn diagnostic_only_typeck(
self,
key: LocalDefId
) -> diagnostic_only_typeck<'tcx>
[query description - consider adding a doc-comment!] type-checking tcx.def_path_str(key.to_def_id())
sourcepub fn used_trait_imports(self, key: LocalDefId) -> used_trait_imports<'tcx>
pub fn used_trait_imports(self, key: LocalDefId) -> used_trait_imports<'tcx>
[query description - consider adding a doc-comment!] finding used_trait_imports tcx.def_path_str(key.to_def_id())
sourcepub fn has_typeck_results(
self,
key: impl IntoQueryParam<DefId>
) -> has_typeck_results<'tcx>
pub fn has_typeck_results(
self,
key: impl IntoQueryParam<DefId>
) -> has_typeck_results<'tcx>
[query description - consider adding a doc-comment!] checking whether tcx.def_path_str(def_id)
has a body
sourcepub fn coherent_trait(
self,
key: impl IntoQueryParam<DefId>
) -> coherent_trait<'tcx>
pub fn coherent_trait(
self,
key: impl IntoQueryParam<DefId>
) -> coherent_trait<'tcx>
[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: LocalDefId) -> mir_borrowck<'tcx>
pub fn mir_borrowck(self, key: LocalDefId) -> mir_borrowck<'tcx>
Borrow-checks the function body. If this is a closure, returns additional requirements that the closure’s creator must verify.
sourcepub fn mir_borrowck_const_arg(
self,
key: (LocalDefId, DefId)
) -> mir_borrowck_const_arg<'tcx>
pub fn mir_borrowck_const_arg(
self,
key: (LocalDefId, DefId)
) -> mir_borrowck_const_arg<'tcx>
[query description - consider adding a doc-comment!] borrow-checking the const argument tcx.def_path_str(key.0.to_def_id())
sourcepub fn crate_inherent_impls(self, key: ()) -> crate_inherent_impls<'tcx>
pub fn crate_inherent_impls(self, key: ()) -> crate_inherent_impls<'tcx>
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: ()
) -> crate_inherent_impls_overlap_check<'tcx>
pub fn crate_inherent_impls_overlap_check(
self,
key: ()
) -> crate_inherent_impls_overlap_check<'tcx>
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: LocalDefId) -> orphan_check_impl<'tcx>
pub fn orphan_check_impl(self, key: LocalDefId) -> orphan_check_impl<'tcx>
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)
) -> mir_callgraph_reachable<'tcx>
pub fn mir_callgraph_reachable(
self,
key: (Instance<'tcx>, LocalDefId)
) -> mir_callgraph_reachable<'tcx>
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: InstanceDef<'tcx>
) -> mir_inliner_callees<'tcx>
pub fn mir_inliner_callees(
self,
key: InstanceDef<'tcx>
) -> mir_inliner_callees<'tcx>
Obtain all the calls into other local functions
sourcepub fn eval_to_allocation_raw(
self,
key: ParamEnvAnd<'tcx, GlobalId<'tcx>>
) -> eval_to_allocation_raw<'tcx>
pub fn eval_to_allocation_raw(
self,
key: ParamEnvAnd<'tcx, GlobalId<'tcx>>
) -> eval_to_allocation_raw<'tcx>
Evaluates a constant and returns the computed allocation.
Do not use this directly, use the tcx.eval_static_initializer
wrapper.
sourcepub fn eval_to_const_value_raw(
self,
key: ParamEnvAnd<'tcx, GlobalId<'tcx>>
) -> eval_to_const_value_raw<'tcx>
pub fn eval_to_const_value_raw(
self,
key: ParamEnvAnd<'tcx, GlobalId<'tcx>>
) -> eval_to_const_value_raw<'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>>
) -> eval_to_valtree<'tcx>
pub fn eval_to_valtree(
self,
key: ParamEnvAnd<'tcx, GlobalId<'tcx>>
) -> eval_to_valtree<'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>)
) -> valtree_to_const_val<'tcx>
pub fn valtree_to_const_val(
self,
key: (Ty<'tcx>, ValTree<'tcx>)
) -> valtree_to_const_val<'tcx>
Converts a type level constant value into ConstValue
sourcepub fn destructure_const(self, key: Const<'tcx>) -> destructure_const<'tcx>
pub fn destructure_const(self, key: Const<'tcx>) -> destructure_const<'tcx>
Destructures array, ADT or tuple constants into the constants of their fields.
sourcepub fn try_destructure_mir_constant(
self,
key: ParamEnvAnd<'tcx, ConstantKind<'tcx>>
) -> try_destructure_mir_constant<'tcx>
pub fn try_destructure_mir_constant(
self,
key: ParamEnvAnd<'tcx, ConstantKind<'tcx>>
) -> try_destructure_mir_constant<'tcx>
Tries to destructure an mir::ConstantKind
ADT or array into its variant index
and its field values.
sourcepub fn deref_mir_constant(
self,
key: ParamEnvAnd<'tcx, ConstantKind<'tcx>>
) -> deref_mir_constant<'tcx>
pub fn deref_mir_constant(
self,
key: ParamEnvAnd<'tcx, ConstantKind<'tcx>>
) -> deref_mir_constant<'tcx>
Dereference a constant reference or raw pointer and turn the result into a constant again.
sourcepub fn const_caller_location(
self,
key: (Symbol, u32, u32)
) -> const_caller_location<'tcx>
pub fn const_caller_location(
self,
key: (Symbol, u32, u32)
) -> const_caller_location<'tcx>
[query description - consider adding a doc-comment!] getting a &core::panic::Location referring to a span
sourcepub fn lit_to_const(self, key: LitToConstInput<'tcx>) -> lit_to_const<'tcx>
pub fn lit_to_const(self, key: LitToConstInput<'tcx>) -> lit_to_const<'tcx>
[query description - consider adding a doc-comment!] converting literal to const
sourcepub fn lit_to_mir_constant(
self,
key: LitToConstInput<'tcx>
) -> lit_to_mir_constant<'tcx>
pub fn lit_to_mir_constant(
self,
key: LitToConstInput<'tcx>
) -> lit_to_mir_constant<'tcx>
[query description - consider adding a doc-comment!] converting literal to mir constant
sourcepub fn check_match(self, key: impl IntoQueryParam<DefId>) -> check_match<'tcx>
pub fn check_match(self, key: impl IntoQueryParam<DefId>) -> check_match<'tcx>
[query description - consider adding a doc-comment!] match-checking tcx.def_path_str(key)
sourcepub fn effective_visibilities(self, key: ()) -> effective_visibilities<'tcx>
pub fn effective_visibilities(self, key: ()) -> effective_visibilities<'tcx>
Performs part of the privacy check and computes effective visibilities.
sourcepub fn check_private_in_public(self, key: ()) -> check_private_in_public<'tcx>
pub fn check_private_in_public(self, key: ()) -> check_private_in_public<'tcx>
[query description - consider adding a doc-comment!] checking for private elements in public interfaces
sourcepub fn reachable_set(self, key: ()) -> reachable_set<'tcx>
pub fn reachable_set(self, key: ()) -> reachable_set<'tcx>
[query description - consider adding a doc-comment!] reachability
sourcepub fn region_scope_tree(
self,
key: impl IntoQueryParam<DefId>
) -> region_scope_tree<'tcx>
pub fn region_scope_tree(
self,
key: impl IntoQueryParam<DefId>
) -> region_scope_tree<'tcx>
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: InstanceDef<'tcx>) -> mir_shims<'tcx>
pub fn mir_shims(self, key: InstanceDef<'tcx>) -> mir_shims<'tcx>
Generates a MIR body for the shim.
sourcepub fn symbol_name(self, key: Instance<'tcx>) -> symbol_name<'tcx>
pub fn symbol_name(self, key: Instance<'tcx>) -> symbol_name<'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 opt_def_kind(self, key: impl IntoQueryParam<DefId>) -> opt_def_kind<'tcx>
pub fn opt_def_kind(self, key: impl IntoQueryParam<DefId>) -> opt_def_kind<'tcx>
[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>) -> def_span<'tcx>
pub fn def_span(self, key: impl IntoQueryParam<DefId>) -> def_span<'tcx>
Gets the span for the definition.
sourcepub fn def_ident_span(
self,
key: impl IntoQueryParam<DefId>
) -> def_ident_span<'tcx>
pub fn def_ident_span(
self,
key: impl IntoQueryParam<DefId>
) -> def_ident_span<'tcx>
Gets the span for the identifier of the definition.
sourcepub fn lookup_stability(
self,
key: impl IntoQueryParam<DefId>
) -> lookup_stability<'tcx>
pub fn lookup_stability(
self,
key: impl IntoQueryParam<DefId>
) -> lookup_stability<'tcx>
[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>
) -> lookup_const_stability<'tcx>
pub fn lookup_const_stability(
self,
key: impl IntoQueryParam<DefId>
) -> lookup_const_stability<'tcx>
[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>
) -> lookup_default_body_stability<'tcx>
pub fn lookup_default_body_stability(
self,
key: impl IntoQueryParam<DefId>
) -> lookup_default_body_stability<'tcx>
[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>
) -> should_inherit_track_caller<'tcx>
pub fn should_inherit_track_caller(
self,
key: impl IntoQueryParam<DefId>
) -> should_inherit_track_caller<'tcx>
[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>
) -> lookup_deprecation_entry<'tcx>
pub fn lookup_deprecation_entry(
self,
key: impl IntoQueryParam<DefId>
) -> lookup_deprecation_entry<'tcx>
[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>
) -> is_doc_notable_trait<'tcx>
pub fn is_doc_notable_trait(
self,
key: impl IntoQueryParam<DefId>
) -> is_doc_notable_trait<'tcx>
Determines whether an item is annotated with doc(notable_trait)
.
sourcepub fn item_attrs(self, key: impl IntoQueryParam<DefId>) -> item_attrs<'tcx>
pub fn item_attrs(self, key: impl IntoQueryParam<DefId>) -> item_attrs<'tcx>
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>
) -> codegen_fn_attrs<'tcx>
pub fn codegen_fn_attrs(
self,
key: impl IntoQueryParam<DefId>
) -> codegen_fn_attrs<'tcx>
[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>
) -> asm_target_features<'tcx>
pub fn asm_target_features(
self,
key: impl IntoQueryParam<DefId>
) -> asm_target_features<'tcx>
[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>) -> fn_arg_names<'tcx>
pub fn fn_arg_names(self, key: impl IntoQueryParam<DefId>) -> fn_arg_names<'tcx>
[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>
) -> rendered_const<'tcx>
pub fn rendered_const(
self,
key: impl IntoQueryParam<DefId>
) -> rendered_const<'tcx>
Gets the rendered value of the specified constant or associated constant. Used by rustdoc.
sourcepub fn impl_parent(self, key: impl IntoQueryParam<DefId>) -> impl_parent<'tcx>
pub fn impl_parent(self, key: impl IntoQueryParam<DefId>) -> impl_parent<'tcx>
[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>
) -> is_ctfe_mir_available<'tcx>
pub fn is_ctfe_mir_available(
self,
key: impl IntoQueryParam<DefId>
) -> is_ctfe_mir_available<'tcx>
[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>
) -> is_mir_available<'tcx>
pub fn is_mir_available(
self,
key: impl IntoQueryParam<DefId>
) -> is_mir_available<'tcx>
[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>
) -> own_existential_vtable_entries<'tcx>
pub fn own_existential_vtable_entries(
self,
key: impl IntoQueryParam<DefId>
) -> own_existential_vtable_entries<'tcx>
[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>) -> vtable_entries<'tcx>
pub fn vtable_entries(self, key: PolyTraitRef<'tcx>) -> vtable_entries<'tcx>
[query description - consider adding a doc-comment!] finding all vtable entries for trait tcx.def_path_str(key.def_id())
sourcepub fn vtable_trait_upcasting_coercion_new_vptr_slot(
self,
key: (Ty<'tcx>, Ty<'tcx>)
) -> vtable_trait_upcasting_coercion_new_vptr_slot<'tcx>
pub fn vtable_trait_upcasting_coercion_new_vptr_slot(
self,
key: (Ty<'tcx>, Ty<'tcx>)
) -> vtable_trait_upcasting_coercion_new_vptr_slot<'tcx>
[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>>)
) -> vtable_allocation<'tcx>
pub fn vtable_allocation(
self,
key: (Ty<'tcx>, Option<PolyExistentialTraitRef<'tcx>>)
) -> vtable_allocation<'tcx>
[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>, PolyTraitRef<'tcx>)
) -> codegen_select_candidate<'tcx>
pub fn codegen_select_candidate(
self,
key: (ParamEnv<'tcx>, PolyTraitRef<'tcx>)
) -> codegen_select_candidate<'tcx>
[query description - consider adding a doc-comment!] computing candidate for key.1
sourcepub fn all_local_trait_impls(self, key: ()) -> all_local_trait_impls<'tcx>
pub fn all_local_trait_impls(self, key: ()) -> all_local_trait_impls<'tcx>
Return all impl
blocks in the current crate.
sourcepub fn trait_impls_of(
self,
key: impl IntoQueryParam<DefId>
) -> trait_impls_of<'tcx>
pub fn trait_impls_of(
self,
key: impl IntoQueryParam<DefId>
) -> trait_impls_of<'tcx>
Given a trait trait_id
, return all known impl
blocks.
sourcepub fn specialization_graph_of(
self,
key: impl IntoQueryParam<DefId>
) -> specialization_graph_of<'tcx>
pub fn specialization_graph_of(
self,
key: impl IntoQueryParam<DefId>
) -> specialization_graph_of<'tcx>
[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>
) -> object_safety_violations<'tcx>
pub fn object_safety_violations(
self,
key: impl IntoQueryParam<DefId>
) -> object_safety_violations<'tcx>
[query description - consider adding a doc-comment!] determining object safety of trait tcx.def_path_str(trait_id)
sourcepub fn param_env(self, key: impl IntoQueryParam<DefId>) -> param_env<'tcx>
pub fn param_env(self, key: impl IntoQueryParam<DefId>) -> param_env<'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>
) -> param_env_reveal_all_normalized<'tcx>
pub fn param_env_reveal_all_normalized(
self,
key: impl IntoQueryParam<DefId>
) -> param_env_reveal_all_normalized<'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>>) -> is_copy_raw<'tcx>
pub fn is_copy_raw(self, key: ParamEnvAnd<'tcx, Ty<'tcx>>) -> is_copy_raw<'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.
sourcepub fn is_sized_raw(self, key: ParamEnvAnd<'tcx, Ty<'tcx>>) -> is_sized_raw<'tcx>
pub fn is_sized_raw(self, key: ParamEnvAnd<'tcx, Ty<'tcx>>) -> is_sized_raw<'tcx>
Query backing Ty::is_sized
.
sourcepub fn is_freeze_raw(
self,
key: ParamEnvAnd<'tcx, Ty<'tcx>>
) -> is_freeze_raw<'tcx>
pub fn is_freeze_raw(
self,
key: ParamEnvAnd<'tcx, Ty<'tcx>>
) -> is_freeze_raw<'tcx>
Query backing Ty::is_freeze
.
sourcepub fn is_unpin_raw(self, key: ParamEnvAnd<'tcx, Ty<'tcx>>) -> is_unpin_raw<'tcx>
pub fn is_unpin_raw(self, key: ParamEnvAnd<'tcx, Ty<'tcx>>) -> is_unpin_raw<'tcx>
Query backing Ty::is_unpin
.
sourcepub fn needs_drop_raw(
self,
key: ParamEnvAnd<'tcx, Ty<'tcx>>
) -> needs_drop_raw<'tcx>
pub fn needs_drop_raw(
self,
key: ParamEnvAnd<'tcx, Ty<'tcx>>
) -> needs_drop_raw<'tcx>
Query backing Ty::needs_drop
.
sourcepub fn has_significant_drop_raw(
self,
key: ParamEnvAnd<'tcx, Ty<'tcx>>
) -> has_significant_drop_raw<'tcx>
pub fn has_significant_drop_raw(
self,
key: ParamEnvAnd<'tcx, Ty<'tcx>>
) -> has_significant_drop_raw<'tcx>
Query backing Ty::has_significant_drop_raw
.
sourcepub fn has_structural_eq_impls(
self,
key: Ty<'tcx>
) -> has_structural_eq_impls<'tcx>
pub fn has_structural_eq_impls(
self,
key: Ty<'tcx>
) -> has_structural_eq_impls<'tcx>
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>) -> adt_drop_tys<'tcx>
pub fn adt_drop_tys(self, key: impl IntoQueryParam<DefId>) -> adt_drop_tys<'tcx>
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>
) -> adt_significant_drop_tys<'tcx>
pub fn adt_significant_drop_tys(
self,
key: impl IntoQueryParam<DefId>
) -> adt_significant_drop_tys<'tcx>
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>>) -> layout_of<'tcx>
pub fn layout_of(self, key: ParamEnvAnd<'tcx, Ty<'tcx>>) -> layout_of<'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>>)>
) -> fn_abi_of_fn_ptr<'tcx>
pub fn fn_abi_of_fn_ptr(
self,
key: ParamEnvAnd<'tcx, (PolyFnSig<'tcx>, &'tcx List<Ty<'tcx>>)>
) -> fn_abi_of_fn_ptr<'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 InstanceDef::Virtual
.
sourcepub fn fn_abi_of_instance(
self,
key: ParamEnvAnd<'tcx, (Instance<'tcx>, &'tcx List<Ty<'tcx>>)>
) -> fn_abi_of_instance<'tcx>
pub fn fn_abi_of_instance(
self,
key: ParamEnvAnd<'tcx, (Instance<'tcx>, &'tcx List<Ty<'tcx>>)>
) -> fn_abi_of_instance<'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 InstanceDef::Virtual
instance (of <dyn Trait as Trait>::fn
).
sourcepub fn dylib_dependency_formats(
self,
key: CrateNum
) -> dylib_dependency_formats<'tcx>
pub fn dylib_dependency_formats(
self,
key: CrateNum
) -> dylib_dependency_formats<'tcx>
[query description - consider adding a doc-comment!] getting dylib dependency formats of crate
sourcepub fn dependency_formats(self, key: ()) -> dependency_formats<'tcx>
pub fn dependency_formats(self, key: ()) -> dependency_formats<'tcx>
[query description - consider adding a doc-comment!] getting the linkage format of all dependencies
sourcepub fn is_compiler_builtins(self, key: CrateNum) -> is_compiler_builtins<'tcx>
pub fn is_compiler_builtins(self, key: CrateNum) -> is_compiler_builtins<'tcx>
[query description - consider adding a doc-comment!] checking if the crate is_compiler_builtins
sourcepub fn has_global_allocator(self, key: CrateNum) -> has_global_allocator<'tcx>
pub fn has_global_allocator(self, key: CrateNum) -> has_global_allocator<'tcx>
[query description - consider adding a doc-comment!] checking if the crate has_global_allocator
sourcepub fn has_alloc_error_handler(
self,
key: CrateNum
) -> has_alloc_error_handler<'tcx>
pub fn has_alloc_error_handler(
self,
key: CrateNum
) -> has_alloc_error_handler<'tcx>
[query description - consider adding a doc-comment!] checking if the crate has_alloc_error_handler
sourcepub fn has_panic_handler(self, key: CrateNum) -> has_panic_handler<'tcx>
pub fn has_panic_handler(self, key: CrateNum) -> has_panic_handler<'tcx>
[query description - consider adding a doc-comment!] checking if the crate has_panic_handler
sourcepub fn is_profiler_runtime(self, key: CrateNum) -> is_profiler_runtime<'tcx>
pub fn is_profiler_runtime(self, key: CrateNum) -> is_profiler_runtime<'tcx>
[query description - consider adding a doc-comment!] checking if a crate is #![profiler_runtime]
sourcepub fn has_ffi_unwind_calls(self, key: LocalDefId) -> has_ffi_unwind_calls<'tcx>
pub fn has_ffi_unwind_calls(self, key: LocalDefId) -> has_ffi_unwind_calls<'tcx>
[query description - consider adding a doc-comment!] checking if tcx.def_path_str(key.to_def_id())
contains FFI-unwind calls
sourcepub fn required_panic_strategy(
self,
key: CrateNum
) -> required_panic_strategy<'tcx>
pub fn required_panic_strategy(
self,
key: CrateNum
) -> required_panic_strategy<'tcx>
[query description - consider adding a doc-comment!] getting a crate’s required panic strategy
sourcepub fn panic_in_drop_strategy(
self,
key: CrateNum
) -> panic_in_drop_strategy<'tcx>
pub fn panic_in_drop_strategy(
self,
key: CrateNum
) -> panic_in_drop_strategy<'tcx>
[query description - consider adding a doc-comment!] getting a crate’s configured panic-in-drop strategy
sourcepub fn is_no_builtins(self, key: CrateNum) -> is_no_builtins<'tcx>
pub fn is_no_builtins(self, key: CrateNum) -> is_no_builtins<'tcx>
[query description - consider adding a doc-comment!] getting whether a crate has #![no_builtins]
sourcepub fn symbol_mangling_version(
self,
key: CrateNum
) -> symbol_mangling_version<'tcx>
pub fn symbol_mangling_version(
self,
key: CrateNum
) -> symbol_mangling_version<'tcx>
[query description - consider adding a doc-comment!] getting a crate’s symbol mangling version
sourcepub fn extern_crate(self, key: impl IntoQueryParam<DefId>) -> extern_crate<'tcx>
pub fn extern_crate(self, key: impl IntoQueryParam<DefId>) -> extern_crate<'tcx>
[query description - consider adding a doc-comment!] getting crate’s ExternCrateData
sourcepub fn specializes(self, key: (DefId, DefId)) -> specializes<'tcx>
pub fn specializes(self, key: (DefId, DefId)) -> specializes<'tcx>
[query description - consider adding a doc-comment!] computing whether impls specialize one another
sourcepub fn in_scope_traits_map(self, key: OwnerId) -> in_scope_traits_map<'tcx>
pub fn in_scope_traits_map(self, key: OwnerId) -> in_scope_traits_map<'tcx>
[query description - consider adding a doc-comment!] getting traits in scope at a block
sourcepub fn module_reexports(self, key: LocalDefId) -> module_reexports<'tcx>
pub fn module_reexports(self, key: LocalDefId) -> module_reexports<'tcx>
[query description - consider adding a doc-comment!] looking up reexports of module tcx.def_path_str(def_id.to_def_id())
sourcepub fn impl_defaultness(
self,
key: impl IntoQueryParam<DefId>
) -> impl_defaultness<'tcx>
pub fn impl_defaultness(
self,
key: impl IntoQueryParam<DefId>
) -> impl_defaultness<'tcx>
[query description - consider adding a doc-comment!] looking up whether tcx.def_path_str(def_id)
is a default impl
sourcepub fn check_well_formed(self, key: OwnerId) -> check_well_formed<'tcx>
pub fn check_well_formed(self, key: OwnerId) -> check_well_formed<'tcx>
[query description - consider adding a doc-comment!] checking that tcx.def_path_str(key.to_def_id())
is well-formed
sourcepub fn reachable_non_generics(
self,
key: CrateNum
) -> reachable_non_generics<'tcx>
pub fn reachable_non_generics(
self,
key: CrateNum
) -> reachable_non_generics<'tcx>
[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>
) -> is_reachable_non_generic<'tcx>
pub fn is_reachable_non_generic(
self,
key: impl IntoQueryParam<DefId>
) -> is_reachable_non_generic<'tcx>
[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: LocalDefId
) -> is_unreachable_local_definition<'tcx>
pub fn is_unreachable_local_definition(
self,
key: LocalDefId
) -> is_unreachable_local_definition<'tcx>
[query description - consider adding a doc-comment!] checking whether tcx.def_path_str(def_id.to_def_id())
is reachable from outside the crate
sourcepub fn upstream_monomorphizations(
self,
key: ()
) -> upstream_monomorphizations<'tcx>
pub fn upstream_monomorphizations(
self,
key: ()
) -> upstream_monomorphizations<'tcx>
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()
.
sourcepub fn upstream_monomorphizations_for(
self,
key: impl IntoQueryParam<DefId>
) -> upstream_monomorphizations_for<'tcx>
pub fn upstream_monomorphizations_for(
self,
key: impl IntoQueryParam<DefId>
) -> upstream_monomorphizations_for<'tcx>
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: SubstsRef<'tcx>
) -> upstream_drop_glue_for<'tcx>
pub fn upstream_drop_glue_for(
self,
key: SubstsRef<'tcx>
) -> upstream_drop_glue_for<'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).
sourcepub fn foreign_modules(self, key: CrateNum) -> foreign_modules<'tcx>
pub fn foreign_modules(self, key: CrateNum) -> foreign_modules<'tcx>
Returns a list of all extern
blocks of a crate.
sourcepub fn entry_fn(self, key: ()) -> entry_fn<'tcx>
pub fn entry_fn(self, key: ()) -> entry_fn<'tcx>
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: ()) -> proc_macro_decls_static<'tcx>
pub fn proc_macro_decls_static(self, key: ()) -> proc_macro_decls_static<'tcx>
Finds the rustc_proc_macro_decls
item of a crate.
sourcepub fn crate_hash(self, key: CrateNum) -> crate_hash<'tcx>
pub fn crate_hash(self, key: CrateNum) -> crate_hash<'tcx>
[query description - consider adding a doc-comment!] looking up the hash a crate
sourcepub fn crate_host_hash(self, key: CrateNum) -> crate_host_hash<'tcx>
pub fn crate_host_hash(self, key: CrateNum) -> crate_host_hash<'tcx>
Gets the hash for the host proc macro. Used to support -Z dual-proc-macro.
sourcepub fn extra_filename(self, key: CrateNum) -> extra_filename<'tcx>
pub fn extra_filename(self, key: CrateNum) -> extra_filename<'tcx>
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) -> crate_extern_paths<'tcx>
pub fn crate_extern_paths(self, key: CrateNum) -> crate_extern_paths<'tcx>
Gets the paths where the crate came from in the file system.
sourcepub fn implementations_of_trait(
self,
key: (CrateNum, DefId)
) -> implementations_of_trait<'tcx>
pub fn implementations_of_trait(
self,
key: (CrateNum, DefId)
) -> implementations_of_trait<'tcx>
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)
) -> crate_incoherent_impls<'tcx>
pub fn crate_incoherent_impls(
self,
key: (CrateNum, SimplifiedType)
) -> crate_incoherent_impls<'tcx>
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>
) -> native_library<'tcx>
pub fn native_library(
self,
key: impl IntoQueryParam<DefId>
) -> native_library<'tcx>
Get the corresponding native library from the native_libraries
query
sourcepub fn resolve_lifetimes(self, key: OwnerId) -> resolve_lifetimes<'tcx>
pub fn resolve_lifetimes(self, key: OwnerId) -> resolve_lifetimes<'tcx>
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_region_map(self, key: OwnerId) -> named_region_map<'tcx>
pub fn named_region_map(self, key: OwnerId) -> named_region_map<'tcx>
[query description - consider adding a doc-comment!] looking up a named region
sourcepub fn is_late_bound_map(self, key: LocalDefId) -> is_late_bound_map<'tcx>
pub fn is_late_bound_map(self, key: LocalDefId) -> is_late_bound_map<'tcx>
[query description - consider adding a doc-comment!] testing if a region is late bound
sourcepub fn object_lifetime_default(
self,
key: impl IntoQueryParam<DefId>
) -> object_lifetime_default<'tcx>
pub fn object_lifetime_default(
self,
key: impl IntoQueryParam<DefId>
) -> object_lifetime_default<'tcx>
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) -> late_bound_vars_map<'tcx>
pub fn late_bound_vars_map(self, key: OwnerId) -> late_bound_vars_map<'tcx>
[query description - consider adding a doc-comment!] looking up late bound vars
sourcepub fn visibility(self, key: impl IntoQueryParam<DefId>) -> visibility<'tcx>
pub fn visibility(self, key: impl IntoQueryParam<DefId>) -> visibility<'tcx>
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>
) -> inhabited_predicate_adt<'tcx>
pub fn inhabited_predicate_adt(
self,
key: impl IntoQueryParam<DefId>
) -> inhabited_predicate_adt<'tcx>
[query description - consider adding a doc-comment!] computing the uninhabited predicate of {:?}
sourcepub fn inhabited_predicate_type(
self,
key: Ty<'tcx>
) -> inhabited_predicate_type<'tcx>
pub fn inhabited_predicate_type(
self,
key: Ty<'tcx>
) -> inhabited_predicate_type<'tcx>
Do not call this query directly: invoke Ty::inhabited_predicate
instead.
sourcepub fn dep_kind(self, key: CrateNum) -> dep_kind<'tcx>
pub fn dep_kind(self, key: CrateNum) -> dep_kind<'tcx>
[query description - consider adding a doc-comment!] fetching what a dependency looks like
sourcepub fn crate_name(self, key: CrateNum) -> crate_name<'tcx>
pub fn crate_name(self, key: CrateNum) -> crate_name<'tcx>
Gets the name of the crate.
sourcepub fn module_children(
self,
key: impl IntoQueryParam<DefId>
) -> module_children<'tcx>
pub fn module_children(
self,
key: impl IntoQueryParam<DefId>
) -> module_children<'tcx>
[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: LocalDefId) -> extern_mod_stmt_cnum<'tcx>
pub fn extern_mod_stmt_cnum(self, key: LocalDefId) -> extern_mod_stmt_cnum<'tcx>
[query description - consider adding a doc-comment!] computing crate imported by tcx.def_path_str(def_id.to_def_id())
sourcepub fn lib_features(self, key: ()) -> lib_features<'tcx>
pub fn lib_features(self, key: ()) -> lib_features<'tcx>
[query description - consider adding a doc-comment!] calculating the lib features map
sourcepub fn defined_lib_features(self, key: CrateNum) -> defined_lib_features<'tcx>
pub fn defined_lib_features(self, key: CrateNum) -> defined_lib_features<'tcx>
[query description - consider adding a doc-comment!] calculating the lib features defined in a crate
sourcepub fn stability_implications(
self,
key: CrateNum
) -> stability_implications<'tcx>
pub fn stability_implications(
self,
key: CrateNum
) -> stability_implications<'tcx>
[query description - consider adding a doc-comment!] calculating the implications between #[unstable]
features defined in a crate
sourcepub fn is_intrinsic(self, key: impl IntoQueryParam<DefId>) -> is_intrinsic<'tcx>
pub fn is_intrinsic(self, key: impl IntoQueryParam<DefId>) -> is_intrinsic<'tcx>
Whether the function is an intrinsic
sourcepub fn get_lang_items(self, key: ()) -> get_lang_items<'tcx>
pub fn get_lang_items(self, key: ()) -> get_lang_items<'tcx>
Returns the lang items defined in another crate by loading it from metadata.
sourcepub fn all_diagnostic_items(self, key: ()) -> all_diagnostic_items<'tcx>
pub fn all_diagnostic_items(self, key: ()) -> all_diagnostic_items<'tcx>
Returns all diagnostic items defined in all crates.
sourcepub fn defined_lang_items(self, key: CrateNum) -> defined_lang_items<'tcx>
pub fn defined_lang_items(self, key: CrateNum) -> defined_lang_items<'tcx>
Returns the lang items defined in another crate by loading it from metadata.
sourcepub fn diagnostic_items(self, key: CrateNum) -> diagnostic_items<'tcx>
pub fn diagnostic_items(self, key: CrateNum) -> diagnostic_items<'tcx>
Returns the diagnostic items defined in a crate.
sourcepub fn missing_lang_items(self, key: CrateNum) -> missing_lang_items<'tcx>
pub fn missing_lang_items(self, key: CrateNum) -> missing_lang_items<'tcx>
[query description - consider adding a doc-comment!] calculating the missing lang items in a crate
sourcepub fn visible_parent_map(self, key: ()) -> visible_parent_map<'tcx>
pub fn visible_parent_map(self, key: ()) -> visible_parent_map<'tcx>
[query description - consider adding a doc-comment!] calculating the visible parent map
sourcepub fn trimmed_def_paths(self, key: ()) -> trimmed_def_paths<'tcx>
pub fn trimmed_def_paths(self, key: ()) -> trimmed_def_paths<'tcx>
[query description - consider adding a doc-comment!] calculating trimmed def paths
sourcepub fn missing_extern_crate_item(
self,
key: CrateNum
) -> missing_extern_crate_item<'tcx>
pub fn missing_extern_crate_item(
self,
key: CrateNum
) -> missing_extern_crate_item<'tcx>
[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) -> used_crate_source<'tcx>
pub fn used_crate_source(self, key: CrateNum) -> used_crate_source<'tcx>
[query description - consider adding a doc-comment!] looking at the source for a crate
sourcepub fn debugger_visualizers(self, key: CrateNum) -> debugger_visualizers<'tcx>
pub fn debugger_visualizers(self, key: CrateNum) -> debugger_visualizers<'tcx>
Returns the debugger visualizers defined for this crate.
sourcepub fn postorder_cnums(self, key: ()) -> postorder_cnums<'tcx>
pub fn postorder_cnums(self, key: ()) -> postorder_cnums<'tcx>
[query description - consider adding a doc-comment!] generating a postorder list of CrateNums
sourcepub fn is_private_dep(self, key: CrateNum) -> is_private_dep<'tcx>
pub fn is_private_dep(self, key: CrateNum) -> is_private_dep<'tcx>
Returns whether or not the crate with CrateNum ‘cnum’ is marked as a private dependency
sourcepub fn allocator_kind(self, key: ()) -> allocator_kind<'tcx>
pub fn allocator_kind(self, key: ()) -> allocator_kind<'tcx>
[query description - consider adding a doc-comment!] getting the allocator kind for the current crate
sourcepub fn alloc_error_handler_kind(self, key: ()) -> alloc_error_handler_kind<'tcx>
pub fn alloc_error_handler_kind(self, key: ()) -> alloc_error_handler_kind<'tcx>
[query description - consider adding a doc-comment!] alloc error handler kind for the current crate
sourcepub fn upvars_mentioned(
self,
key: impl IntoQueryParam<DefId>
) -> upvars_mentioned<'tcx>
pub fn upvars_mentioned(
self,
key: impl IntoQueryParam<DefId>
) -> upvars_mentioned<'tcx>
[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: ()
) -> maybe_unused_trait_imports<'tcx>
pub fn maybe_unused_trait_imports(
self,
key: ()
) -> maybe_unused_trait_imports<'tcx>
[query description - consider adding a doc-comment!] fetching potentially unused trait imports
sourcepub fn maybe_unused_extern_crates(
self,
key: ()
) -> maybe_unused_extern_crates<'tcx>
pub fn maybe_unused_extern_crates(
self,
key: ()
) -> maybe_unused_extern_crates<'tcx>
[query description - consider adding a doc-comment!] looking up all possibly unused extern crates
sourcepub fn names_imported_by_glob_use(
self,
key: LocalDefId
) -> names_imported_by_glob_use<'tcx>
pub fn names_imported_by_glob_use(
self,
key: LocalDefId
) -> names_imported_by_glob_use<'tcx>
[query description - consider adding a doc-comment!] finding names imported by glob use for tcx.def_path_str(def_id.to_def_id())
sourcepub fn stability_index(self, key: ()) -> stability_index<'tcx>
pub fn stability_index(self, key: ()) -> stability_index<'tcx>
[query description - consider adding a doc-comment!] calculating the stability index for the local crate
sourcepub fn crates(self, key: ()) -> crates<'tcx>
pub fn crates(self, key: ()) -> crates<'tcx>
[query description - consider adding a doc-comment!] fetching all foreign CrateNum instances
sourcepub fn traits_in_crate(self, key: CrateNum) -> traits_in_crate<'tcx>
pub fn traits_in_crate(self, key: CrateNum) -> traits_in_crate<'tcx>
A list of all traits in a crate, used by rustdoc and error reporting.
NOTE: Not named just traits
due to a naming conflict.
sourcepub fn exported_symbols(self, key: CrateNum) -> exported_symbols<'tcx>
pub fn exported_symbols(self, key: CrateNum) -> exported_symbols<'tcx>
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: ()
) -> collect_and_partition_mono_items<'tcx>
pub fn collect_and_partition_mono_items(
self,
key: ()
) -> collect_and_partition_mono_items<'tcx>
[query description - consider adding a doc-comment!] collect_and_partition_mono_items
sourcepub fn is_codegened_item(
self,
key: impl IntoQueryParam<DefId>
) -> is_codegened_item<'tcx>
pub fn is_codegened_item(
self,
key: impl IntoQueryParam<DefId>
) -> is_codegened_item<'tcx>
[query description - consider adding a doc-comment!] determining whether tcx.def_path_str(def_id)
needs codegen
sourcepub fn codegened_and_inlined_items(
self,
key: ()
) -> codegened_and_inlined_items<'tcx>
pub fn codegened_and_inlined_items(
self,
key: ()
) -> codegened_and_inlined_items<'tcx>
All items participating in code generation together with items inlined into them.
sourcepub fn codegen_unit(self, key: Symbol) -> codegen_unit<'tcx>
pub fn codegen_unit(self, key: Symbol) -> codegen_unit<'tcx>
[query description - consider adding a doc-comment!] getting codegen unit {sym}
sourcepub fn unused_generic_params(
self,
key: InstanceDef<'tcx>
) -> unused_generic_params<'tcx>
pub fn unused_generic_params(
self,
key: InstanceDef<'tcx>
) -> unused_generic_params<'tcx>
[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: ()
) -> backend_optimization_level<'tcx>
pub fn backend_optimization_level(
self,
key: ()
) -> backend_optimization_level<'tcx>
[query description - consider adding a doc-comment!] optimization level used by backend
sourcepub fn output_filenames(self, key: ()) -> output_filenames<'tcx>
pub fn output_filenames(self, key: ()) -> output_filenames<'tcx>
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_projection_ty(
self,
key: CanonicalProjectionGoal<'tcx>
) -> normalize_projection_ty<'tcx>
pub fn normalize_projection_ty(
self,
key: CanonicalProjectionGoal<'tcx>
) -> normalize_projection_ty<'tcx>
Do not call this query directly: invoke normalize
instead.
sourcepub fn try_normalize_generic_arg_after_erasing_regions(
self,
key: ParamEnvAnd<'tcx, GenericArg<'tcx>>
) -> try_normalize_generic_arg_after_erasing_regions<'tcx>
pub fn try_normalize_generic_arg_after_erasing_regions(
self,
key: ParamEnvAnd<'tcx, GenericArg<'tcx>>
) -> try_normalize_generic_arg_after_erasing_regions<'tcx>
Do not call this query directly: invoke try_normalize_erasing_regions
instead.
sourcepub fn implied_outlives_bounds(
self,
key: CanonicalTyGoal<'tcx>
) -> implied_outlives_bounds<'tcx>
pub fn implied_outlives_bounds(
self,
key: CanonicalTyGoal<'tcx>
) -> implied_outlives_bounds<'tcx>
[query description - consider adding a doc-comment!] computing implied outlives bounds for goal.value.value
sourcepub fn dropck_outlives(self, key: CanonicalTyGoal<'tcx>) -> dropck_outlives<'tcx>
pub fn dropck_outlives(self, key: CanonicalTyGoal<'tcx>) -> dropck_outlives<'tcx>
Do not call this query directly:
invoke DropckOutlives::new(dropped_ty)).fully_perform(typeck.infcx)
instead.
sourcepub fn evaluate_obligation(
self,
key: CanonicalPredicateGoal<'tcx>
) -> evaluate_obligation<'tcx>
pub fn evaluate_obligation(
self,
key: CanonicalPredicateGoal<'tcx>
) -> evaluate_obligation<'tcx>
Do not call this query directly: invoke infcx.predicate_may_hold()
or
infcx.predicate_must_hold()
instead.
sourcepub fn evaluate_goal(
self,
key: CanonicalChalkEnvironmentAndGoal<'tcx>
) -> evaluate_goal<'tcx>
pub fn evaluate_goal(
self,
key: CanonicalChalkEnvironmentAndGoal<'tcx>
) -> evaluate_goal<'tcx>
[query description - consider adding a doc-comment!] evaluating trait selection obligation goal.value
sourcepub fn type_op_ascribe_user_type(
self,
key: CanonicalTypeOpAscribeUserTypeGoal<'tcx>
) -> type_op_ascribe_user_type<'tcx>
pub fn type_op_ascribe_user_type(
self,
key: CanonicalTypeOpAscribeUserTypeGoal<'tcx>
) -> type_op_ascribe_user_type<'tcx>
Do not call this query directly: part of the Eq
type-op
sourcepub fn type_op_eq(self, key: CanonicalTypeOpEqGoal<'tcx>) -> type_op_eq<'tcx>
pub fn type_op_eq(self, key: CanonicalTypeOpEqGoal<'tcx>) -> type_op_eq<'tcx>
Do not call this query directly: part of the Eq
type-op
sourcepub fn type_op_subtype(
self,
key: CanonicalTypeOpSubtypeGoal<'tcx>
) -> type_op_subtype<'tcx>
pub fn type_op_subtype(
self,
key: CanonicalTypeOpSubtypeGoal<'tcx>
) -> type_op_subtype<'tcx>
Do not call this query directly: part of the Subtype
type-op
sourcepub fn type_op_prove_predicate(
self,
key: CanonicalTypeOpProvePredicateGoal<'tcx>
) -> type_op_prove_predicate<'tcx>
pub fn type_op_prove_predicate(
self,
key: CanonicalTypeOpProvePredicateGoal<'tcx>
) -> type_op_prove_predicate<'tcx>
Do not call this query directly: part of the ProvePredicate
type-op
sourcepub fn type_op_normalize_ty(
self,
key: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>
) -> type_op_normalize_ty<'tcx>
pub fn type_op_normalize_ty(
self,
key: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>
) -> type_op_normalize_ty<'tcx>
Do not call this query directly: part of the Normalize
type-op
sourcepub fn type_op_normalize_predicate(
self,
key: CanonicalTypeOpNormalizeGoal<'tcx, Predicate<'tcx>>
) -> type_op_normalize_predicate<'tcx>
pub fn type_op_normalize_predicate(
self,
key: CanonicalTypeOpNormalizeGoal<'tcx, Predicate<'tcx>>
) -> type_op_normalize_predicate<'tcx>
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>>
) -> type_op_normalize_poly_fn_sig<'tcx>
pub fn type_op_normalize_poly_fn_sig(
self,
key: CanonicalTypeOpNormalizeGoal<'tcx, PolyFnSig<'tcx>>
) -> type_op_normalize_poly_fn_sig<'tcx>
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>>
) -> type_op_normalize_fn_sig<'tcx>
pub fn type_op_normalize_fn_sig(
self,
key: CanonicalTypeOpNormalizeGoal<'tcx, FnSig<'tcx>>
) -> type_op_normalize_fn_sig<'tcx>
Do not call this query directly: part of the Normalize
type-op
sourcepub fn subst_and_check_impossible_predicates(
self,
key: (DefId, SubstsRef<'tcx>)
) -> subst_and_check_impossible_predicates<'tcx>
pub fn subst_and_check_impossible_predicates(
self,
key: (DefId, SubstsRef<'tcx>)
) -> subst_and_check_impossible_predicates<'tcx>
[query description - consider adding a doc-comment!] checking impossible substituted predicates: tcx.def_path_str(key.0)
sourcepub fn is_impossible_method(
self,
key: (DefId, DefId)
) -> is_impossible_method<'tcx>
pub fn is_impossible_method(
self,
key: (DefId, DefId)
) -> is_impossible_method<'tcx>
[query description - consider adding a doc-comment!] checking if tcx.def_path_str(key.1)
is impossible to call within tcx.def_path_str(key.0)
sourcepub fn method_autoderef_steps(
self,
key: CanonicalTyGoal<'tcx>
) -> method_autoderef_steps<'tcx>
pub fn method_autoderef_steps(
self,
key: CanonicalTyGoal<'tcx>
) -> method_autoderef_steps<'tcx>
[query description - consider adding a doc-comment!] computing autoderef types for goal.value.value
sourcepub fn supported_target_features(
self,
key: CrateNum
) -> supported_target_features<'tcx>
pub fn supported_target_features(
self,
key: CrateNum
) -> supported_target_features<'tcx>
[query description - consider adding a doc-comment!] looking up supported target features
sourcepub fn instance_def_size_estimate(
self,
key: InstanceDef<'tcx>
) -> instance_def_size_estimate<'tcx>
pub fn instance_def_size_estimate(
self,
key: InstanceDef<'tcx>
) -> instance_def_size_estimate<'tcx>
Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning.
sourcepub fn features_query(self, key: ()) -> features_query<'tcx>
pub fn features_query(self, key: ()) -> features_query<'tcx>
[query description - consider adding a doc-comment!] looking up enabled feature gates
sourcepub fn resolve_instance(
self,
key: ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)>
) -> resolve_instance<'tcx>
pub fn resolve_instance(
self,
key: ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)>
) -> resolve_instance<'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 theSubstsRef
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 resolve_instance_of_const_arg(
self,
key: ParamEnvAnd<'tcx, (LocalDefId, DefId, SubstsRef<'tcx>)>
) -> resolve_instance_of_const_arg<'tcx>
pub fn resolve_instance_of_const_arg(
self,
key: ParamEnvAnd<'tcx, (LocalDefId, DefId, SubstsRef<'tcx>)>
) -> resolve_instance_of_const_arg<'tcx>
[query description - consider adding a doc-comment!] resolving instance of the const argument ty :: Instance :: new(key.value.0.to_def_id(), key.value.2)
sourcepub fn reveal_opaque_types_in_bounds(
self,
key: &'tcx List<Predicate<'tcx>>
) -> reveal_opaque_types_in_bounds<'tcx>
pub fn reveal_opaque_types_in_bounds(
self,
key: &'tcx List<Predicate<'tcx>>
) -> reveal_opaque_types_in_bounds<'tcx>
[query description - consider adding a doc-comment!] revealing opaque types in {:?}
sourcepub fn limits(self, key: ()) -> limits<'tcx>
pub fn limits(self, key: ()) -> limits<'tcx>
[query description - consider adding a doc-comment!] looking up limits
sourcepub fn diagnostic_hir_wf_check(
self,
key: (Predicate<'tcx>, WellFormedLoc)
) -> diagnostic_hir_wf_check<'tcx>
pub fn diagnostic_hir_wf_check(
self,
key: (Predicate<'tcx>, WellFormedLoc)
) -> diagnostic_hir_wf_check<'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: ()) -> global_backend_features<'tcx>
pub fn global_backend_features(self, key: ()) -> global_backend_features<'tcx>
The list of backend features computed from CLI flags (-Ctarget-cpu
, -Ctarget-feature
,
--target
and similar).
sourcepub fn generator_diagnostic_data(
self,
key: impl IntoQueryParam<DefId>
) -> generator_diagnostic_data<'tcx>
pub fn generator_diagnostic_data(
self,
key: impl IntoQueryParam<DefId>
) -> generator_diagnostic_data<'tcx>
[query description - consider adding a doc-comment!] looking up generator diagnostic data of tcx.def_path_str(key)
sourcepub fn permits_uninit_init(
self,
key: TyAndLayout<'tcx>
) -> permits_uninit_init<'tcx>
pub fn permits_uninit_init(
self,
key: TyAndLayout<'tcx>
) -> permits_uninit_init<'tcx>
[query description - consider adding a doc-comment!] checking to see if key.ty
permits being left uninit
sourcepub fn permits_zero_init(self, key: TyAndLayout<'tcx>) -> permits_zero_init<'tcx>
pub fn permits_zero_init(self, key: TyAndLayout<'tcx>) -> permits_zero_init<'tcx>
[query description - consider adding a doc-comment!] checking to see if key.ty
permits being left zeroed
sourcepub fn compare_assoc_const_impl_item_with_trait_item(
self,
key: (LocalDefId, DefId)
) -> compare_assoc_const_impl_item_with_trait_item<'tcx>
pub fn compare_assoc_const_impl_item_with_trait_item(
self,
key: (LocalDefId, DefId)
) -> compare_assoc_const_impl_item_with_trait_item<'tcx>
[query description - consider adding a doc-comment!] checking assoc const tcx.def_path_str(key.0.to_def_id())
has the same type as trait item
sourcepub fn deduced_param_attrs(
self,
key: impl IntoQueryParam<DefId>
) -> deduced_param_attrs<'tcx>
pub fn deduced_param_attrs(
self,
key: impl IntoQueryParam<DefId>
) -> deduced_param_attrs<'tcx>
[query description - consider adding a doc-comment!] deducing parameter attributes for tcx.def_path_str(def_id)
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
pub fn def_kind(self, def_id: impl IntoQueryParam<DefId>) -> DefKind
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
pub fn for_each_impl<F: FnMut(DefId)>(self, def_id: DefId, f: F)
sourcepub fn for_each_relevant_impl<F: FnMut(DefId)>(
self,
def_id: DefId,
self_ty: Ty<'tcx>,
f: F
)
pub fn for_each_relevant_impl<F: FnMut(DefId)>(
self,
def_id: DefId,
self_ty: Ty<'tcx>,
f: F
)
Iterate over every impl that could possibly match the
self type self_ty
.
pub fn non_blanket_impls_for_ty(
self,
def_id: DefId,
self_ty: Ty<'tcx>
) -> impl Iterator<Item = DefId> + 'tcx
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
sourcepub fn type_id_hash(self, ty: Ty<'tcx>) -> u64
pub fn type_id_hash(self, ty: Ty<'tcx>) -> u64
Creates a hash of the type Ty
which will be the same no matter what crate
context it’s calculated within. This is used by the type_id
intrinsic.
pub fn res_generics_def_id(self, res: Res) -> Option<DefId>
pub fn has_error_field(self, ty: Ty<'tcx>) -> bool
sourcepub fn struct_tail_without_normalization(self, ty: Ty<'tcx>) -> Ty<'tcx>
pub fn struct_tail_without_normalization(self, ty: Ty<'tcx>) -> Ty<'tcx>
Attempts to returns the deeply last field of nested structures, but
does not apply any normalization in its search. Returns the same type
if input ty
is not a structure at all.
sourcepub fn struct_tail_erasing_lifetimes(
self,
ty: Ty<'tcx>,
param_env: ParamEnv<'tcx>
) -> Ty<'tcx>
pub fn struct_tail_erasing_lifetimes(
self,
ty: Ty<'tcx>,
param_env: ParamEnv<'tcx>
) -> Ty<'tcx>
Returns the deeply last field of nested structures, or the same type if not a structure at all. Corresponds to the only possible unsized field, and its type can be used to determine unsizing strategy.
Should only be called if ty
has no inference variables and does not
need its lifetimes preserved (e.g. as part of codegen); otherwise
normalization attempt may cause compiler bugs.
sourcepub fn struct_tail_with_normalize(
self,
ty: Ty<'tcx>,
normalize: impl FnMut(Ty<'tcx>) -> Ty<'tcx>,
f: impl FnMut()
) -> Ty<'tcx>
pub fn struct_tail_with_normalize(
self,
ty: Ty<'tcx>,
normalize: impl FnMut(Ty<'tcx>) -> Ty<'tcx>,
f: impl FnMut()
) -> Ty<'tcx>
Returns the deeply last field of nested structures, or the same type if not a structure at all. Corresponds to the only possible unsized field, and its type can be used to determine unsizing strategy.
This is parameterized over the normalization strategy (i.e. how to
handle <T as Trait>::Assoc
and impl Trait
); pass the identity
function to indicate no normalization should take place.
See also struct_tail_erasing_lifetimes
, which is suitable for use
during codegen.
sourcepub fn struct_lockstep_tails_erasing_lifetimes(
self,
source: Ty<'tcx>,
target: Ty<'tcx>,
param_env: ParamEnv<'tcx>
) -> (Ty<'tcx>, Ty<'tcx>)
pub fn struct_lockstep_tails_erasing_lifetimes(
self,
source: Ty<'tcx>,
target: Ty<'tcx>,
param_env: ParamEnv<'tcx>
) -> (Ty<'tcx>, Ty<'tcx>)
Same as applying struct_tail
on source
and target
, but only
keeps going as long as the two types are instances of the same
structure definitions.
For (Foo<Foo<T>>, Foo<dyn Trait>)
, the result will be (Foo<T>, Trait)
,
whereas struct_tail produces T
, and Trait
, respectively.
Should only be called if the types have no inference variables and do not need their lifetimes preserved (e.g., as part of codegen); otherwise, normalization attempt may cause compiler bugs.
sourcepub fn struct_lockstep_tails_with_normalize(
self,
source: Ty<'tcx>,
target: Ty<'tcx>,
normalize: impl Fn(Ty<'tcx>) -> Ty<'tcx>
) -> (Ty<'tcx>, Ty<'tcx>)
pub fn struct_lockstep_tails_with_normalize(
self,
source: Ty<'tcx>,
target: Ty<'tcx>,
normalize: impl Fn(Ty<'tcx>) -> Ty<'tcx>
) -> (Ty<'tcx>, Ty<'tcx>)
Same as applying struct_tail
on source
and target
, but only
keeps going as long as the two types are instances of the same
structure definitions.
For (Foo<Foo<T>>, Foo<dyn Trait>)
, the result will be (Foo<T>, Trait)
,
whereas struct_tail produces T
, and Trait
, respectively.
See also struct_lockstep_tails_erasing_lifetimes
, which is suitable for use
during codegen.
sourcepub fn calculate_dtor(
self,
adt_did: DefId,
validate: impl Fn(Self, DefId) -> Result<(), ErrorGuaranteed>
) -> Option<Destructor>
pub fn calculate_dtor(
self,
adt_did: DefId,
validate: impl Fn(Self, DefId) -> Result<(), ErrorGuaranteed>
) -> Option<Destructor>
Calculate the destructor of a given type.
sourcepub fn destructor_constraints(self, def: AdtDef<'tcx>) -> Vec<GenericArg<'tcx>>
pub fn destructor_constraints(self, def: AdtDef<'tcx>) -> Vec<GenericArg<'tcx>>
Returns the set of types that are required to be alive in
order to run the destructor of def
(see RFCs 769 and
1238).
Note that this returns only the constraints for the
destructor of def
itself. For the destructors of the
contents, you need adt_dtorck_constraint
.
sourcepub fn uses_unique_generic_params(
self,
substs: SubstsRef<'tcx>,
ignore_regions: IgnoreRegions
) -> Result<(), NotUniqueParam<'tcx>>
pub fn uses_unique_generic_params(
self,
substs: SubstsRef<'tcx>,
ignore_regions: IgnoreRegions
) -> Result<(), NotUniqueParam<'tcx>>
Checks whether each generic argument is simply a unique generic parameter.
sourcepub fn is_closure(self, def_id: DefId) -> bool
pub fn is_closure(self, def_id: DefId) -> bool
Returns true
if def_id
refers to a closure (e.g., |x| x * 2
). Note
that closures have a DefId
, but the closure expression also
has a HirId
that is located within the context where the
closure appears (and, sadly, a corresponding NodeId
, since
those are not yet phased out). The parent of the closure’s
DefId
will also be the context where it appears.
sourcepub fn is_typeck_child(self, def_id: DefId) -> bool
pub fn is_typeck_child(self, def_id: DefId) -> bool
Returns true
if def_id
refers to a definition that does not have its own
type-checking context, i.e. closure, generator or inline const.
sourcepub fn is_trait(self, def_id: DefId) -> bool
pub fn is_trait(self, def_id: DefId) -> bool
Returns true
if def_id
refers to a trait (i.e., trait Foo { ... }
).
sourcepub fn is_trait_alias(self, def_id: DefId) -> bool
pub fn is_trait_alias(self, def_id: DefId) -> bool
Returns true
if def_id
refers to a trait alias (i.e., trait Foo = ...;
),
and false
otherwise.
sourcepub fn is_constructor(self, def_id: DefId) -> bool
pub fn is_constructor(self, def_id: DefId) -> bool
Returns true
if this DefId
refers to the implicit constructor for
a tuple struct like struct Foo(u32)
, and false
otherwise.
sourcepub fn typeck_root_def_id(self, def_id: DefId) -> DefId
pub fn typeck_root_def_id(self, def_id: DefId) -> DefId
Given the DefId
, returns the DefId
of the innermost item that
has its own type-checking context or “inference environment”.
For example, a closure has its own DefId
, but it is type-checked
with the containing item. Similarly, an inline const block has its
own DefId
but it is type-checked together with the containing item.
Therefore, when we fetch the
typeck
the closure, for example, we really wind up
fetching the typeck
the enclosing fn item.
sourcepub fn closure_env_ty(
self,
closure_def_id: DefId,
closure_substs: SubstsRef<'tcx>,
env_region: RegionKind<'tcx>
) -> Option<Ty<'tcx>>
pub fn closure_env_ty(
self,
closure_def_id: DefId,
closure_substs: SubstsRef<'tcx>,
env_region: RegionKind<'tcx>
) -> Option<Ty<'tcx>>
Given the DefId
and substs a closure, creates the type of
self
argument that the closure expects. For example, for a
Fn
closure, this would return a reference type &T
where
T = closure_ty
.
Returns None
if this closure’s kind has not yet been inferred.
This should only be possible during type checking.
Note that the return value is a late-bound region and hence wrapped in a binder.
sourcepub fn is_static(self, def_id: DefId) -> bool
pub fn is_static(self, def_id: DefId) -> bool
Returns true
if the node pointed to by def_id
is a static
item.
pub fn static_mutability(self, def_id: DefId) -> Option<Mutability>
sourcepub fn is_thread_local_static(self, def_id: DefId) -> bool
pub fn is_thread_local_static(self, def_id: DefId) -> bool
Returns true
if this is a static
item with the #[thread_local]
attribute.
sourcepub fn is_mutable_static(self, def_id: DefId) -> bool
pub fn is_mutable_static(self, def_id: DefId) -> bool
Returns true
if the node pointed to by def_id
is a mutable static
item.
sourcepub fn static_ptr_ty(self, def_id: DefId) -> Ty<'tcx>
pub fn static_ptr_ty(self, def_id: DefId) -> Ty<'tcx>
Get the type of the pointer to the static that we use in MIR.
sourcepub fn try_expand_impl_trait_type(
self,
def_id: DefId,
substs: SubstsRef<'tcx>
) -> Result<Ty<'tcx>, Ty<'tcx>>
pub fn try_expand_impl_trait_type(
self,
def_id: DefId,
substs: SubstsRef<'tcx>
) -> Result<Ty<'tcx>, Ty<'tcx>>
Expands the given impl trait type, stopping if the type is recursive.
pub fn bound_type_of(self, def_id: DefId) -> EarlyBinder<Ty<'tcx>>
pub fn bound_trait_impl_trait_tys(
self,
def_id: DefId
) -> EarlyBinder<Result<&'tcx FxHashMap<DefId, Ty<'tcx>>, ErrorGuaranteed>>
pub fn bound_fn_sig(self, def_id: DefId) -> EarlyBinder<PolyFnSig<'tcx>>
pub fn bound_impl_trait_ref(
self,
def_id: DefId
) -> Option<EarlyBinder<TraitRef<'tcx>>>
pub fn bound_explicit_item_bounds(
self,
def_id: DefId
) -> EarlyBinder<&'tcx [(Predicate<'tcx>, Span)]>
pub fn bound_item_bounds(
self,
def_id: DefId
) -> EarlyBinder<&'tcx List<Predicate<'tcx>>>
pub fn bound_const_param_default(self, def_id: DefId) -> EarlyBinder<Const<'tcx>>
pub fn bound_predicates_of(
self,
def_id: DefId
) -> EarlyBinder<GenericPredicates<'tcx>>
pub fn bound_explicit_predicates_of(
self,
def_id: DefId
) -> EarlyBinder<GenericPredicates<'tcx>>
pub fn bound_impl_subject(self, def_id: DefId) -> EarlyBinder<ImplSubject<'tcx>>
sourcepub fn closure_saved_names_of_captured_variables(
self,
def_id: DefId
) -> SmallVec<[String; 16]>
pub fn closure_saved_names_of_captured_variables(
self,
def_id: DefId
) -> SmallVec<[String; 16]>
Returns names of captured upvars for closures and generators.
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 generators this only contains upvars that are shared by all states.
pub fn generator_layout_and_saved_local_names(
self,
def_id: DefId
) -> (&'tcx GeneratorLayout<'tcx>, IndexVec<GeneratorSavedLocal, Option<Symbol>>)
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
sourcepub fn for_each_free_region(
self,
value: &impl TypeVisitable<'tcx>,
callback: impl FnMut(Region<'tcx>)
)
pub fn for_each_free_region(
self,
value: &impl TypeVisitable<'tcx>,
callback: impl FnMut(Region<'tcx>)
)
Invoke callback
on every region appearing free in value
.
sourcepub fn all_free_regions_meet(
self,
value: &impl TypeVisitable<'tcx>,
callback: impl FnMut(Region<'tcx>) -> bool
) -> bool
pub fn all_free_regions_meet(
self,
value: &impl TypeVisitable<'tcx>,
callback: impl FnMut(Region<'tcx>) -> bool
) -> bool
Returns true
if callback
returns true for every region appearing free in value
.
sourcepub fn any_free_region_meets(
self,
value: &impl TypeVisitable<'tcx>,
callback: impl FnMut(Region<'tcx>) -> bool
) -> bool
pub fn any_free_region_meets(
self,
value: &impl TypeVisitable<'tcx>,
callback: impl FnMut(Region<'tcx>) -> bool
) -> bool
Returns true
if callback
returns true for some region appearing free in value
.
sourcepub fn collect_constrained_late_bound_regions<T>(
self,
value: &Binder<'tcx, T>
) -> FxHashSet<BoundRegionKind>where
T: TypeVisitable<'tcx>,
pub fn collect_constrained_late_bound_regions<T>(
self,
value: &Binder<'tcx, T>
) -> FxHashSet<BoundRegionKind>where
T: TypeVisitable<'tcx>,
Returns a set of all late-bound regions that are constrained
by value
, meaning that if we instantiate those LBR with
variables and equate value
with something else, those
variables will also be equated.
sourcepub fn collect_referenced_late_bound_regions<T>(
self,
value: &Binder<'tcx, T>
) -> FxHashSet<BoundRegionKind>where
T: TypeVisitable<'tcx>,
pub fn collect_referenced_late_bound_regions<T>(
self,
value: &Binder<'tcx, T>
) -> FxHashSet<BoundRegionKind>where
T: TypeVisitable<'tcx>,
Returns a set of all late-bound regions that appear in value
anywhere.
fn collect_late_bound_regions<T>(
self,
value: &Binder<'tcx, T>,
just_constraint: bool
) -> FxHashSet<BoundRegionKind>where
T: TypeVisitable<'tcx>,
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
pub fn feed_unit_query(self) -> TyCtxtFeed<'tcx, ()>
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
sourcepub fn body_codegen_attrs(self, def_id: DefId) -> &'tcx CodegenFnAttrs
pub fn body_codegen_attrs(self, def_id: DefId) -> &'tcx CodegenFnAttrs
Expects a body and returns its codegen attributes.
Unlike codegen_fn_attrs
, this returns CodegenFnAttrs::EMPTY
for
constants.
pub fn typeck_opt_const_arg(
self,
def: WithOptConstParam<LocalDefId>
) -> &'tcx TypeckResults<'tcx>
pub fn mir_borrowck_opt_const_arg(
self,
def: WithOptConstParam<LocalDefId>
) -> &'tcx BorrowCheckResult<'tcx>
pub fn alloc_steal_thir(self, thir: Thir<'tcx>) -> &'tcx Steal<Thir<'tcx>>
pub fn alloc_steal_mir(self, mir: Body<'tcx>) -> &'tcx Steal<Body<'tcx>>
pub fn alloc_steal_promoted(
self,
promoted: IndexVec<Promoted, Body<'tcx>>
) -> &'tcx Steal<IndexVec<Promoted, Body<'tcx>>>
pub fn alloc_adt_def(
self,
did: DefId,
kind: AdtKind,
variants: IndexVec<VariantIdx, VariantDef>,
repr: ReprOptions
) -> AdtDef<'tcx>
sourcepub fn allocate_bytes(self, bytes: &[u8]) -> AllocId
pub fn allocate_bytes(self, bytes: &[u8]) -> AllocId
Allocates a read-only byte or string literal for mir::interpret
.
sourcepub fn layout_scalar_valid_range(
self,
def_id: DefId
) -> (Bound<u128>, Bound<u128>)
pub fn layout_scalar_valid_range(
self,
def_id: DefId
) -> (Bound<u128>, Bound<u128>)
Returns a range of the start/end indices specified with the
rustc_layout_scalar_valid_range
attribute.
pub fn lift<T: Lift<'tcx>>(self, value: T) -> Option<T::Lifted>
sourcepub fn create_global_ctxt(
s: &'tcx Session,
lint_store: Lrc<dyn Any + Send + Sync>,
arena: &'tcx WorkerLocal<Arena<'tcx>>,
hir_arena: &'tcx WorkerLocal<Arena<'tcx>>,
untracked_resolutions: ResolverGlobalCtxt,
untracked: Untracked,
krate: Lrc<Crate>,
dep_graph: DepGraph,
on_disk_cache: Option<&'tcx dyn OnDiskCache<'tcx>>,
queries: &'tcx dyn QueryEngine<'tcx>,
query_kinds: &'tcx [DepKindStruct<'tcx>],
crate_name: Symbol,
output_filenames: OutputFilenames
) -> GlobalCtxt<'tcx>
pub fn create_global_ctxt(
s: &'tcx Session,
lint_store: Lrc<dyn Any + Send + Sync>,
arena: &'tcx WorkerLocal<Arena<'tcx>>,
hir_arena: &'tcx WorkerLocal<Arena<'tcx>>,
untracked_resolutions: ResolverGlobalCtxt,
untracked: Untracked,
krate: Lrc<Crate>,
dep_graph: DepGraph,
on_disk_cache: Option<&'tcx dyn OnDiskCache<'tcx>>,
queries: &'tcx dyn QueryEngine<'tcx>,
query_kinds: &'tcx [DepKindStruct<'tcx>],
crate_name: Symbol,
output_filenames: OutputFilenames
) -> GlobalCtxt<'tcx>
Creates a type context and call the closure with a TyCtxt
reference
to the context. The closure enforces that the type context and any interned
value (types, substs, etc.) can only be used while ty::tls
has a valid
reference to the context, to allow formatting values that need it.
sourcepub fn ty_error_with_guaranteed(self, reported: ErrorGuaranteed) -> Ty<'tcx>
pub fn ty_error_with_guaranteed(self, reported: ErrorGuaranteed) -> Ty<'tcx>
Constructs a TyKind::Error
type with current ErrorGuaranteed
sourcepub fn ty_error(self) -> Ty<'tcx>
pub fn ty_error(self) -> Ty<'tcx>
Constructs a TyKind::Error
type and registers a delay_span_bug
to ensure it gets used.
sourcepub fn ty_error_with_message<S: Into<MultiSpan>>(
self,
span: S,
msg: &str
) -> Ty<'tcx>
pub fn ty_error_with_message<S: Into<MultiSpan>>(
self,
span: S,
msg: &str
) -> Ty<'tcx>
Constructs a TyKind::Error
type and registers a delay_span_bug
with the given msg
to
ensure it gets used.
sourcepub fn const_error_with_guaranteed(
self,
ty: Ty<'tcx>,
reported: ErrorGuaranteed
) -> Const<'tcx>
pub fn const_error_with_guaranteed(
self,
ty: Ty<'tcx>,
reported: ErrorGuaranteed
) -> Const<'tcx>
Like TyCtxt::ty_error but for constants, with current ErrorGuaranteed
sourcepub fn const_error(self, ty: Ty<'tcx>) -> Const<'tcx>
pub fn const_error(self, ty: Ty<'tcx>) -> Const<'tcx>
Like TyCtxt::ty_error but for constants.
sourcepub fn const_error_with_message<S: Into<MultiSpan>>(
self,
ty: Ty<'tcx>,
span: S,
msg: &str
) -> Const<'tcx>
pub fn const_error_with_message<S: Into<MultiSpan>>(
self,
ty: Ty<'tcx>,
span: S,
msg: &str
) -> Const<'tcx>
Like TyCtxt::ty_error_with_message but for constants.
pub fn consider_optimizing<T: Fn() -> String>(self, msg: T) -> bool
sourcepub fn lang_items(self) -> &'tcx LanguageItems
pub fn lang_items(self) -> &'tcx LanguageItems
Obtain all lang items of this crate and all dependencies (recursively)
sourcepub fn get_diagnostic_item(self, name: Symbol) -> Option<DefId>
pub fn get_diagnostic_item(self, name: Symbol) -> Option<DefId>
Obtain the given diagnostic item’s DefId
. Use is_diagnostic_item
if you just want to
compare against another DefId
, since is_diagnostic_item
is cheaper.
sourcepub fn get_diagnostic_name(self, id: DefId) -> Option<Symbol>
pub fn get_diagnostic_name(self, id: DefId) -> Option<Symbol>
Obtain the diagnostic item’s name
sourcepub fn is_diagnostic_item(self, name: Symbol, did: DefId) -> bool
pub fn is_diagnostic_item(self, name: Symbol, did: DefId) -> bool
Check whether the diagnostic item with the given name
has the given DefId
.
sourcepub fn generator_is_async(self, def_id: DefId) -> bool
pub fn generator_is_async(self, def_id: DefId) -> bool
Returns true
if the node pointed to by def_id
is a generator for an async construct.
pub fn stability(self) -> &'tcx Index
pub fn features(self) -> &'tcx Features
pub fn def_key(self, id: DefId) -> DefKey
sourcepub fn def_path(self, id: DefId) -> DefPath
pub fn def_path(self, id: DefId) -> DefPath
Converts a DefId
into its fully expanded DefPath
(every
DefId
is really just an interned DefPath
).
Note that if id
is not local to this crate, the result will
be a non-local DefPath
.
pub fn def_path_hash(self, def_id: DefId) -> DefPathHash
pub fn stable_crate_id(self, crate_num: CrateNum) -> StableCrateId
sourcepub fn stable_crate_id_to_crate_num(
self,
stable_crate_id: StableCrateId
) -> CrateNum
pub fn stable_crate_id_to_crate_num(
self,
stable_crate_id: StableCrateId
) -> CrateNum
Maps a StableCrateId to the corresponding CrateNum. This method assumes that the crate in question has already been loaded by the CrateStore.
sourcepub fn def_path_hash_to_def_id(
self,
hash: DefPathHash,
err: &mut dyn FnMut() -> !
) -> DefId
pub fn def_path_hash_to_def_id(
self,
hash: DefPathHash,
err: &mut dyn FnMut() -> !
) -> 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
.
pub fn def_path_debug_str(self, def_id: DefId) -> String
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
pub fn iter_local_def_id(self) -> impl Iterator<Item = LocalDefId> + 'tcx
pub fn def_path_table(self) -> &'tcx DefPathTable
pub fn def_path_hash_to_def_index_map(self) -> &'tcx DefPathHashMap
sourcepub fn cstore_untracked(self) -> &'tcx CrateStoreDyn
pub fn cstore_untracked(self) -> &'tcx CrateStoreDyn
Note that this is untracked and should only be used within the query system if the result is otherwise tracked through queries
sourcepub fn definitions_untracked(self) -> ReadGuard<'tcx, Definitions>
pub fn definitions_untracked(self) -> ReadGuard<'tcx, Definitions>
Note that this is untracked and should only be used within the query system if the result is otherwise tracked through queries
sourcepub fn source_span_untracked(self, def_id: LocalDefId) -> Span
pub fn source_span_untracked(self, def_id: LocalDefId) -> Span
Note that this is untracked and should only be used within the query system if the result is otherwise tracked through queries
pub fn with_stable_hashing_context<R>(
self,
f: impl FnOnce(StableHashingContext<'_>) -> R
) -> R
pub fn serialize_query_result_cache(
self,
encoder: FileEncoder
) -> FileEncodeResult
sourcepub fn lazy_normalization(self) -> bool
pub fn lazy_normalization(self) -> bool
If true
, we should use lazy normalization for constants, otherwise
we still evaluate them eagerly.
pub fn local_crate_exports_generics(self) -> bool
sourcepub fn is_suitable_region(self, region: Region<'tcx>) -> Option<FreeRegionInfo>
pub fn is_suitable_region(self, region: Region<'tcx>) -> Option<FreeRegionInfo>
Returns the DefId
and the BoundRegionKind
corresponding to the given region.
sourcepub fn return_type_impl_or_dyn_traits(
self,
scope_def_id: LocalDefId
) -> Vec<&'tcx Ty<'tcx>>
pub fn return_type_impl_or_dyn_traits(
self,
scope_def_id: LocalDefId
) -> Vec<&'tcx Ty<'tcx>>
Given a DefId
for an fn
, return all the dyn
and impl
traits in its return type.
pub fn return_type_impl_trait(
self,
scope_def_id: LocalDefId
) -> Option<(Ty<'tcx>, Span)>
sourcepub fn is_bound_region_in_impl_item(
self,
suitable_region_binding_scope: LocalDefId
) -> bool
pub fn is_bound_region_in_impl_item(
self,
suitable_region_binding_scope: LocalDefId
) -> bool
Checks if the bound region is in Impl Item.
sourcepub fn has_strict_asm_symbol_naming(self) -> bool
pub fn has_strict_asm_symbol_naming(self) -> bool
Determines whether identifiers in the assembly have strict naming rules. Currently, only NVPTX* targets need it.
sourcepub fn caller_location_ty(self) -> Ty<'tcx>
pub fn caller_location_ty(self) -> Ty<'tcx>
Returns &'static core::panic::Location<'static>
.
sourcepub fn article_and_description(
self,
def_id: DefId
) -> (&'static str, &'static str)
pub fn article_and_description(
self,
def_id: DefId
) -> (&'static str, &'static str)
Returns a displayable description and article for the given def_id
(e.g. ("a", "struct")
).
pub fn type_length_limit(self) -> Limit
pub fn recursion_limit(self) -> Limit
pub fn move_size_limit(self) -> Limit
pub fn const_eval_limit(self) -> Limit
pub fn all_traits(self) -> impl Iterator<Item = DefId> + 'tcx
pub fn local_visibility(self, def_id: LocalDefId) -> Visibility
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
pub fn intern_const_alloc(self, v: Allocation) -> ConstAllocation<'tcx>
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
pub fn intern_layout(self, v: LayoutS<VariantIdx>) -> Layout<'tcx>
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
pub fn intern_adt_def(self, v: AdtDefData) -> AdtDef<'tcx>
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
pub fn _intern_const_list(self, v: &[Const<'tcx>]) -> &'tcx List<Const<'tcx>>
pub fn _intern_substs(
self,
v: &[GenericArg<'tcx>]
) -> &'tcx List<GenericArg<'tcx>>
pub fn _intern_canonical_var_infos(
self,
v: &[CanonicalVarInfo<'tcx>]
) -> &'tcx List<CanonicalVarInfo<'tcx>>
pub fn _intern_poly_existential_predicates(
self,
v: &[PolyExistentialPredicate<'tcx>]
) -> &'tcx List<PolyExistentialPredicate<'tcx>>
pub fn _intern_predicates(
self,
v: &[Predicate<'tcx>]
) -> &'tcx List<Predicate<'tcx>>
pub fn _intern_projs(self, v: &[ProjectionKind]) -> &'tcx List<ProjectionKind>
pub fn _intern_place_elems(
self,
v: &[PlaceElem<'tcx>]
) -> &'tcx List<PlaceElem<'tcx>>
pub fn _intern_bound_variable_kinds(
self,
v: &[BoundVariableKind]
) -> &'tcx List<BoundVariableKind>
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
sourcepub fn safe_to_unsafe_fn_ty(self, sig: PolyFnSig<'tcx>) -> Ty<'tcx>
pub fn safe_to_unsafe_fn_ty(self, sig: PolyFnSig<'tcx>) -> Ty<'tcx>
Given a fn
type, returns an equivalent unsafe fn
type;
that is, a fn
type that is equivalent in every way for being
unsafe.
sourcepub fn trait_may_define_assoc_type(
self,
trait_def_id: DefId,
assoc_name: Ident
) -> bool
pub fn trait_may_define_assoc_type(
self,
trait_def_id: DefId,
assoc_name: Ident
) -> bool
Given the def_id of a Trait trait_def_id
and the name of an associated item assoc_name
returns true if the trait_def_id
defines an associated item of name assoc_name
.
sourcepub fn ty_is_opaque_future(self, ty: Ty<'_>) -> bool
pub fn ty_is_opaque_future(self, ty: Ty<'_>) -> bool
Given a ty
, return whether it’s an impl Future<...>
.
sourcefn super_traits_of(
self,
trait_def_id: DefId
) -> impl Iterator<Item = DefId> + 'tcx
fn super_traits_of(
self,
trait_def_id: DefId
) -> impl Iterator<Item = DefId> + 'tcx
Computes the def-ids of the transitive supertraits of trait_def_id
. This (intentionally)
does not compute the full elaborated super-predicates but just the set of def-ids. It is used
to identify which traits may define a given associated type to help avoid cycle errors.
Returns a DefId
iterator.
sourcepub fn signature_unclosure(
self,
sig: PolyFnSig<'tcx>,
unsafety: Unsafety
) -> PolyFnSig<'tcx>
pub fn signature_unclosure(
self,
sig: PolyFnSig<'tcx>,
unsafety: Unsafety
) -> PolyFnSig<'tcx>
Given a closure signature, returns an equivalent fn signature. Detuples
and so forth – so e.g., if we have a sig with Fn<(u32, i32)>
then
you would get a fn(u32, i32)
.
unsafety
determines the unsafety of the fn signature. If you pass
hir::Unsafety::Unsafe
in the previous example, then you would get
an unsafe fn (u32, i32)
.
It cannot convert a closure that requires unsafe.
sourcepub fn reuse_or_mk_region(
self,
r: Region<'tcx>,
kind: RegionKind<'tcx>
) -> Region<'tcx>
pub fn reuse_or_mk_region(
self,
r: Region<'tcx>,
kind: RegionKind<'tcx>
) -> Region<'tcx>
Same a self.mk_region(kind)
, but avoids accessing the interners if
*r == kind
.
pub fn mk_ty(self, st: TyKind<'tcx>) -> Ty<'tcx>
pub fn mk_predicate(
self,
binder: Binder<'tcx, PredicateKind<'tcx>>
) -> Predicate<'tcx>
pub fn reuse_or_mk_predicate(
self,
pred: Predicate<'tcx>,
binder: Binder<'tcx, PredicateKind<'tcx>>
) -> Predicate<'tcx>
pub fn mk_mach_int(self, tm: IntTy) -> Ty<'tcx>
pub fn mk_mach_uint(self, tm: UintTy) -> Ty<'tcx>
pub fn mk_mach_float(self, tm: FloatTy) -> Ty<'tcx>
pub fn mk_static_str(self) -> Ty<'tcx>
pub fn mk_adt(self, def: AdtDef<'tcx>, substs: SubstsRef<'tcx>) -> Ty<'tcx>
pub fn mk_foreign(self, def_id: DefId) -> Ty<'tcx>
fn mk_generic_adt(self, wrapper_def_id: DefId, ty_param: Ty<'tcx>) -> Ty<'tcx>
pub fn mk_box(self, ty: Ty<'tcx>) -> Ty<'tcx>
pub fn mk_lang_item(self, ty: Ty<'tcx>, item: LangItem) -> Option<Ty<'tcx>>
pub fn mk_diagnostic_item(self, ty: Ty<'tcx>, name: Symbol) -> Option<Ty<'tcx>>
pub fn mk_maybe_uninit(self, ty: Ty<'tcx>) -> Ty<'tcx>
pub fn mk_ptr(self, tm: TypeAndMut<'tcx>) -> Ty<'tcx>
pub fn mk_ref(self, r: Region<'tcx>, tm: TypeAndMut<'tcx>) -> Ty<'tcx>
pub fn mk_mut_ref(self, r: Region<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx>
pub fn mk_imm_ref(self, r: Region<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx>
pub fn mk_mut_ptr(self, ty: Ty<'tcx>) -> Ty<'tcx>
pub fn mk_imm_ptr(self, ty: Ty<'tcx>) -> Ty<'tcx>
pub fn mk_array(self, ty: Ty<'tcx>, n: u64) -> Ty<'tcx>
pub fn mk_slice(self, ty: Ty<'tcx>) -> Ty<'tcx>
pub fn intern_tup(self, ts: &[Ty<'tcx>]) -> Ty<'tcx>
pub fn mk_tup<I: InternAs<Ty<'tcx>, Ty<'tcx>>>(self, iter: I) -> I::Output
pub fn mk_unit(self) -> Ty<'tcx>
pub fn mk_diverging_default(self) -> Ty<'tcx>
pub fn mk_fn_def(
self,
def_id: DefId,
substs: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>
) -> Ty<'tcx>
fn check_substs(
self,
_def_id: DefId,
substs: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>
) -> SubstsRef<'tcx>
pub fn mk_fn_ptr(self, fty: PolyFnSig<'tcx>) -> Ty<'tcx>
pub fn mk_dynamic(
self,
obj: &'tcx List<PolyExistentialPredicate<'tcx>>,
reg: Region<'tcx>,
repr: DynKind
) -> Ty<'tcx>
pub fn mk_projection(
self,
item_def_id: DefId,
substs: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>
) -> Ty<'tcx>
pub fn mk_closure(
self,
closure_id: DefId,
closure_substs: SubstsRef<'tcx>
) -> Ty<'tcx>
pub fn mk_generator(
self,
id: DefId,
generator_substs: SubstsRef<'tcx>,
movability: Movability
) -> Ty<'tcx>
pub fn mk_generator_witness(
self,
types: Binder<'tcx, &'tcx List<Ty<'tcx>>>
) -> Ty<'tcx>
pub fn mk_ty_var(self, v: TyVid) -> Ty<'tcx>
pub fn mk_const(
self,
kind: impl Into<ConstKind<'tcx>>,
ty: Ty<'tcx>
) -> Const<'tcx>
pub fn mk_int_var(self, v: IntVid) -> Ty<'tcx>
pub fn mk_float_var(self, v: FloatVid) -> Ty<'tcx>
pub fn mk_ty_infer(self, it: InferTy) -> Ty<'tcx>
pub fn mk_ty_param(self, index: u32, name: Symbol) -> Ty<'tcx>
pub fn mk_param_from_def(self, param: &GenericParamDef) -> GenericArg<'tcx>
pub fn mk_opaque(self, def_id: DefId, substs: SubstsRef<'tcx>) -> Ty<'tcx>
pub fn mk_place_field(
self,
place: Place<'tcx>,
f: Field,
ty: Ty<'tcx>
) -> Place<'tcx>
pub fn mk_place_deref(self, place: Place<'tcx>) -> Place<'tcx>
pub fn mk_place_downcast(
self,
place: Place<'tcx>,
adt_def: AdtDef<'tcx>,
variant_index: VariantIdx
) -> Place<'tcx>
pub fn mk_place_downcast_unnamed(
self,
place: Place<'tcx>,
variant_index: VariantIdx
) -> Place<'tcx>
pub fn mk_place_index(self, place: Place<'tcx>, index: Local) -> Place<'tcx>
sourcepub fn mk_place_elem(
self,
place: Place<'tcx>,
elem: PlaceElem<'tcx>
) -> Place<'tcx>
pub fn mk_place_elem(
self,
place: Place<'tcx>,
elem: PlaceElem<'tcx>
) -> Place<'tcx>
This method copies Place
’s projection, add an element and reintern it. Should not be used
to build a full Place
it’s just a convenient way to grab a projection and modify it in
flight.
pub fn intern_poly_existential_predicates(
self,
eps: &[PolyExistentialPredicate<'tcx>]
) -> &'tcx List<PolyExistentialPredicate<'tcx>>
pub fn intern_predicates(
self,
preds: &[Predicate<'tcx>]
) -> &'tcx List<Predicate<'tcx>>
pub fn mk_const_list<I: InternAs<Const<'tcx>, &'tcx List<Const<'tcx>>>>(
self,
iter: I
) -> I::Output
pub fn intern_const_list(self, cs: &[Const<'tcx>]) -> &'tcx List<Const<'tcx>>
pub fn intern_type_list(self, ts: &[Ty<'tcx>]) -> &'tcx List<Ty<'tcx>>
pub fn intern_substs(
self,
ts: &[GenericArg<'tcx>]
) -> &'tcx List<GenericArg<'tcx>>
pub fn intern_projs(self, ps: &[ProjectionKind]) -> &'tcx List<ProjectionKind>
pub fn intern_place_elems(
self,
ts: &[PlaceElem<'tcx>]
) -> &'tcx List<PlaceElem<'tcx>>
pub fn intern_canonical_var_infos(
self,
ts: &[CanonicalVarInfo<'tcx>]
) -> CanonicalVarInfos<'tcx>
pub fn intern_bound_variable_kinds(
self,
ts: &[BoundVariableKind]
) -> &'tcx List<BoundVariableKind>
pub fn mk_fn_sig<I>(
self,
inputs: I,
output: I::Item,
c_variadic: bool,
unsafety: Unsafety,
abi: Abi
) -> <<I as Iterator>::Item as InternIteratorElement<Ty<'tcx>, FnSig<'tcx>>>::Outputwhere
I: Iterator<Item: InternIteratorElement<Ty<'tcx>, FnSig<'tcx>>>,
pub fn mk_poly_existential_predicates<I: InternAs<PolyExistentialPredicate<'tcx>, &'tcx List<PolyExistentialPredicate<'tcx>>>>(
self,
iter: I
) -> I::Output
pub fn mk_predicates<I: InternAs<Predicate<'tcx>, &'tcx List<Predicate<'tcx>>>>(
self,
iter: I
) -> I::Output
pub fn mk_type_list<I: InternAs<Ty<'tcx>, &'tcx List<Ty<'tcx>>>>(
self,
iter: I
) -> I::Output
pub fn mk_substs<I: InternAs<GenericArg<'tcx>, &'tcx List<GenericArg<'tcx>>>>(
self,
iter: I
) -> I::Output
pub fn mk_place_elems<I: InternAs<PlaceElem<'tcx>, &'tcx List<PlaceElem<'tcx>>>>(
self,
iter: I
) -> I::Output
pub fn mk_substs_trait(
self,
self_ty: Ty<'tcx>,
rest: impl IntoIterator<Item = GenericArg<'tcx>>
) -> SubstsRef<'tcx>
pub fn mk_trait_ref(
self,
trait_def_id: DefId,
substs: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>
) -> TraitRef<'tcx>
pub fn mk_alias_ty(
self,
def_id: DefId,
substs: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>
) -> AliasTy<'tcx>
pub fn mk_bound_variable_kinds<I: InternAs<BoundVariableKind, &'tcx List<BoundVariableKind>>>(
self,
iter: I
) -> I::Output
sourcepub fn emit_spanned_lint(
self,
lint: &'static Lint,
hir_id: HirId,
span: impl Into<MultiSpan>,
decorator: impl for<'a> DecorateLint<'a, ()>
)
pub fn emit_spanned_lint(
self,
lint: &'static Lint,
hir_id: HirId,
span: impl Into<MultiSpan>,
decorator: impl for<'a> DecorateLint<'a, ()>
)
Emit a lint at span
from a lint struct (some type that implements DecorateLint
,
typically generated by #[derive(LintDiagnostic)]
).
sourcepub fn struct_span_lint_hir(
self,
lint: &'static Lint,
hir_id: HirId,
span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>
)
pub fn struct_span_lint_hir(
self,
lint: &'static Lint,
hir_id: HirId,
span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>
)
Emit a lint at the appropriate level for a hir node, with an associated span.
Return value of the decorate
closure is ignored, see struct_lint_level
for a detailed explanation.
sourcepub fn emit_lint(
self,
lint: &'static Lint,
id: HirId,
decorator: impl for<'a> DecorateLint<'a, ()>
)
pub fn emit_lint(
self,
lint: &'static Lint,
id: HirId,
decorator: impl for<'a> DecorateLint<'a, ()>
)
Emit a lint from a lint struct (some type that implements DecorateLint
, typically
generated by #[derive(LintDiagnostic)]
).
sourcepub fn struct_lint_node(
self,
lint: &'static Lint,
id: HirId,
msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>
)
pub fn struct_lint_node(
self,
lint: &'static Lint,
id: HirId,
msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>
)
Emit a lint at the appropriate level for a hir node.
Return value of the decorate
closure is ignored, see struct_lint_level
for a detailed explanation.
pub fn in_scope_traits(self, id: HirId) -> Option<&'tcx [TraitCandidate]>
pub fn named_region(self, id: HirId) -> Option<Region>
pub fn is_late_bound(self, id: HirId) -> bool
pub fn late_bound_vars(self, id: HirId) -> &'tcx List<BoundVariableKind>
sourcepub fn is_const_fn(self, def_id: DefId) -> bool
pub fn is_const_fn(self, def_id: DefId) -> bool
Whether the def_id
counts as const fn in the current crate, considering all active
feature gates
sourcepub fn is_const_trait_impl_raw(self, def_id: DefId) -> bool
pub fn is_const_trait_impl_raw(self, def_id: DefId) -> bool
Whether the trait impl is marked const. This does not consider stability or feature gates.
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
sourcepub fn erase_regions<T>(self, value: T) -> Twhere
T: TypeFoldable<'tcx>,
pub fn erase_regions<T>(self, value: T) -> Twhere
T: TypeFoldable<'tcx>,
Returns an equivalent value with all free regions removed (note that late-bound regions remain, because they are important for subtyping, but they are anonymized and normalized as well)..
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
sourcepub const BOOL_TY_FOR_UNIT_TESTING: Ty<'tcx> = _
pub const BOOL_TY_FOR_UNIT_TESTING: Ty<'tcx> = _
A “bool” type used in rustc_mir_transform unit tests when we have not spun up a TyCtxt.
source§impl<'tcx> TyCtxt<'tcx>
impl<'tcx> TyCtxt<'tcx>
pub fn typeck_body(self, body: BodyId) -> &'tcx TypeckResults<'tcx>
pub fn provided_trait_methods(
self,
id: DefId
) -> impl 'tcx + Iterator<Item = &'tcx AssocItem>
pub fn repr_options_of_def(self, did: DefId) -> ReprOptions
sourcepub fn opt_item_name(self, def_id: DefId) -> Option<Symbol>
pub fn opt_item_name(self, def_id: DefId) -> Option<Symbol>
Look up the name of a definition across crates. This does not look at HIR.
sourcepub fn item_name(self, id: DefId) -> Symbol
pub fn item_name(self, id: DefId) -> Symbol
Look up the name of a definition across crates. This does not look at HIR.
This method will ICE if the corresponding item does not have a name. In these cases, use
opt_item_name
instead.
sourcepub fn opt_item_ident(self, def_id: DefId) -> Option<Ident>
pub fn opt_item_ident(self, def_id: DefId) -> Option<Ident>
Look up the name and span of a definition.
See item_name
for more information.
pub fn opt_associated_item(self, def_id: DefId) -> Option<&'tcx AssocItem>
pub fn find_field_index(self, ident: Ident, variant: &VariantDef) -> Option<usize>
sourcepub fn impls_are_allowed_to_overlap(
self,
def_id1: DefId,
def_id2: DefId
) -> Option<ImplOverlapKind>
pub fn impls_are_allowed_to_overlap(
self,
def_id1: DefId,
def_id2: DefId
) -> Option<ImplOverlapKind>
Returns true
if the impls are the same polarity and the trait either
has no items or is annotated #[marker]
and prevents item overrides.
sourcepub fn expect_variant_res(self, res: Res) -> &'tcx VariantDef
pub fn expect_variant_res(self, res: Res) -> &'tcx VariantDef
Returns ty::VariantDef
if res
refers to a struct,
or variant or their constructors, panics otherwise.
sourcepub fn instance_mir(self, instance: InstanceDef<'tcx>) -> &'tcx Body<'tcx>
pub fn instance_mir(self, instance: InstanceDef<'tcx>) -> &'tcx Body<'tcx>
Returns the possibly-auto-generated MIR of a (DefId, Subst)
pair.
pub fn get_attrs_unchecked(self, did: DefId) -> &'tcx [Attribute]
sourcepub fn get_attrs(self, did: DefId, attr: Symbol) -> Attributes<'tcx>
pub fn get_attrs(self, did: DefId, attr: Symbol) -> Attributes<'tcx>
Gets all attributes with the given name.
pub fn get_attr(self, did: DefId, attr: Symbol) -> Option<&'tcx Attribute>
sourcepub fn has_attr(self, did: DefId, attr: Symbol) -> bool
pub fn has_attr(self, did: DefId, attr: Symbol) -> bool
Determines whether an item is annotated with an attribute.
sourcepub fn trait_is_auto(self, trait_def_id: DefId) -> bool
pub fn trait_is_auto(self, trait_def_id: DefId) -> bool
Returns true
if this is an auto trait
.
pub fn trait_is_coinductive(self, trait_def_id: DefId) -> bool
sourcepub fn generator_layout(
self,
def_id: DefId
) -> Option<&'tcx GeneratorLayout<'tcx>>
pub fn generator_layout(
self,
def_id: DefId
) -> Option<&'tcx GeneratorLayout<'tcx>>
Returns layout of a generator. Layout might be unavailable if the generator is tainted by errors.
sourcepub fn trait_id_of_impl(self, def_id: DefId) -> Option<DefId>
pub fn trait_id_of_impl(self, def_id: DefId) -> Option<DefId>
Given the DefId
of an impl, returns the DefId
of the trait it implements.
If it implements no trait, returns None
.
sourcepub fn trait_of_item(self, def_id: DefId) -> Option<DefId>
pub fn trait_of_item(self, def_id: DefId) -> Option<DefId>
If the given DefId
describes an item belonging to a trait,
returns the DefId
of the trait that the trait item belongs to;
otherwise, returns None
.
sourcepub fn impl_of_method(self, def_id: DefId) -> Option<DefId>
pub fn impl_of_method(self, def_id: DefId) -> Option<DefId>
If the given DefId
describes a method belonging to an impl, returns the
DefId
of the impl that the method belongs to; otherwise, returns None
.
sourcepub fn is_builtin_derive(self, def_id: DefId) -> bool
pub fn is_builtin_derive(self, def_id: DefId) -> bool
If the given DefId
belongs to a trait that was automatically derived, returns true
.
sourcepub fn span_of_impl(self, impl_def_id: DefId) -> Result<Span, Symbol>
pub fn span_of_impl(self, impl_def_id: DefId) -> Result<Span, Symbol>
Looks up the span of impl_did
if the impl is local; otherwise returns Err
with the name of the crate containing the impl.
sourcepub fn hygienic_eq(
self,
use_name: Ident,
def_name: Ident,
def_parent_def_id: DefId
) -> bool
pub fn hygienic_eq(
self,
use_name: Ident,
def_name: Ident,
def_parent_def_id: DefId
) -> bool
Hygienically compares a use-site name (use_name
) for a field or an associated item with
its supposed definition name (def_name
). The method also needs DefId
of the supposed
definition’s parent/scope to perform comparison.
pub fn adjust_ident(self, ident: Ident, scope: DefId) -> Ident
pub fn adjust_ident_and_get_scope(
self,
ident: Ident,
scope: DefId,
block: HirId
) -> (Ident, DefId)
sourcepub fn should_collapse_debuginfo(self, span: Span) -> bool
pub fn should_collapse_debuginfo(self, span: Span) -> bool
Returns true
if the debuginfo for span
should be collapsed to the outermost expansion
site. Only applies when Span
is the result of macro expansion.
- If the
collapse_debuginfo
feature is enabled then debuginfo is not collapsed by default and only when a macro definition is annotated with#[collapse_debuginfo]
. - If
collapse_debuginfo
is not enabled, then debuginfo is collapsed by default.
When -Zdebug-macros
is provided then debuginfo will never be collapsed.
pub fn is_object_safe(self, key: DefId) -> bool
pub fn is_const_fn_raw(self, def_id: DefId) -> bool
pub fn is_const_default_method(self, def_id: DefId) -> bool
pub fn impl_trait_in_trait_parent(self, def_id: DefId) -> DefId
Trait Implementations§
source§impl<'tcx> DefIdTree for TyCtxt<'tcx>
impl<'tcx> DefIdTree for TyCtxt<'tcx>
fn opt_parent(self, id: DefId) -> Option<DefId>
fn parent(self, id: DefId) -> DefId
fn opt_local_parent(self, id: LocalDefId) -> Option<LocalDefId>
fn local_parent(self, id: LocalDefId) -> LocalDefId
fn is_descendant_of(self, descendant: DefId, ancestor: DefId) -> bool
source§impl<'tcx> DepContext for TyCtxt<'tcx>
impl<'tcx> DepContext for TyCtxt<'tcx>
type DepKind = DepKind
source§fn with_stable_hashing_context<R>(
&self,
f: impl FnOnce(StableHashingContext<'_>) -> R
) -> R
fn with_stable_hashing_context<R>(
&self,
f: impl FnOnce(StableHashingContext<'_>) -> R
) -> R
source§fn profiler(&self) -> &SelfProfilerRef
fn profiler(&self) -> &SelfProfilerRef
fn dep_kind_info(&self, dep_kind: DepKind) -> &DepKindStruct<'tcx>
fn fingerprint_style(&self, kind: Self::DepKind) -> FingerprintStyle
source§fn is_eval_always(&self, kind: Self::DepKind) -> bool
fn is_eval_always(&self, kind: Self::DepKind) -> bool
source§fn try_force_from_dep_node(self, dep_node: DepNode<Self::DepKind>) -> bool
fn try_force_from_dep_node(self, dep_node: DepNode<Self::DepKind>) -> bool
source§fn try_load_from_on_disk_cache(self, dep_node: DepNode<Self::DepKind>)
fn try_load_from_on_disk_cache(self, dep_node: DepNode<Self::DepKind>)
source§impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for ()
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for ()
fn fingerprint_style() -> FingerprintStyle
source§fn to_fingerprint(&self, _: TyCtxt<'tcx>) -> Fingerprint
fn to_fingerprint(&self, _: TyCtxt<'tcx>) -> Fingerprint
source§fn recover(_: TyCtxt<'tcx>, _: &DepNode) -> Option<Self>
fn recover(_: TyCtxt<'tcx>, _: &DepNode) -> Option<Self>
DepNode
,
something which is needed when forcing DepNode
s during red-green
evaluation. The query system will only call this method if
fingerprint_style()
is not FingerprintStyle::Opaque
.
It is always valid to return None
here, in which case incremental
compilation will treat the query as having changed instead of forcing it. Read morefn to_debug_str(&self, _: Tcx) -> String
source§impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for (DefId, DefId)
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for (DefId, DefId)
fn fingerprint_style() -> FingerprintStyle
source§fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String
source§fn recover(
tcx: Tcx,
dep_node: &DepNode<<Tcx as DepContext>::DepKind>
) -> Option<Self>
fn recover(
tcx: Tcx,
dep_node: &DepNode<<Tcx as DepContext>::DepKind>
) -> Option<Self>
DepNode
,
something which is needed when forcing DepNode
s during red-green
evaluation. The query system will only call this method if
fingerprint_style()
is not FingerprintStyle::Opaque
.
It is always valid to return None
here, in which case incremental
compilation will treat the query as having changed instead of forcing it. Read moresource§impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for CrateNum
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for CrateNum
fn fingerprint_style() -> FingerprintStyle
source§fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String
source§fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self>
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self>
DepNode
,
something which is needed when forcing DepNode
s during red-green
evaluation. The query system will only call this method if
fingerprint_style()
is not FingerprintStyle::Opaque
.
It is always valid to return None
here, in which case incremental
compilation will treat the query as having changed instead of forcing it. Read moresource§impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for DefId
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for DefId
fn fingerprint_style() -> FingerprintStyle
source§fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String
source§fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self>
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self>
DepNode
,
something which is needed when forcing DepNode
s during red-green
evaluation. The query system will only call this method if
fingerprint_style()
is not FingerprintStyle::Opaque
.
It is always valid to return None
here, in which case incremental
compilation will treat the query as having changed instead of forcing it. Read moresource§impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for HirId
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for HirId
fn fingerprint_style() -> FingerprintStyle
source§fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String
source§fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self>
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self>
DepNode
,
something which is needed when forcing DepNode
s during red-green
evaluation. The query system will only call this method if
fingerprint_style()
is not FingerprintStyle::Opaque
.
It is always valid to return None
here, in which case incremental
compilation will treat the query as having changed instead of forcing it. Read moresource§impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for LocalDefId
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for LocalDefId
fn fingerprint_style() -> FingerprintStyle
source§fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String
source§fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self>
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self>
DepNode
,
something which is needed when forcing DepNode
s during red-green
evaluation. The query system will only call this method if
fingerprint_style()
is not FingerprintStyle::Opaque
.
It is always valid to return None
here, in which case incremental
compilation will treat the query as having changed instead of forcing it. Read moresource§impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for OwnerId
impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for OwnerId
fn fingerprint_style() -> FingerprintStyle
source§fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint
fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String
source§fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self>
fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self>
DepNode
,
something which is needed when forcing DepNode
s during red-green
evaluation. The query system will only call this method if
fingerprint_style()
is not FingerprintStyle::Opaque
.
It is always valid to return None
here, in which case incremental
compilation will treat the query as having changed instead of forcing it. Read moresource§impl<'tcx> HasDataLayout for TyCtxt<'tcx>
impl<'tcx> HasDataLayout for TyCtxt<'tcx>
fn data_layout(&self) -> &TargetDataLayout
source§impl<'tcx> HasTargetSpec for TyCtxt<'tcx>
impl<'tcx> HasTargetSpec for TyCtxt<'tcx>
fn target_spec(&self) -> &Target
source§impl<'tcx> Interner for TyCtxt<'tcx>
impl<'tcx> Interner for TyCtxt<'tcx>
type AdtDef = AdtDef<'tcx>
type SubstsRef = &'tcx List<GenericArg<'tcx>>
type DefId = DefId
type Ty = Ty<'tcx>
type Const = Const<'tcx>
type Region = Region<'tcx>
type TypeAndMut = TypeAndMut<'tcx>
type Mutability = Mutability
type Movability = Movability
type PolyFnSig = Binder<'tcx, FnSig<'tcx>>
type ListBinderExistentialPredicate = &'tcx List<Binder<'tcx, ExistentialPredicate<'tcx>>>
type BinderListTy = Binder<'tcx, &'tcx List<Ty<'tcx>>>
type ListTy = &'tcx List<Ty<'tcx>>
type AliasTy = AliasTy<'tcx>
type ParamTy = ParamTy
type BoundTy = BoundTy
type PlaceholderType = Placeholder<BoundVar>
type InferTy = InferTy
type ErrorGuaranteed = ErrorGuaranteed
type PredicateKind = PredicateKind<'tcx>
type AllocId = AllocId
type EarlyBoundRegion = EarlyBoundRegion
type BoundRegion = BoundRegion
type FreeRegion = FreeRegion
type RegionVid = RegionVid
type PlaceholderRegion = Placeholder<BoundRegionKind>
source§impl<'tcx> Value<TyCtxt<'tcx>> for Binder<'_, FnSig<'_>>
impl<'tcx> Value<TyCtxt<'tcx>> for Binder<'_, FnSig<'_>>
fn from_cycle_error(tcx: TyCtxt<'tcx>, stack: &[QueryInfo]) -> Self
source§impl<'tcx> Value<TyCtxt<'tcx>> for Representability
impl<'tcx> Value<TyCtxt<'tcx>> for Representability
fn from_cycle_error(tcx: TyCtxt<'tcx>, cycle: &[QueryInfo]) -> Self
source§impl<'tcx> Value<TyCtxt<'tcx>> for SymbolName<'_>
impl<'tcx> Value<TyCtxt<'tcx>> for SymbolName<'_>
fn from_cycle_error(tcx: TyCtxt<'tcx>, _: &[QueryInfo]) -> Self
source§impl<'tcx> Value<TyCtxt<'tcx>> for Ty<'_>
impl<'tcx> Value<TyCtxt<'tcx>> for Ty<'_>
fn from_cycle_error(tcx: TyCtxt<'tcx>, _: &[QueryInfo]) -> Self
impl<'tcx> Copy for TyCtxt<'tcx>
Auto Trait Implementations§
impl<'tcx> !RefUnwindSafe for TyCtxt<'tcx>
impl<'tcx> !Send for TyCtxt<'tcx>
impl<'tcx> !Sync for TyCtxt<'tcx>
impl<'tcx> Unpin for TyCtxt<'tcx>
impl<'tcx> !UnwindSafe for TyCtxt<'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<T, R> InternIteratorElement<T, R> for T
impl<T, R> InternIteratorElement<T, R> for T
type Output = R
fn intern_with<I, F>(iter: I, f: F) -> <T as InternIteratorElement<T, R>>::Outputwhere
I: Iterator<Item = T>,
F: FnOnce(&[T]) -> R,
source§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
source§impl<'tcx, T> ToPredicate<'tcx, T> for T
impl<'tcx, T> ToPredicate<'tcx, T> for T
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> 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, _: &[QueryInfo]) -> T
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: 8 bytes