summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_middle/src/query
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
commit1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch)
tree3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /compiler/rustc_middle/src/query
parentReleasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz
rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_middle/src/query')
-rw-r--r--compiler/rustc_middle/src/query/erase.rs336
-rw-r--r--compiler/rustc_middle/src/query/keys.rs297
-rw-r--r--compiler/rustc_middle/src/query/mod.rs69
3 files changed, 440 insertions, 262 deletions
diff --git a/compiler/rustc_middle/src/query/erase.rs b/compiler/rustc_middle/src/query/erase.rs
new file mode 100644
index 000000000..7d9aea022
--- /dev/null
+++ b/compiler/rustc_middle/src/query/erase.rs
@@ -0,0 +1,336 @@
+use crate::mir;
+use crate::traits;
+use crate::ty::{self, Ty};
+use std::mem::{size_of, transmute_copy, MaybeUninit};
+
+#[derive(Copy, Clone)]
+pub struct Erased<T: Copy> {
+ // We use `MaybeUninit` here so we can store any value
+ // in `data` since we aren't actually storing a `T`.
+ data: MaybeUninit<T>,
+}
+
+pub trait EraseType: Copy {
+ type Result: Copy;
+}
+
+// Allow `type_alias_bounds` since compilation will fail without `EraseType`.
+#[allow(type_alias_bounds)]
+pub type Erase<T: EraseType> = Erased<impl Copy>;
+
+#[inline(always)]
+pub fn erase<T: EraseType>(src: T) -> Erase<T> {
+ // Ensure the sizes match
+ const {
+ if std::mem::size_of::<T>() != std::mem::size_of::<T::Result>() {
+ panic!("size of T must match erased type T::Result")
+ }
+ };
+
+ Erased::<<T as EraseType>::Result> {
+ // SAFETY: Is it safe to transmute to MaybeUninit for types with the same sizes.
+ data: unsafe { transmute_copy(&src) },
+ }
+}
+
+/// Restores an erased value.
+#[inline(always)]
+pub fn restore<T: EraseType>(value: Erase<T>) -> T {
+ let value: Erased<<T as EraseType>::Result> = value;
+ // SAFETY: Due to the use of impl Trait in `Erase` the only way to safely create an instance
+ // of `Erase` is to call `erase`, so we know that `value.data` is a valid instance of `T` of
+ // the right size.
+ unsafe { transmute_copy(&value.data) }
+}
+
+impl<T> EraseType for &'_ T {
+ type Result = [u8; size_of::<*const ()>()];
+}
+
+impl<T> EraseType for &'_ [T] {
+ type Result = [u8; size_of::<*const [()]>()];
+}
+
+impl<T> EraseType for &'_ ty::List<T> {
+ type Result = [u8; size_of::<*const ()>()];
+}
+
+impl<T> EraseType for Result<&'_ T, traits::query::NoSolution> {
+ type Result = [u8; size_of::<Result<&'static (), traits::query::NoSolution>>()];
+}
+
+impl<T> EraseType for Result<&'_ T, rustc_errors::ErrorGuaranteed> {
+ type Result = [u8; size_of::<Result<&'static (), rustc_errors::ErrorGuaranteed>>()];
+}
+
+impl<T> EraseType for Result<&'_ T, traits::CodegenObligationError> {
+ type Result = [u8; size_of::<Result<&'static (), traits::CodegenObligationError>>()];
+}
+
+impl<T> EraseType for Result<&'_ T, ty::layout::FnAbiError<'_>> {
+ type Result = [u8; size_of::<Result<&'static (), ty::layout::FnAbiError<'static>>>()];
+}
+
+impl<T> EraseType for Result<(&'_ T, rustc_middle::thir::ExprId), rustc_errors::ErrorGuaranteed> {
+ type Result = [u8; size_of::<
+ Result<(&'static (), rustc_middle::thir::ExprId), rustc_errors::ErrorGuaranteed>,
+ >()];
+}
+
+impl EraseType for Result<Option<ty::Instance<'_>>, rustc_errors::ErrorGuaranteed> {
+ type Result =
+ [u8; size_of::<Result<Option<ty::Instance<'static>>, rustc_errors::ErrorGuaranteed>>()];
+}
+
+impl EraseType for Result<Option<ty::Const<'_>>, rustc_errors::ErrorGuaranteed> {
+ type Result =
+ [u8; size_of::<Result<Option<ty::Const<'static>>, rustc_errors::ErrorGuaranteed>>()];
+}
+
+impl EraseType for Result<ty::GenericArg<'_>, traits::query::NoSolution> {
+ type Result = [u8; size_of::<Result<ty::GenericArg<'static>, traits::query::NoSolution>>()];
+}
+
+impl EraseType for Result<bool, ty::layout::LayoutError<'_>> {
+ type Result = [u8; size_of::<Result<bool, ty::layout::LayoutError<'static>>>()];
+}
+
+impl EraseType for Result<rustc_target::abi::TyAndLayout<'_, Ty<'_>>, ty::layout::LayoutError<'_>> {
+ type Result = [u8; size_of::<
+ Result<
+ rustc_target::abi::TyAndLayout<'static, Ty<'static>>,
+ ty::layout::LayoutError<'static>,
+ >,
+ >()];
+}
+
+impl EraseType for Result<ty::Const<'_>, mir::interpret::LitToConstError> {
+ type Result = [u8; size_of::<Result<ty::Const<'static>, mir::interpret::LitToConstError>>()];
+}
+
+impl EraseType for Result<mir::ConstantKind<'_>, mir::interpret::LitToConstError> {
+ type Result =
+ [u8; size_of::<Result<mir::ConstantKind<'static>, mir::interpret::LitToConstError>>()];
+}
+
+impl EraseType for Result<mir::interpret::ConstAlloc<'_>, mir::interpret::ErrorHandled> {
+ type Result = [u8; size_of::<
+ Result<mir::interpret::ConstAlloc<'static>, mir::interpret::ErrorHandled>,
+ >()];
+}
+
+impl EraseType for Result<mir::interpret::ConstValue<'_>, mir::interpret::ErrorHandled> {
+ type Result = [u8; size_of::<
+ Result<mir::interpret::ConstValue<'static>, mir::interpret::ErrorHandled>,
+ >()];
+}
+
+impl EraseType for Result<Option<ty::ValTree<'_>>, mir::interpret::ErrorHandled> {
+ type Result =
+ [u8; size_of::<Result<Option<ty::ValTree<'static>>, mir::interpret::ErrorHandled>>()];
+}
+
+impl EraseType for Result<&'_ ty::List<Ty<'_>>, ty::util::AlwaysRequiresDrop> {
+ type Result =
+ [u8; size_of::<Result<&'static ty::List<Ty<'static>>, ty::util::AlwaysRequiresDrop>>()];
+}
+
+impl<T> EraseType for Option<&'_ T> {
+ type Result = [u8; size_of::<Option<&'static ()>>()];
+}
+
+impl<T> EraseType for Option<&'_ [T]> {
+ type Result = [u8; size_of::<Option<&'static [()]>>()];
+}
+
+impl EraseType for Option<rustc_middle::hir::Owner<'_>> {
+ type Result = [u8; size_of::<Option<rustc_middle::hir::Owner<'static>>>()];
+}
+
+impl EraseType for Option<mir::DestructuredConstant<'_>> {
+ type Result = [u8; size_of::<Option<mir::DestructuredConstant<'static>>>()];
+}
+
+impl EraseType for Option<ty::EarlyBinder<ty::TraitRef<'_>>> {
+ type Result = [u8; size_of::<Option<ty::EarlyBinder<ty::TraitRef<'static>>>>()];
+}
+
+impl EraseType for Option<ty::EarlyBinder<Ty<'_>>> {
+ type Result = [u8; size_of::<Option<ty::EarlyBinder<Ty<'static>>>>()];
+}
+
+impl<T> EraseType for rustc_hir::MaybeOwner<&'_ T> {
+ type Result = [u8; size_of::<rustc_hir::MaybeOwner<&'static ()>>()];
+}
+
+impl<T: EraseType> EraseType for ty::EarlyBinder<T> {
+ type Result = T::Result;
+}
+
+impl EraseType for ty::Binder<'_, ty::FnSig<'_>> {
+ type Result = [u8; size_of::<ty::Binder<'static, ty::FnSig<'static>>>()];
+}
+
+impl<T0, T1> EraseType for (&'_ T0, &'_ T1) {
+ type Result = [u8; size_of::<(&'static (), &'static ())>()];
+}
+
+impl<T0, T1> EraseType for (&'_ T0, &'_ [T1]) {
+ type Result = [u8; size_of::<(&'static (), &'static [()])>()];
+}
+
+macro_rules! trivial {
+ ($($ty:ty),+ $(,)?) => {
+ $(
+ impl EraseType for $ty {
+ type Result = [u8; size_of::<$ty>()];
+ }
+ )*
+ }
+}
+
+trivial! {
+ (),
+ bool,
+ Option<(rustc_span::def_id::DefId, rustc_session::config::EntryFnType)>,
+ Option<rustc_ast::expand::allocator::AllocatorKind>,
+ Option<rustc_attr::ConstStability>,
+ Option<rustc_attr::DefaultBodyStability>,
+ Option<rustc_attr::Stability>,
+ Option<rustc_data_structures::svh::Svh>,
+ Option<rustc_hir::def::DefKind>,
+ Option<rustc_hir::GeneratorKind>,
+ Option<rustc_hir::HirId>,
+ Option<rustc_middle::middle::stability::DeprecationEntry>,
+ Option<rustc_middle::ty::Destructor>,
+ Option<rustc_middle::ty::ImplTraitInTraitData>,
+ Option<rustc_span::def_id::CrateNum>,
+ Option<rustc_span::def_id::DefId>,
+ Option<rustc_span::def_id::LocalDefId>,
+ Option<rustc_span::Span>,
+ Option<rustc_target::spec::PanicStrategy>,
+ Option<usize>,
+ Result<(), rustc_errors::ErrorGuaranteed>,
+ Result<(), rustc_middle::traits::query::NoSolution>,
+ Result<rustc_middle::traits::EvaluationResult, rustc_middle::traits::OverflowError>,
+ rustc_ast::expand::allocator::AllocatorKind,
+ rustc_attr::ConstStability,
+ rustc_attr::DefaultBodyStability,
+ rustc_attr::Deprecation,
+ rustc_attr::Stability,
+ rustc_data_structures::svh::Svh,
+ rustc_errors::ErrorGuaranteed,
+ rustc_hir::Constness,
+ rustc_hir::def_id::DefId,
+ rustc_hir::def_id::DefIndex,
+ rustc_hir::def_id::LocalDefId,
+ rustc_hir::def::DefKind,
+ rustc_hir::Defaultness,
+ rustc_hir::definitions::DefKey,
+ rustc_hir::GeneratorKind,
+ rustc_hir::HirId,
+ rustc_hir::IsAsync,
+ rustc_hir::ItemLocalId,
+ rustc_hir::LangItem,
+ rustc_hir::OwnerId,
+ rustc_hir::Upvar,
+ rustc_index::bit_set::FiniteBitSet<u32>,
+ rustc_middle::middle::dependency_format::Linkage,
+ rustc_middle::middle::exported_symbols::SymbolExportInfo,
+ rustc_middle::middle::resolve_bound_vars::ObjectLifetimeDefault,
+ rustc_middle::middle::resolve_bound_vars::ResolvedArg,
+ rustc_middle::middle::stability::DeprecationEntry,
+ rustc_middle::mir::ConstQualifs,
+ rustc_middle::mir::interpret::AllocId,
+ rustc_middle::mir::interpret::ErrorHandled,
+ rustc_middle::mir::interpret::LitToConstError,
+ rustc_middle::thir::ExprId,
+ rustc_middle::traits::CodegenObligationError,
+ rustc_middle::traits::EvaluationResult,
+ rustc_middle::traits::OverflowError,
+ rustc_middle::traits::query::NoSolution,
+ rustc_middle::traits::WellFormedLoc,
+ rustc_middle::ty::adjustment::CoerceUnsizedInfo,
+ rustc_middle::ty::AssocItem,
+ rustc_middle::ty::AssocItemContainer,
+ rustc_middle::ty::BoundVariableKind,
+ rustc_middle::ty::DeducedParamAttrs,
+ rustc_middle::ty::Destructor,
+ rustc_middle::ty::fast_reject::SimplifiedType,
+ rustc_middle::ty::ImplPolarity,
+ rustc_middle::ty::Representability,
+ rustc_middle::ty::ReprOptions,
+ rustc_middle::ty::UnusedGenericParams,
+ rustc_middle::ty::util::AlwaysRequiresDrop,
+ rustc_middle::ty::Visibility<rustc_span::def_id::DefId>,
+ rustc_session::config::CrateType,
+ rustc_session::config::EntryFnType,
+ rustc_session::config::OptLevel,
+ rustc_session::config::SymbolManglingVersion,
+ rustc_session::cstore::CrateDepKind,
+ rustc_session::cstore::ExternCrate,
+ rustc_session::cstore::LinkagePreference,
+ rustc_session::Limits,
+ rustc_session::lint::LintExpectationId,
+ rustc_span::def_id::CrateNum,
+ rustc_span::def_id::DefPathHash,
+ rustc_span::ExpnHash,
+ rustc_span::ExpnId,
+ rustc_span::Span,
+ rustc_span::Symbol,
+ rustc_span::symbol::Ident,
+ rustc_target::spec::PanicStrategy,
+ rustc_type_ir::Variance,
+ u32,
+ usize,
+}
+
+macro_rules! tcx_lifetime {
+ ($($($fake_path:ident)::+),+ $(,)?) => {
+ $(
+ impl<'tcx> EraseType for $($fake_path)::+<'tcx> {
+ type Result = [u8; size_of::<$($fake_path)::+<'static>>()];
+ }
+ )*
+ }
+}
+
+tcx_lifetime! {
+ rustc_middle::hir::Owner,
+ rustc_middle::middle::exported_symbols::ExportedSymbol,
+ rustc_middle::mir::ConstantKind,
+ rustc_middle::mir::DestructuredConstant,
+ rustc_middle::mir::interpret::ConstAlloc,
+ rustc_middle::mir::interpret::ConstValue,
+ rustc_middle::mir::interpret::GlobalId,
+ rustc_middle::mir::interpret::LitToConstInput,
+ rustc_middle::traits::ChalkEnvironmentAndGoal,
+ rustc_middle::traits::query::MethodAutoderefStepsResult,
+ rustc_middle::traits::query::type_op::AscribeUserType,
+ rustc_middle::traits::query::type_op::Eq,
+ rustc_middle::traits::query::type_op::ProvePredicate,
+ rustc_middle::traits::query::type_op::Subtype,
+ rustc_middle::ty::AdtDef,
+ rustc_middle::ty::AliasTy,
+ rustc_middle::ty::Clause,
+ rustc_middle::ty::ClosureTypeInfo,
+ rustc_middle::ty::Const,
+ rustc_middle::ty::DestructuredConst,
+ rustc_middle::ty::ExistentialTraitRef,
+ rustc_middle::ty::FnSig,
+ rustc_middle::ty::GenericArg,
+ rustc_middle::ty::GenericPredicates,
+ rustc_middle::ty::inhabitedness::InhabitedPredicate,
+ rustc_middle::ty::Instance,
+ rustc_middle::ty::InstanceDef,
+ rustc_middle::ty::layout::FnAbiError,
+ rustc_middle::ty::layout::LayoutError,
+ rustc_middle::ty::ParamEnv,
+ rustc_middle::ty::Predicate,
+ rustc_middle::ty::SymbolName,
+ rustc_middle::ty::TraitRef,
+ rustc_middle::ty::Ty,
+ rustc_middle::ty::UnevaluatedConst,
+ rustc_middle::ty::ValTree,
+ rustc_middle::ty::VtblEntry,
+}
diff --git a/compiler/rustc_middle/src/query/keys.rs b/compiler/rustc_middle/src/query/keys.rs
index 78ee8a6a8..23b28ac5c 100644
--- a/compiler/rustc_middle/src/query/keys.rs
+++ b/compiler/rustc_middle/src/query/keys.rs
@@ -12,6 +12,11 @@ use rustc_hir::hir_id::{HirId, OwnerId};
use rustc_query_system::query::{DefaultCacheSelector, SingleCacheSelector, VecCacheSelector};
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::{Span, DUMMY_SP};
+use rustc_target::abi::FieldIdx;
+
+/// Placeholder for `CrateNum`'s "local" counterpart
+#[derive(Copy, Clone, Debug)]
+pub struct LocalCrate;
/// The `Key` trait controls what types can legally be used as the key
/// for a query.
@@ -21,15 +26,11 @@ pub trait Key: Sized {
//
// ...But r-a doesn't support them yet and using a default here causes r-a to not infer
// return types of queries which is very annoying. Thus, until r-a support associated
- // type defaults, plese restrain from using them here <3
+ // type defaults, please restrain from using them here <3
//
// r-a issue: <https://github.com/rust-lang/rust-analyzer/issues/13693>
type CacheSelector;
- /// Given an instance of this key, what crate is it referring to?
- /// This is used to find the provider.
- fn query_crate_is_local(&self) -> bool;
-
/// In the event that a cycle occurs, if no explicit span has been
/// given for a query with key `self`, what span should we use?
fn default_span(&self, tcx: TyCtxt<'_>) -> Span;
@@ -45,14 +46,17 @@ pub trait Key: Sized {
}
}
+pub trait AsLocalKey: Key {
+ type LocalKey;
+
+ /// Given an instance of this key, what crate is it referring to?
+ /// This is used to find the provider.
+ fn as_local_key(&self) -> Option<Self::LocalKey>;
+}
+
impl Key for () {
type CacheSelector = SingleCacheSelector;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
-
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
}
@@ -61,23 +65,22 @@ impl Key for () {
impl<'tcx> Key for ty::InstanceDef<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
-
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.def_id())
}
}
-impl<'tcx> Key for ty::Instance<'tcx> {
- type CacheSelector = DefaultCacheSelector<Self>;
+impl<'tcx> AsLocalKey for ty::InstanceDef<'tcx> {
+ type LocalKey = Self;
#[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
+ fn as_local_key(&self) -> Option<Self::LocalKey> {
+ self.def_id().is_local().then(|| *self)
}
+}
+
+impl<'tcx> Key for ty::Instance<'tcx> {
+ type CacheSelector = DefaultCacheSelector<Self>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.def_id())
@@ -87,11 +90,6 @@ impl<'tcx> Key for ty::Instance<'tcx> {
impl<'tcx> Key for mir::interpret::GlobalId<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
-
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.instance.default_span(tcx)
}
@@ -100,11 +98,6 @@ impl<'tcx> Key for mir::interpret::GlobalId<'tcx> {
impl<'tcx> Key for (Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>) {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
-
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
}
@@ -113,11 +106,6 @@ impl<'tcx> Key for (Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>) {
impl<'tcx> Key for mir::interpret::LitToConstInput<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
-
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
}
@@ -126,25 +114,27 @@ impl<'tcx> Key for mir::interpret::LitToConstInput<'tcx> {
impl Key for CrateNum {
type CacheSelector = VecCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- *self == LOCAL_CRATE
- }
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
}
}
-impl Key for OwnerId {
- type CacheSelector = VecCacheSelector<Self>;
+impl AsLocalKey for CrateNum {
+ type LocalKey = LocalCrate;
#[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
+ fn as_local_key(&self) -> Option<Self::LocalKey> {
+ (*self == LOCAL_CRATE).then_some(LocalCrate)
}
+}
+
+impl Key for OwnerId {
+ type CacheSelector = VecCacheSelector<Self>;
+
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.to_def_id().default_span(tcx)
}
+
fn key_as_def_id(&self) -> Option<DefId> {
Some(self.to_def_id())
}
@@ -153,13 +143,10 @@ impl Key for OwnerId {
impl Key for LocalDefId {
type CacheSelector = VecCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.to_def_id().default_span(tcx)
}
+
fn key_as_def_id(&self) -> Option<DefId> {
Some(self.to_def_id())
}
@@ -168,26 +155,28 @@ impl Key for LocalDefId {
impl Key for DefId {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- self.krate == LOCAL_CRATE
- }
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(*self)
}
+
#[inline(always)]
fn key_as_def_id(&self) -> Option<DefId> {
Some(*self)
}
}
-impl Key for ty::WithOptConstParam<LocalDefId> {
- type CacheSelector = DefaultCacheSelector<Self>;
+impl AsLocalKey for DefId {
+ type LocalKey = LocalDefId;
#[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
+ fn as_local_key(&self) -> Option<Self::LocalKey> {
+ self.as_local()
}
+}
+
+impl Key for ty::WithOptConstParam<LocalDefId> {
+ type CacheSelector = DefaultCacheSelector<Self>;
+
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.did.default_span(tcx)
}
@@ -196,10 +185,6 @@ impl Key for ty::WithOptConstParam<LocalDefId> {
impl Key for SimplifiedType {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
}
@@ -208,10 +193,6 @@ impl Key for SimplifiedType {
impl Key for (DefId, DefId) {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- self.0.krate == LOCAL_CRATE
- }
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.1.default_span(tcx)
}
@@ -220,10 +201,6 @@ impl Key for (DefId, DefId) {
impl<'tcx> Key for (ty::Instance<'tcx>, LocalDefId) {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.0.default_span(tcx)
}
@@ -232,10 +209,6 @@ impl<'tcx> Key for (ty::Instance<'tcx>, LocalDefId) {
impl Key for (DefId, LocalDefId) {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- self.0.krate == LOCAL_CRATE
- }
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.1.default_span(tcx)
}
@@ -244,10 +217,6 @@ impl Key for (DefId, LocalDefId) {
impl Key for (LocalDefId, DefId) {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.0.default_span(tcx)
}
@@ -256,38 +225,27 @@ impl Key for (LocalDefId, DefId) {
impl Key for (LocalDefId, LocalDefId) {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.0.default_span(tcx)
}
}
-impl Key for (DefId, Option<Ident>) {
+impl Key for (DefId, Ident) {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- self.0.krate == LOCAL_CRATE
- }
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.0)
}
+
#[inline(always)]
fn key_as_def_id(&self) -> Option<DefId> {
Some(self.0)
}
}
-impl Key for (DefId, LocalDefId, Ident) {
+impl Key for (LocalDefId, LocalDefId, Ident) {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- self.0.krate == LOCAL_CRATE
- }
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.1.default_span(tcx)
}
@@ -296,34 +254,40 @@ impl Key for (DefId, LocalDefId, Ident) {
impl Key for (CrateNum, DefId) {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- self.0 == LOCAL_CRATE
- }
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.1.default_span(tcx)
}
}
-impl Key for (CrateNum, SimplifiedType) {
- type CacheSelector = DefaultCacheSelector<Self>;
+impl AsLocalKey for (CrateNum, DefId) {
+ type LocalKey = DefId;
#[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- self.0 == LOCAL_CRATE
+ fn as_local_key(&self) -> Option<Self::LocalKey> {
+ (self.0 == LOCAL_CRATE).then(|| self.1)
}
+}
+
+impl Key for (CrateNum, SimplifiedType) {
+ type CacheSelector = DefaultCacheSelector<Self>;
+
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
}
}
-impl Key for (DefId, SimplifiedType) {
- type CacheSelector = DefaultCacheSelector<Self>;
+impl AsLocalKey for (CrateNum, SimplifiedType) {
+ type LocalKey = SimplifiedType;
#[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- self.0.krate == LOCAL_CRATE
+ fn as_local_key(&self) -> Option<Self::LocalKey> {
+ (self.0 == LOCAL_CRATE).then(|| self.1)
}
+}
+
+impl Key for (DefId, SimplifiedType) {
+ type CacheSelector = DefaultCacheSelector<Self>;
+
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.0.default_span(tcx)
}
@@ -332,10 +296,6 @@ impl Key for (DefId, SimplifiedType) {
impl<'tcx> Key for SubstsRef<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
}
@@ -344,10 +304,6 @@ impl<'tcx> Key for SubstsRef<'tcx> {
impl<'tcx> Key for (DefId, SubstsRef<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- self.0.krate == LOCAL_CRATE
- }
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.0.default_span(tcx)
}
@@ -356,10 +312,6 @@ impl<'tcx> Key for (DefId, SubstsRef<'tcx>) {
impl<'tcx> Key for (ty::UnevaluatedConst<'tcx>, ty::UnevaluatedConst<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- (self.0).def.did.krate == LOCAL_CRATE
- }
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
(self.0).def.did.default_span(tcx)
}
@@ -368,10 +320,6 @@ impl<'tcx> Key for (ty::UnevaluatedConst<'tcx>, ty::UnevaluatedConst<'tcx>) {
impl<'tcx> Key for (LocalDefId, DefId, SubstsRef<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.0.default_span(tcx)
}
@@ -380,22 +328,14 @@ impl<'tcx> Key for (LocalDefId, DefId, SubstsRef<'tcx>) {
impl<'tcx> Key for (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- self.1.def_id().krate == LOCAL_CRATE
- }
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.1.def_id())
}
}
-impl<'tcx> Key for (ty::Const<'tcx>, mir::Field) {
+impl<'tcx> Key for (ty::Const<'tcx>, FieldIdx) {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
}
@@ -404,10 +344,6 @@ impl<'tcx> Key for (ty::Const<'tcx>, mir::Field) {
impl<'tcx> Key for mir::interpret::ConstAlloc<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
}
@@ -416,10 +352,6 @@ impl<'tcx> Key for mir::interpret::ConstAlloc<'tcx> {
impl<'tcx> Key for ty::PolyTraitRef<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- self.def_id().krate == LOCAL_CRATE
- }
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.def_id())
}
@@ -428,10 +360,6 @@ impl<'tcx> Key for ty::PolyTraitRef<'tcx> {
impl<'tcx> Key for ty::PolyExistentialTraitRef<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- self.def_id().krate == LOCAL_CRATE
- }
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.def_id())
}
@@ -440,10 +368,6 @@ impl<'tcx> Key for ty::PolyExistentialTraitRef<'tcx> {
impl<'tcx> Key for (ty::PolyTraitRef<'tcx>, ty::PolyTraitRef<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- self.0.def_id().krate == LOCAL_CRATE
- }
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.0.def_id())
}
@@ -452,10 +376,6 @@ impl<'tcx> Key for (ty::PolyTraitRef<'tcx>, ty::PolyTraitRef<'tcx>) {
impl<'tcx> Key for GenericArg<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
}
@@ -464,10 +384,6 @@ impl<'tcx> Key for GenericArg<'tcx> {
impl<'tcx> Key for mir::ConstantKind<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
}
@@ -476,10 +392,6 @@ impl<'tcx> Key for mir::ConstantKind<'tcx> {
impl<'tcx> Key for ty::Const<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
}
@@ -488,13 +400,10 @@ impl<'tcx> Key for ty::Const<'tcx> {
impl<'tcx> Key for Ty<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
}
+
fn ty_adt_id(&self) -> Option<DefId> {
match self.kind() {
ty::Adt(adt, _) => Some(adt.did()),
@@ -506,10 +415,6 @@ impl<'tcx> Key for Ty<'tcx> {
impl<'tcx> Key for TyAndLayout<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
}
@@ -518,10 +423,6 @@ impl<'tcx> Key for TyAndLayout<'tcx> {
impl<'tcx> Key for (Ty<'tcx>, Ty<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
}
@@ -530,10 +431,6 @@ impl<'tcx> Key for (Ty<'tcx>, Ty<'tcx>) {
impl<'tcx> Key for &'tcx ty::List<ty::Predicate<'tcx>> {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
}
@@ -542,10 +439,6 @@ impl<'tcx> Key for &'tcx ty::List<ty::Predicate<'tcx>> {
impl<'tcx> Key for ty::ParamEnv<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
}
@@ -554,10 +447,6 @@ impl<'tcx> Key for ty::ParamEnv<'tcx> {
impl<'tcx, T: Key> Key for ty::ParamEnvAnd<'tcx, T> {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- self.value.query_crate_is_local()
- }
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.value.default_span(tcx)
}
@@ -566,10 +455,6 @@ impl<'tcx, T: Key> Key for ty::ParamEnvAnd<'tcx, T> {
impl Key for Symbol {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
}
@@ -578,10 +463,6 @@ impl Key for Symbol {
impl Key for Option<Symbol> {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
}
@@ -589,14 +470,9 @@ impl Key for Option<Symbol> {
/// Canonical query goals correspond to abstract trait operations that
/// are not tied to any crate in particular.
-impl<'tcx, T> Key for Canonical<'tcx, T> {
+impl<'tcx, T: Clone> Key for Canonical<'tcx, T> {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
-
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
}
@@ -605,11 +481,6 @@ impl<'tcx, T> Key for Canonical<'tcx, T> {
impl Key for (Symbol, u32, u32) {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
-
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
}
@@ -618,11 +489,6 @@ impl Key for (Symbol, u32, u32) {
impl<'tcx> Key for (DefId, Ty<'tcx>, SubstsRef<'tcx>, ty::ParamEnv<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
-
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
}
@@ -631,11 +497,6 @@ impl<'tcx> Key for (DefId, Ty<'tcx>, SubstsRef<'tcx>, ty::ParamEnv<'tcx>) {
impl<'tcx> Key for (ty::Predicate<'tcx>, traits::WellFormedLoc) {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
-
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
}
@@ -644,11 +505,6 @@ impl<'tcx> Key for (ty::Predicate<'tcx>, traits::WellFormedLoc) {
impl<'tcx> Key for (ty::PolyFnSig<'tcx>, &'tcx ty::List<Ty<'tcx>>) {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
-
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
}
@@ -657,11 +513,6 @@ impl<'tcx> Key for (ty::PolyFnSig<'tcx>, &'tcx ty::List<Ty<'tcx>>) {
impl<'tcx> Key for (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>) {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
-
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.0.default_span(tcx)
}
@@ -670,11 +521,6 @@ impl<'tcx> Key for (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>) {
impl<'tcx> Key for (Ty<'tcx>, ty::ValTree<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
-
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
}
@@ -683,11 +529,6 @@ impl<'tcx> Key for (Ty<'tcx>, ty::ValTree<'tcx>) {
impl Key for HirId {
type CacheSelector = DefaultCacheSelector<Self>;
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
-
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.hir().span(*self)
}
@@ -702,10 +543,6 @@ impl<'tcx> Key for (ValidityRequirement, ty::ParamEnvAnd<'tcx, Ty<'tcx>>) {
type CacheSelector = DefaultCacheSelector<Self>;
// Just forward to `Ty<'tcx>`
- #[inline(always)]
- fn query_crate_is_local(&self) -> bool {
- true
- }
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs
index 5133da342..7a5a16035 100644
--- a/compiler/rustc_middle/src/query/mod.rs
+++ b/compiler/rustc_middle/src/query/mod.rs
@@ -7,8 +7,9 @@
use crate::ty::{self, print::describe_as_module, TyCtxt};
use rustc_span::def_id::LOCAL_CRATE;
+pub mod erase;
mod keys;
-pub use keys::Key;
+pub use keys::{AsLocalKey, Key, LocalCrate};
// Each of these queries corresponds to a function pointer field in the
// `Providers` struct for requesting a value of that type, and a method
@@ -26,6 +27,15 @@ rustc_queries! {
desc { "triggering a delay span bug" }
}
+ query registered_tools(_: ()) -> &'tcx ty::RegisteredTools {
+ arena_cache
+ desc { "compute registered tools for crate" }
+ }
+
+ query early_lint_checks(_: ()) -> () {
+ desc { "perform lints prior to macro expansion" }
+ }
+
query resolutions(_: ()) -> &'tcx ty::ResolverGlobalCtxt {
feedable
no_hash
@@ -87,7 +97,7 @@ rustc_queries! {
/// Gives access to the HIR ID for the given `LocalDefId` owner `key` if any.
///
- /// Definitions that were generated with no HIR, would be feeded to return `None`.
+ /// Definitions that were generated with no HIR, would be fed to return `None`.
query opt_local_def_id_to_hir_id(key: LocalDefId) -> Option<hir::HirId>{
desc { |tcx| "getting HIR ID of `{}`", tcx.def_path_str(key.to_def_id()) }
feedable
@@ -182,6 +192,7 @@ rustc_queries! {
{
desc { "determine whether the opaque is a type-alias impl trait" }
separate_provide_extern
+ feedable
}
query unsizing_params_for_adt(key: DefId) -> &'tcx rustc_index::bit_set::BitSet<u32>
@@ -616,20 +627,26 @@ rustc_queries! {
separate_provide_extern
}
+ query implied_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
+ desc { |tcx| "computing the implied predicates of `{}`", tcx.def_path_str(key) }
+ cache_on_disk_if { key.is_local() }
+ separate_provide_extern
+ }
+
/// 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`.
- query super_predicates_that_define_assoc_type(key: (DefId, Option<rustc_span::symbol::Ident>)) -> ty::GenericPredicates<'tcx> {
- desc { |tcx| "computing the super traits of `{}`{}",
+ query super_predicates_that_define_assoc_type(key: (DefId, rustc_span::symbol::Ident)) -> ty::GenericPredicates<'tcx> {
+ desc { |tcx| "computing the super traits of `{}` with associated type name `{}`",
tcx.def_path_str(key.0),
- if let Some(assoc_name) = key.1 { format!(" with associated type name `{}`", assoc_name) } else { "".to_string() },
+ key.1
}
}
/// To avoid cycles within the predicates of a single item we compute
/// per-type-parameter predicates for resolving `T::AssocTy`.
- query type_param_predicates(key: (DefId, LocalDefId, rustc_span::symbol::Ident)) -> ty::GenericPredicates<'tcx> {
+ query type_param_predicates(key: (LocalDefId, LocalDefId, rustc_span::symbol::Ident)) -> ty::GenericPredicates<'tcx> {
desc { |tcx| "computing the bounds for type parameter `{}`", tcx.hir().ty_param_name(key.1) }
}
@@ -764,7 +781,7 @@ rustc_queries! {
///
/// The map returned for `tcx.impl_item_implementor_ids(impl_id)` would be
///`{ trait_f: impl_f, trait_g: impl_g }`
- query impl_item_implementor_ids(impl_id: DefId) -> &'tcx FxHashMap<DefId, DefId> {
+ query impl_item_implementor_ids(impl_id: DefId) -> &'tcx DefIdMap<DefId> {
arena_cache
desc { |tcx| "comparing impl items against trait for `{}`", tcx.def_path_str(impl_id) }
}
@@ -775,7 +792,7 @@ rustc_queries! {
/// if `fn_def_id` is the def id of a function defined inside an impl that implements a trait, then it
/// creates and returns the associated items that correspond to each impl trait in return position
/// of the implemented trait.
- query associated_items_for_impl_trait_in_trait(fn_def_id: DefId) -> &'tcx [DefId] {
+ query associated_types_for_impl_traits_in_associated_fn(fn_def_id: DefId) -> &'tcx [DefId] {
desc { |tcx| "creating associated items for impl trait in trait returned by `{}`", tcx.def_path_str(fn_def_id) }
cache_on_disk_if { fn_def_id.is_local() }
separate_provide_extern
@@ -783,10 +800,9 @@ rustc_queries! {
/// Given an impl trait in trait `opaque_ty_def_id`, create and return the corresponding
/// associated item.
- query associated_item_for_impl_trait_in_trait(opaque_ty_def_id: LocalDefId) -> LocalDefId {
+ query associated_type_for_impl_trait_in_trait(opaque_ty_def_id: LocalDefId) -> LocalDefId {
desc { |tcx| "creates the associated item corresponding to the opaque type `{}`", tcx.def_path_str(opaque_ty_def_id.to_def_id()) }
cache_on_disk_if { true }
- separate_provide_extern
}
/// Given an `impl_id`, return the trait it implements.
@@ -906,8 +922,8 @@ rustc_queries! {
/// 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)
query live_symbols_and_ignored_derived_traits(_: ()) -> &'tcx (
- FxHashSet<LocalDefId>,
- FxHashMap<LocalDefId, Vec<(DefId, DefId)>>
+ LocalDefIdSet,
+ LocalDefIdMap<Vec<(DefId, DefId)>>
) {
arena_cache
desc { "finding live symbols in crate" }
@@ -1105,9 +1121,9 @@ rustc_queries! {
desc { "converting literal to mir constant" }
}
- query check_match(key: DefId) {
- desc { |tcx| "match-checking `{}`", tcx.def_path_str(key) }
- cache_on_disk_if { key.is_local() }
+ query check_match(key: LocalDefId) {
+ desc { |tcx| "match-checking `{}`", tcx.def_path_str(key.to_def_id()) }
+ cache_on_disk_if { true }
}
/// Performs part of the privacy check and computes effective visibilities.
@@ -1120,7 +1136,7 @@ rustc_queries! {
desc { "checking for private elements in public interfaces" }
}
- query reachable_set(_: ()) -> &'tcx FxHashSet<LocalDefId> {
+ query reachable_set(_: ()) -> &'tcx LocalDefIdSet {
arena_cache
desc { "reachability" }
}
@@ -1152,14 +1168,6 @@ rustc_queries! {
feedable
}
- /// The `opt_rpitit_info` query returns the pair of the def id of the function where the RPIT
- /// is defined and the opaque def id if any.
- query opt_rpitit_info(def_id: DefId) -> Option<ty::ImplTraitInTraitData> {
- desc { |tcx| "opt_rpitit_info `{}`", tcx.def_path_str(def_id) }
- cache_on_disk_if { def_id.is_local() }
- feedable
- }
-
/// Gets the span for the definition.
query def_span(def_id: DefId) -> Span {
desc { |tcx| "looking up span for `{}`", tcx.def_path_str(def_id) }
@@ -1229,7 +1237,7 @@ rustc_queries! {
separate_provide_extern
}
- query asm_target_features(def_id: DefId) -> &'tcx FxHashSet<Symbol> {
+ query asm_target_features(def_id: DefId) -> &'tcx FxIndexSet<Symbol> {
desc { |tcx| "computing target features for inline asm of `{}`", tcx.def_path_str(def_id) }
}
@@ -1324,6 +1332,7 @@ rustc_queries! {
/// might want to use `reveal_all()` method to change modes.
query param_env(def_id: DefId) -> ty::ParamEnv<'tcx> {
desc { |tcx| "computing normalized predicates of `{}`", tcx.def_path_str(def_id) }
+ feedable
}
/// Like `param_env`, but returns the `ParamEnv` in `Reveal::All` mode.
@@ -1507,10 +1516,6 @@ rustc_queries! {
desc { "getting traits in scope at a block" }
}
- query module_reexports(def_id: LocalDefId) -> Option<&'tcx [ModChild]> {
- desc { |tcx| "looking up reexports of module `{}`", tcx.def_path_str(def_id.to_def_id()) }
- }
-
query impl_defaultness(def_id: DefId) -> hir::Defaultness {
desc { |tcx| "looking up whether `{}` is a default impl", tcx.def_path_str(def_id) }
cache_on_disk_if { def_id.is_local() }
@@ -1845,7 +1850,7 @@ rustc_queries! {
query maybe_unused_trait_imports(_: ()) -> &'tcx FxIndexSet<LocalDefId> {
desc { "fetching potentially unused trait imports" }
}
- query names_imported_by_glob_use(def_id: LocalDefId) -> &'tcx FxHashSet<Symbol> {
+ query names_imported_by_glob_use(def_id: LocalDefId) -> &'tcx UnordSet<Symbol> {
desc { |tcx| "finding names imported by glob use for `{}`", tcx.def_path_str(def_id.to_def_id()) }
}
@@ -2114,7 +2119,7 @@ rustc_queries! {
desc { "raw operations for metadata file access" }
}
- query crate_for_resolver((): ()) -> &'tcx Steal<rustc_ast::ast::Crate> {
+ query crate_for_resolver((): ()) -> &'tcx Steal<(rustc_ast::Crate, rustc_ast::AttrVec)> {
feedable
no_hash
desc { "the ast before macro expansion and name resolution" }
@@ -2213,7 +2218,7 @@ rustc_queries! {
}
/// Used in `super_combine_consts` to ICE if the type of the two consts are definitely not going to end up being
- /// equal to eachother. This might return `Ok` even if the types are unequal, but will never return `Err` if
+ /// equal to eachother. This might return `Ok` even if the types are not equal, but will never return `Err` if
/// the types might be equal.
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"}