|
|
|
@@ -20,9 +20,8 @@
|
|
|
|
|
#[derive(Copy, Clone, Debug)]
|
|
|
|
|
pub struct LocalCrate;
|
|
|
|
|
|
|
|
|
|
/// The `Key` trait controls what types can legally be used as the key
|
|
|
|
|
/// for a query.
|
|
|
|
|
pub trait Key: Sized {
|
|
|
|
|
/// Controls what types can legally be used as the key for a query.
|
|
|
|
|
pub trait QueryKey: Sized {
|
|
|
|
|
/// The type of in-memory cache to use for queries with this key type.
|
|
|
|
|
///
|
|
|
|
|
/// In practice the cache type must implement [`QueryCache`], though that
|
|
|
|
@@ -47,15 +46,15 @@ fn def_id_for_ty_in_cycle(&self) -> Option<DefId> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub trait AsLocalKey: Key {
|
|
|
|
|
type LocalKey;
|
|
|
|
|
pub trait AsLocalQueryKey: QueryKey {
|
|
|
|
|
type LocalQueryKey;
|
|
|
|
|
|
|
|
|
|
/// 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>;
|
|
|
|
|
fn as_local_key(&self) -> Option<Self::LocalQueryKey>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Key for () {
|
|
|
|
|
impl QueryKey for () {
|
|
|
|
|
type Cache<V> = SingleCache<V>;
|
|
|
|
|
|
|
|
|
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
|
|
|
@@ -63,37 +62,37 @@ fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> Key for ty::InstanceKind<'tcx> {
|
|
|
|
|
impl<'tcx> QueryKey for ty::InstanceKind<'tcx> {
|
|
|
|
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
tcx.def_span(self.def_id())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> Key for ty::Instance<'tcx> {
|
|
|
|
|
impl<'tcx> QueryKey for ty::Instance<'tcx> {
|
|
|
|
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
tcx.def_span(self.def_id())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> Key for mir::interpret::GlobalId<'tcx> {
|
|
|
|
|
impl<'tcx> QueryKey for mir::interpret::GlobalId<'tcx> {
|
|
|
|
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
self.instance.default_span(tcx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> Key for (Ty<'tcx>, Option<ty::ExistentialTraitRef<'tcx>>) {
|
|
|
|
|
impl<'tcx> QueryKey for (Ty<'tcx>, Option<ty::ExistentialTraitRef<'tcx>>) {
|
|
|
|
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
|
|
|
|
DUMMY_SP
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> Key for ty::LitToConstInput<'tcx> {
|
|
|
|
|
impl<'tcx> QueryKey for ty::LitToConstInput<'tcx> {
|
|
|
|
|
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
DUMMY_SP
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Key for CrateNum {
|
|
|
|
|
impl QueryKey for CrateNum {
|
|
|
|
|
type Cache<V> = VecCache<Self, V, DepNodeIndex>;
|
|
|
|
|
|
|
|
|
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
|
|
|
@@ -101,16 +100,16 @@ fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl AsLocalKey for CrateNum {
|
|
|
|
|
type LocalKey = LocalCrate;
|
|
|
|
|
impl AsLocalQueryKey for CrateNum {
|
|
|
|
|
type LocalQueryKey = LocalCrate;
|
|
|
|
|
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
|
|
|
|
fn as_local_key(&self) -> Option<Self::LocalQueryKey> {
|
|
|
|
|
(*self == LOCAL_CRATE).then_some(LocalCrate)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Key for OwnerId {
|
|
|
|
|
impl QueryKey for OwnerId {
|
|
|
|
|
type Cache<V> = VecCache<Self, V, DepNodeIndex>;
|
|
|
|
|
|
|
|
|
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
|
|
|
@@ -122,7 +121,7 @@ fn key_as_def_id(&self) -> Option<DefId> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Key for LocalDefId {
|
|
|
|
|
impl QueryKey for LocalDefId {
|
|
|
|
|
type Cache<V> = VecCache<Self, V, DepNodeIndex>;
|
|
|
|
|
|
|
|
|
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
|
|
|
@@ -134,7 +133,7 @@ fn key_as_def_id(&self) -> Option<DefId> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Key for DefId {
|
|
|
|
|
impl QueryKey for DefId {
|
|
|
|
|
type Cache<V> = DefIdCache<V>;
|
|
|
|
|
|
|
|
|
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
|
|
|
@@ -147,16 +146,16 @@ fn key_as_def_id(&self) -> Option<DefId> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl AsLocalKey for DefId {
|
|
|
|
|
type LocalKey = LocalDefId;
|
|
|
|
|
impl AsLocalQueryKey for DefId {
|
|
|
|
|
type LocalQueryKey = LocalDefId;
|
|
|
|
|
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
|
|
|
|
fn as_local_key(&self) -> Option<Self::LocalQueryKey> {
|
|
|
|
|
self.as_local()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Key for LocalModDefId {
|
|
|
|
|
impl QueryKey for LocalModDefId {
|
|
|
|
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
tcx.def_span(*self)
|
|
|
|
|
}
|
|
|
|
@@ -167,19 +166,19 @@ fn key_as_def_id(&self) -> Option<DefId> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Key for SimplifiedType {
|
|
|
|
|
impl QueryKey for SimplifiedType {
|
|
|
|
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
|
|
|
|
DUMMY_SP
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Key for (DefId, DefId) {
|
|
|
|
|
impl QueryKey for (DefId, DefId) {
|
|
|
|
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
self.1.default_span(tcx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Key for (DefId, Ident) {
|
|
|
|
|
impl QueryKey for (DefId, Ident) {
|
|
|
|
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
tcx.def_span(self.0)
|
|
|
|
|
}
|
|
|
|
@@ -190,73 +189,73 @@ fn key_as_def_id(&self) -> Option<DefId> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Key for (LocalDefId, LocalDefId, Ident) {
|
|
|
|
|
impl QueryKey for (LocalDefId, LocalDefId, Ident) {
|
|
|
|
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
self.1.default_span(tcx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Key for (CrateNum, DefId) {
|
|
|
|
|
impl QueryKey for (CrateNum, DefId) {
|
|
|
|
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
self.1.default_span(tcx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl AsLocalKey for (CrateNum, DefId) {
|
|
|
|
|
type LocalKey = DefId;
|
|
|
|
|
impl AsLocalQueryKey for (CrateNum, DefId) {
|
|
|
|
|
type LocalQueryKey = DefId;
|
|
|
|
|
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
|
|
|
|
fn as_local_key(&self) -> Option<Self::LocalQueryKey> {
|
|
|
|
|
(self.0 == LOCAL_CRATE).then(|| self.1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Key for (CrateNum, SimplifiedType) {
|
|
|
|
|
impl QueryKey for (CrateNum, SimplifiedType) {
|
|
|
|
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
|
|
|
|
DUMMY_SP
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl AsLocalKey for (CrateNum, SimplifiedType) {
|
|
|
|
|
type LocalKey = SimplifiedType;
|
|
|
|
|
impl AsLocalQueryKey for (CrateNum, SimplifiedType) {
|
|
|
|
|
type LocalQueryKey = SimplifiedType;
|
|
|
|
|
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
|
|
|
|
fn as_local_key(&self) -> Option<Self::LocalQueryKey> {
|
|
|
|
|
(self.0 == LOCAL_CRATE).then(|| self.1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Key for (DefId, ty::SizedTraitKind) {
|
|
|
|
|
impl QueryKey for (DefId, ty::SizedTraitKind) {
|
|
|
|
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
self.0.default_span(tcx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> Key for GenericArgsRef<'tcx> {
|
|
|
|
|
impl<'tcx> QueryKey for GenericArgsRef<'tcx> {
|
|
|
|
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
|
|
|
|
DUMMY_SP
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> Key for (DefId, GenericArgsRef<'tcx>) {
|
|
|
|
|
impl<'tcx> QueryKey for (DefId, GenericArgsRef<'tcx>) {
|
|
|
|
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
self.0.default_span(tcx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> Key for ty::TraitRef<'tcx> {
|
|
|
|
|
impl<'tcx> QueryKey for ty::TraitRef<'tcx> {
|
|
|
|
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
tcx.def_span(self.def_id)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> Key for GenericArg<'tcx> {
|
|
|
|
|
impl<'tcx> QueryKey for GenericArg<'tcx> {
|
|
|
|
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
|
|
|
|
DUMMY_SP
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> Key for Ty<'tcx> {
|
|
|
|
|
impl<'tcx> QueryKey for Ty<'tcx> {
|
|
|
|
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
|
|
|
|
DUMMY_SP
|
|
|
|
|
}
|
|
|
|
@@ -270,19 +269,19 @@ fn def_id_for_ty_in_cycle(&self) -> Option<DefId> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> Key for (Ty<'tcx>, Ty<'tcx>) {
|
|
|
|
|
impl<'tcx> QueryKey for (Ty<'tcx>, Ty<'tcx>) {
|
|
|
|
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
|
|
|
|
DUMMY_SP
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> Key for ty::Clauses<'tcx> {
|
|
|
|
|
impl<'tcx> QueryKey for ty::Clauses<'tcx> {
|
|
|
|
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
|
|
|
|
DUMMY_SP
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx, T: Key> Key for ty::PseudoCanonicalInput<'tcx, T> {
|
|
|
|
|
impl<'tcx, T: QueryKey> QueryKey for ty::PseudoCanonicalInput<'tcx, T> {
|
|
|
|
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
self.value.default_span(tcx)
|
|
|
|
|
}
|
|
|
|
@@ -292,19 +291,19 @@ fn def_id_for_ty_in_cycle(&self) -> Option<DefId> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Key for Symbol {
|
|
|
|
|
impl QueryKey for Symbol {
|
|
|
|
|
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
DUMMY_SP
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Key for Option<Symbol> {
|
|
|
|
|
impl QueryKey for Option<Symbol> {
|
|
|
|
|
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
DUMMY_SP
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> Key for &'tcx OsStr {
|
|
|
|
|
impl<'tcx> QueryKey for &'tcx OsStr {
|
|
|
|
|
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
DUMMY_SP
|
|
|
|
|
}
|
|
|
|
@@ -312,55 +311,55 @@ fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
|
|
|
|
|
/// Canonical query goals correspond to abstract trait operations that
|
|
|
|
|
/// are not tied to any crate in particular.
|
|
|
|
|
impl<'tcx, T: Clone> Key for CanonicalQueryInput<'tcx, T> {
|
|
|
|
|
impl<'tcx, T: Clone> QueryKey for CanonicalQueryInput<'tcx, T> {
|
|
|
|
|
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
DUMMY_SP
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx, T: Clone> Key for (CanonicalQueryInput<'tcx, T>, bool) {
|
|
|
|
|
impl<'tcx, T: Clone> QueryKey for (CanonicalQueryInput<'tcx, T>, bool) {
|
|
|
|
|
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
DUMMY_SP
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> Key for (Ty<'tcx>, rustc_abi::VariantIdx) {
|
|
|
|
|
impl<'tcx> QueryKey for (Ty<'tcx>, rustc_abi::VariantIdx) {
|
|
|
|
|
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
DUMMY_SP
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> Key for (ty::Predicate<'tcx>, traits::WellFormedLoc) {
|
|
|
|
|
impl<'tcx> QueryKey for (ty::Predicate<'tcx>, traits::WellFormedLoc) {
|
|
|
|
|
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
DUMMY_SP
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> Key for (ty::PolyFnSig<'tcx>, &'tcx ty::List<Ty<'tcx>>) {
|
|
|
|
|
impl<'tcx> QueryKey for (ty::PolyFnSig<'tcx>, &'tcx ty::List<Ty<'tcx>>) {
|
|
|
|
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
|
|
|
|
DUMMY_SP
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> Key for (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>) {
|
|
|
|
|
impl<'tcx> QueryKey for (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>) {
|
|
|
|
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
self.0.default_span(tcx)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> Key for ty::Value<'tcx> {
|
|
|
|
|
impl<'tcx> QueryKey for ty::Value<'tcx> {
|
|
|
|
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
|
|
|
|
DUMMY_SP
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> Key for (LocalExpnId, &'tcx TokenStream) {
|
|
|
|
|
impl<'tcx> QueryKey for (LocalExpnId, &'tcx TokenStream) {
|
|
|
|
|
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
self.0.expn_data().call_site
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> Key for (ValidityRequirement, ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>) {
|
|
|
|
|
impl<'tcx> QueryKey for (ValidityRequirement, ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>) {
|
|
|
|
|
// Just forward to `Ty<'tcx>`
|
|
|
|
|
|
|
|
|
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
|
|
|
@@ -375,7 +374,7 @@ fn def_id_for_ty_in_cycle(&self) -> Option<DefId> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'tcx> Key for (ty::Instance<'tcx>, CollectionMode) {
|
|
|
|
|
impl<'tcx> QueryKey for (ty::Instance<'tcx>, CollectionMode) {
|
|
|
|
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
|
|
|
|
self.0.default_span(tcx)
|
|
|
|
|
}
|
|
|
|
|