summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_middle/src/query/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_middle/src/query/mod.rs')
-rw-r--r--compiler/rustc_middle/src/query/mod.rs100
1 files changed, 59 insertions, 41 deletions
diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs
index 1528be42f..a059590e6 100644
--- a/compiler/rustc_middle/src/query/mod.rs
+++ b/compiler/rustc_middle/src/query/mod.rs
@@ -39,8 +39,8 @@ use crate::traits::query::{
};
use crate::traits::specialization_graph;
use crate::traits::{
- CanonicalChalkEnvironmentAndGoal, CodegenObligationError, EvaluationResult, ImplSource,
- ObjectSafetyViolation, ObligationCause, OverflowError, WellFormedLoc,
+ CodegenObligationError, EvaluationResult, ImplSource, ObjectSafetyViolation, ObligationCause,
+ OverflowError, WellFormedLoc,
};
use crate::ty::fast_reject::SimplifiedType;
use crate::ty::layout::ValidityRequirement;
@@ -54,7 +54,7 @@ use crate::ty::{
};
use rustc_arena::TypedArena;
use rustc_ast as ast;
-use rustc_ast::expand::allocator::AllocatorKind;
+use rustc_ast::expand::{allocator::AllocatorKind, StrippedCfgItem};
use rustc_attr as attr;
use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
@@ -346,7 +346,7 @@ rustc_queries! {
/// `key` is the `DefId` of the associated type or opaque type.
///
/// Bounds from the parent (e.g. with nested impl trait) are not included.
- query explicit_item_bounds(key: DefId) -> ty::EarlyBinder<&'tcx [(ty::Predicate<'tcx>, Span)]> {
+ query explicit_item_bounds(key: DefId) -> ty::EarlyBinder<&'tcx [(ty::Clause<'tcx>, Span)]> {
desc { |tcx| "finding item bounds for `{}`", tcx.def_path_str(key) }
cache_on_disk_if { key.is_local() }
separate_provide_extern
@@ -373,7 +373,7 @@ rustc_queries! {
/// ```
///
/// Bounds from the parent (e.g. with nested impl trait) are not included.
- query item_bounds(key: DefId) -> ty::EarlyBinder<&'tcx ty::List<ty::Predicate<'tcx>>> {
+ query item_bounds(key: DefId) -> ty::EarlyBinder<&'tcx ty::List<ty::Clause<'tcx>>> {
desc { |tcx| "elaborating item bounds for `{}`", tcx.def_path_str(key) }
}
@@ -531,6 +531,19 @@ rustc_queries! {
}
}
+ /// 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.
+ query closure_saved_names_of_captured_variables(def_id: DefId) -> &'tcx IndexVec<abi::FieldIdx, Symbol> {
+ arena_cache
+ desc { |tcx| "computing debuginfo for closure `{}`", tcx.def_path_str(def_id) }
+ separate_provide_extern
+ }
+
query mir_generator_witnesses(key: DefId) -> &'tcx Option<mir::GeneratorLayout<'tcx>> {
arena_cache
desc { |tcx| "generator witness types for `{}`", tcx.def_path_str(key) }
@@ -868,7 +881,7 @@ rustc_queries! {
///
/// 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.
- query assumed_wf_types(key: DefId) -> &'tcx ty::List<Ty<'tcx>> {
+ query assumed_wf_types(key: LocalDefId) -> &'tcx [(Ty<'tcx>, Span)] {
desc { |tcx| "computing the implied bounds of `{}`", tcx.def_path_str(key) }
}
@@ -1074,19 +1087,13 @@ rustc_queries! {
}
/// Tries to destructure an `mir::ConstantKind` ADT or array into its variant index
- /// and its field values.
- query try_destructure_mir_constant(
- key: ty::ParamEnvAnd<'tcx, mir::ConstantKind<'tcx>>
+ /// and its field values. This should only be used for pretty printing.
+ query try_destructure_mir_constant_for_diagnostics(
+ key: (ConstValue<'tcx>, Ty<'tcx>)
) -> Option<mir::DestructuredConstant<'tcx>> {
desc { "destructuring MIR constant"}
- }
-
- /// Dereference a constant reference or raw pointer and turn the result into a constant
- /// again.
- query deref_mir_constant(
- key: ty::ParamEnvAnd<'tcx, mir::ConstantKind<'tcx>>
- ) -> mir::ConstantKind<'tcx> {
- desc { "dereferencing MIR constant" }
+ no_hash
+ eval_always
}
query const_caller_location(key: (rustc_span::Symbol, u32, u32)) -> ConstValue<'tcx> {
@@ -1100,10 +1107,6 @@ rustc_queries! {
desc { "converting literal to const" }
}
- query lit_to_mir_constant(key: LitToConstInput<'tcx>) -> Result<mir::ConstantKind<'tcx>, LitToConstError> {
- desc { "converting literal to mir constant" }
- }
-
query check_match(key: LocalDefId) -> Result<(), rustc_errors::ErrorGuaranteed> {
desc { |tcx| "match-checking `{}`", tcx.def_path_str(key) }
cache_on_disk_if { true }
@@ -1275,7 +1278,7 @@ rustc_queries! {
}
query codegen_select_candidate(
- key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)
+ key: (ty::ParamEnv<'tcx>, ty::TraitRef<'tcx>)
) -> Result<&'tcx ImplSource<'tcx, ()>, CodegenObligationError> {
cache_on_disk_if { true }
desc { |tcx| "computing candidate for `{}`", key.1 }
@@ -1382,7 +1385,7 @@ rustc_queries! {
/// executes in "reveal all" mode, and will normalize the input type.
query layout_of(
key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
- ) -> Result<ty::layout::TyAndLayout<'tcx>, ty::layout::LayoutError<'tcx>> {
+ ) -> Result<ty::layout::TyAndLayout<'tcx>, &'tcx ty::layout::LayoutError<'tcx>> {
depth_limit
desc { "computing layout of `{}`", key.value }
}
@@ -1393,7 +1396,7 @@ rustc_queries! {
/// instead, where the instance is an `InstanceDef::Virtual`.
query fn_abi_of_fn_ptr(
key: ty::ParamEnvAnd<'tcx, (ty::PolyFnSig<'tcx>, &'tcx ty::List<Ty<'tcx>>)>
- ) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, ty::layout::FnAbiError<'tcx>> {
+ ) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, &'tcx ty::layout::FnAbiError<'tcx>> {
desc { "computing call ABI of `{}` function pointers", key.value.0 }
}
@@ -1404,7 +1407,7 @@ rustc_queries! {
/// to an `InstanceDef::Virtual` instance (of `<dyn Trait as Trait>::fn`).
query fn_abi_of_instance(
key: ty::ParamEnvAnd<'tcx, (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>)>
- ) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, ty::layout::FnAbiError<'tcx>> {
+ ) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, &'tcx ty::layout::FnAbiError<'tcx>> {
desc { "computing call ABI of `{}`", key.value.0 }
}
@@ -1487,8 +1490,9 @@ rustc_queries! {
desc { "getting traits in scope at a block" }
}
- query impl_defaultness(def_id: DefId) -> hir::Defaultness {
- desc { |tcx| "looking up whether `{}` is a default impl", tcx.def_path_str(def_id) }
+ /// Returns whether the impl or associated function has the `default` keyword.
+ query defaultness(def_id: DefId) -> hir::Defaultness {
+ desc { |tcx| "looking up whether `{}` has `default`", tcx.def_path_str(def_id) }
separate_provide_extern
feedable
}
@@ -1915,6 +1919,16 @@ rustc_queries! {
}
/// Do not call this query directly: invoke `normalize` instead.
+ query normalize_weak_ty(
+ goal: CanonicalProjectionGoal<'tcx>
+ ) -> Result<
+ &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>,
+ NoSolution,
+ > {
+ desc { "normalizing `{}`", goal.value.value }
+ }
+
+ /// Do not call this query directly: invoke `normalize` instead.
query normalize_inherent_projection_ty(
goal: CanonicalProjectionGoal<'tcx>
) -> Result<
@@ -1959,15 +1973,6 @@ rustc_queries! {
desc { "evaluating trait selection obligation `{}`", goal.value.value }
}
- query evaluate_goal(
- goal: CanonicalChalkEnvironmentAndGoal<'tcx>
- ) -> Result<
- &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
- NoSolution
- > {
- desc { "evaluating trait selection obligation `{}`", goal.value }
- }
-
/// Do not call this query directly: part of the `Eq` type-op
query type_op_ascribe_user_type(
goal: CanonicalTypeOpAscribeUserTypeGoal<'tcx>
@@ -2019,10 +2024,10 @@ rustc_queries! {
}
/// Do not call this query directly: part of the `Normalize` type-op
- query type_op_normalize_predicate(
- goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>>
+ query type_op_normalize_clause(
+ goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::Clause<'tcx>>
) -> Result<
- &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::Predicate<'tcx>>>,
+ &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::Clause<'tcx>>>,
NoSolution,
> {
desc { "normalizing `{:?}`", goal.value.value.value }
@@ -2113,7 +2118,7 @@ rustc_queries! {
desc { "resolving instance `{}`", ty::Instance::new(key.value.0, key.value.1) }
}
- query reveal_opaque_types_in_bounds(key: &'tcx ty::List<ty::Predicate<'tcx>>) -> &'tcx ty::List<ty::Predicate<'tcx>> {
+ query reveal_opaque_types_in_bounds(key: &'tcx ty::List<ty::Clause<'tcx>>) -> &'tcx ty::List<ty::Clause<'tcx>> {
desc { "revealing opaque types in `{:?}`", key }
}
@@ -2152,7 +2157,7 @@ rustc_queries! {
separate_provide_extern
}
- query check_validity_requirement(key: (ValidityRequirement, ty::ParamEnvAnd<'tcx, Ty<'tcx>>)) -> Result<bool, ty::layout::LayoutError<'tcx>> {
+ query check_validity_requirement(key: (ValidityRequirement, ty::ParamEnvAnd<'tcx, Ty<'tcx>>)) -> Result<bool, &'tcx ty::layout::LayoutError<'tcx>> {
desc { "checking validity requirement for `{}`: {}", key.1.value, key.0 }
}
@@ -2185,6 +2190,19 @@ rustc_queries! {
query check_tys_might_be_eq(arg: Canonical<'tcx, (ty::ParamEnv<'tcx>, Ty<'tcx>, Ty<'tcx>)>) -> Result<(), NoSolution> {
desc { "check whether two const param are definitely not equal to eachother"}
}
+
+ /// Get all item paths that were stripped by a `#[cfg]` in a particular crate.
+ /// Should not be called for the local crate before the resolver outputs are created, as it
+ /// is only fed there.
+ query stripped_cfg_items(cnum: CrateNum) -> &'tcx [StrippedCfgItem] {
+ feedable
+ desc { "getting cfg-ed out item names" }
+ separate_provide_extern
+ }
+
+ query generics_require_sized_self(def_id: DefId) -> bool {
+ desc { "check whether the item has a `where Self: Sized` bound" }
+ }
}
rustc_query_append! { define_callbacks! }