AsLocalKey trait
This commit is contained in:
parent
7e6506764b
commit
dcaf956de0
@ -26,12 +26,6 @@ pub trait Key: Sized {
|
|||||||
// r-a issue: <https://github.com/rust-lang/rust-analyzer/issues/13693>
|
// r-a issue: <https://github.com/rust-lang/rust-analyzer/issues/13693>
|
||||||
type CacheSelector;
|
type CacheSelector;
|
||||||
|
|
||||||
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>;
|
|
||||||
|
|
||||||
/// In the event that a cycle occurs, if no explicit span has been
|
/// 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?
|
/// given for a query with key `self`, what span should we use?
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span;
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span;
|
||||||
@ -47,14 +41,16 @@ 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 () {
|
impl Key for () {
|
||||||
type CacheSelector = SingleCacheSelector;
|
type CacheSelector = SingleCacheSelector;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -63,26 +59,23 @@ impl Key for () {
|
|||||||
|
|
||||||
impl<'tcx> Key for ty::InstanceDef<'tcx> {
|
impl<'tcx> Key for ty::InstanceDef<'tcx> {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
self.def_id().is_local().then(|| *self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
tcx.def_span(self.def_id())
|
tcx.def_span(self.def_id())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Key for ty::Instance<'tcx> {
|
impl<'tcx> AsLocalKey for ty::InstanceDef<'tcx> {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
|
||||||
type LocalKey = Self;
|
type LocalKey = Self;
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
||||||
self.def_id().is_local().then(|| *self)
|
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 {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
tcx.def_span(self.def_id())
|
tcx.def_span(self.def_id())
|
||||||
@ -91,12 +84,6 @@ impl<'tcx> Key for ty::Instance<'tcx> {
|
|||||||
|
|
||||||
impl<'tcx> Key for mir::interpret::GlobalId<'tcx> {
|
impl<'tcx> Key for mir::interpret::GlobalId<'tcx> {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
self.instance.default_span(tcx)
|
self.instance.default_span(tcx)
|
||||||
@ -105,12 +92,6 @@ impl<'tcx> Key for mir::interpret::GlobalId<'tcx> {
|
|||||||
|
|
||||||
impl<'tcx> Key for (Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>) {
|
impl<'tcx> Key for (Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -119,12 +100,6 @@ impl<'tcx> Key for (Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>) {
|
|||||||
|
|
||||||
impl<'tcx> Key for mir::interpret::LitToConstInput<'tcx> {
|
impl<'tcx> Key for mir::interpret::LitToConstInput<'tcx> {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -133,26 +108,23 @@ impl<'tcx> Key for mir::interpret::LitToConstInput<'tcx> {
|
|||||||
|
|
||||||
impl Key for CrateNum {
|
impl Key for CrateNum {
|
||||||
type CacheSelector = VecCacheSelector<Self>;
|
type CacheSelector = VecCacheSelector<Self>;
|
||||||
type LocalKey = ();
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
|
||||||
(*self == LOCAL_CRATE).then_some(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Key for OwnerId {
|
impl AsLocalKey for CrateNum {
|
||||||
type CacheSelector = VecCacheSelector<Self>;
|
type LocalKey = ();
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
||||||
Some(*self)
|
(*self == LOCAL_CRATE).then_some(())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Key for OwnerId {
|
||||||
|
type CacheSelector = VecCacheSelector<Self>;
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
self.to_def_id().default_span(tcx)
|
self.to_def_id().default_span(tcx)
|
||||||
@ -165,12 +137,6 @@ impl Key for OwnerId {
|
|||||||
|
|
||||||
impl Key for LocalDefId {
|
impl Key for LocalDefId {
|
||||||
type CacheSelector = VecCacheSelector<Self>;
|
type CacheSelector = VecCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
self.to_def_id().default_span(tcx)
|
self.to_def_id().default_span(tcx)
|
||||||
@ -183,12 +149,6 @@ impl Key for LocalDefId {
|
|||||||
|
|
||||||
impl Key for DefId {
|
impl Key for DefId {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = LocalDefId;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
|
||||||
self.as_local()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
tcx.def_span(*self)
|
tcx.def_span(*self)
|
||||||
@ -200,14 +160,17 @@ impl Key for DefId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Key for ty::WithOptConstParam<LocalDefId> {
|
impl AsLocalKey for DefId {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type LocalKey = LocalDefId;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
||||||
Some(*self)
|
self.as_local()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Key for ty::WithOptConstParam<LocalDefId> {
|
||||||
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
self.did.default_span(tcx)
|
self.did.default_span(tcx)
|
||||||
@ -216,12 +179,6 @@ impl Key for ty::WithOptConstParam<LocalDefId> {
|
|||||||
|
|
||||||
impl Key for SimplifiedType {
|
impl Key for SimplifiedType {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -230,12 +187,6 @@ impl Key for SimplifiedType {
|
|||||||
|
|
||||||
impl Key for (DefId, DefId) {
|
impl Key for (DefId, DefId) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = (LocalDefId, DefId);
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
|
||||||
Some((self.0.as_local()?, self.1))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
self.1.default_span(tcx)
|
self.1.default_span(tcx)
|
||||||
@ -244,12 +195,6 @@ impl Key for (DefId, DefId) {
|
|||||||
|
|
||||||
impl<'tcx> Key for (ty::Instance<'tcx>, LocalDefId) {
|
impl<'tcx> Key for (ty::Instance<'tcx>, LocalDefId) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
self.0.default_span(tcx)
|
self.0.default_span(tcx)
|
||||||
@ -258,12 +203,6 @@ impl<'tcx> Key for (ty::Instance<'tcx>, LocalDefId) {
|
|||||||
|
|
||||||
impl Key for (DefId, LocalDefId) {
|
impl Key for (DefId, LocalDefId) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = (LocalDefId, LocalDefId);
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
|
||||||
Some((self.0.as_local()?, self.1))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
self.1.default_span(tcx)
|
self.1.default_span(tcx)
|
||||||
@ -272,12 +211,6 @@ impl Key for (DefId, LocalDefId) {
|
|||||||
|
|
||||||
impl Key for (LocalDefId, DefId) {
|
impl Key for (LocalDefId, DefId) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
self.0.default_span(tcx)
|
self.0.default_span(tcx)
|
||||||
@ -286,12 +219,6 @@ impl Key for (LocalDefId, DefId) {
|
|||||||
|
|
||||||
impl Key for (LocalDefId, LocalDefId) {
|
impl Key for (LocalDefId, LocalDefId) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
self.0.default_span(tcx)
|
self.0.default_span(tcx)
|
||||||
@ -300,11 +227,6 @@ impl Key for (LocalDefId, LocalDefId) {
|
|||||||
|
|
||||||
impl Key for (DefId, Option<Ident>) {
|
impl Key for (DefId, Option<Ident>) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = (LocalDefId, Option<Ident>);
|
|
||||||
|
|
||||||
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
|
||||||
Some((self.0.as_local()?, self.1))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
tcx.def_span(self.0)
|
tcx.def_span(self.0)
|
||||||
@ -318,11 +240,6 @@ impl Key for (DefId, Option<Ident>) {
|
|||||||
|
|
||||||
impl Key for (LocalDefId, LocalDefId, Ident) {
|
impl Key for (LocalDefId, LocalDefId, Ident) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
self.1.default_span(tcx)
|
self.1.default_span(tcx)
|
||||||
@ -331,40 +248,40 @@ impl Key for (LocalDefId, LocalDefId, Ident) {
|
|||||||
|
|
||||||
impl Key for (CrateNum, DefId) {
|
impl Key for (CrateNum, DefId) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = DefId;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
|
||||||
(self.0 == LOCAL_CRATE).then_some(self.1)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
self.1.default_span(tcx)
|
self.1.default_span(tcx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Key for (CrateNum, SimplifiedType) {
|
impl AsLocalKey for (CrateNum, DefId) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type LocalKey = DefId;
|
||||||
type LocalKey = SimplifiedType;
|
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
||||||
(self.0 == LOCAL_CRATE).then_some(self.1)
|
(self.0 == LOCAL_CRATE).then(|| self.1)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Key for (CrateNum, SimplifiedType) {
|
||||||
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
|
|
||||||
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Key for (DefId, SimplifiedType) {
|
impl AsLocalKey for (CrateNum, SimplifiedType) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type LocalKey = SimplifiedType;
|
||||||
type LocalKey = (LocalDefId, SimplifiedType);
|
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
||||||
Some((self.0.as_local()?, self.1))
|
(self.0 == LOCAL_CRATE).then(|| self.1)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Key for (DefId, SimplifiedType) {
|
||||||
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
self.0.default_span(tcx)
|
self.0.default_span(tcx)
|
||||||
@ -373,12 +290,6 @@ impl Key for (DefId, SimplifiedType) {
|
|||||||
|
|
||||||
impl<'tcx> Key for SubstsRef<'tcx> {
|
impl<'tcx> Key for SubstsRef<'tcx> {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -387,12 +298,6 @@ impl<'tcx> Key for SubstsRef<'tcx> {
|
|||||||
|
|
||||||
impl<'tcx> Key for (DefId, SubstsRef<'tcx>) {
|
impl<'tcx> Key for (DefId, SubstsRef<'tcx>) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = (LocalDefId, SubstsRef<'tcx>);
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
|
||||||
Some((self.0.as_local()?, self.1))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
self.0.default_span(tcx)
|
self.0.default_span(tcx)
|
||||||
@ -401,12 +306,6 @@ impl<'tcx> Key for (DefId, SubstsRef<'tcx>) {
|
|||||||
|
|
||||||
impl<'tcx> Key for (ty::UnevaluatedConst<'tcx>, ty::UnevaluatedConst<'tcx>) {
|
impl<'tcx> Key for (ty::UnevaluatedConst<'tcx>, ty::UnevaluatedConst<'tcx>) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
|
||||||
self.0.def.is_local().then_some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
(self.0).def.did.default_span(tcx)
|
(self.0).def.did.default_span(tcx)
|
||||||
@ -415,12 +314,6 @@ impl<'tcx> Key for (ty::UnevaluatedConst<'tcx>, ty::UnevaluatedConst<'tcx>) {
|
|||||||
|
|
||||||
impl<'tcx> Key for (LocalDefId, DefId, SubstsRef<'tcx>) {
|
impl<'tcx> Key for (LocalDefId, DefId, SubstsRef<'tcx>) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
self.0.default_span(tcx)
|
self.0.default_span(tcx)
|
||||||
@ -429,12 +322,6 @@ impl<'tcx> Key for (LocalDefId, DefId, SubstsRef<'tcx>) {
|
|||||||
|
|
||||||
impl<'tcx> Key for (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>) {
|
impl<'tcx> Key for (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
|
||||||
self.1.def_id().is_local().then_some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
tcx.def_span(self.1.def_id())
|
tcx.def_span(self.1.def_id())
|
||||||
@ -443,12 +330,6 @@ impl<'tcx> Key for (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>) {
|
|||||||
|
|
||||||
impl<'tcx> Key for (ty::Const<'tcx>, mir::Field) {
|
impl<'tcx> Key for (ty::Const<'tcx>, mir::Field) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -457,12 +338,6 @@ impl<'tcx> Key for (ty::Const<'tcx>, mir::Field) {
|
|||||||
|
|
||||||
impl<'tcx> Key for mir::interpret::ConstAlloc<'tcx> {
|
impl<'tcx> Key for mir::interpret::ConstAlloc<'tcx> {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -471,12 +346,6 @@ impl<'tcx> Key for mir::interpret::ConstAlloc<'tcx> {
|
|||||||
|
|
||||||
impl<'tcx> Key for ty::PolyTraitRef<'tcx> {
|
impl<'tcx> Key for ty::PolyTraitRef<'tcx> {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
|
||||||
self.def_id().is_local().then_some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
tcx.def_span(self.def_id())
|
tcx.def_span(self.def_id())
|
||||||
@ -485,12 +354,6 @@ impl<'tcx> Key for ty::PolyTraitRef<'tcx> {
|
|||||||
|
|
||||||
impl<'tcx> Key for ty::PolyExistentialTraitRef<'tcx> {
|
impl<'tcx> Key for ty::PolyExistentialTraitRef<'tcx> {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
|
||||||
self.def_id().is_local().then_some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
tcx.def_span(self.def_id())
|
tcx.def_span(self.def_id())
|
||||||
@ -499,12 +362,6 @@ impl<'tcx> Key for ty::PolyExistentialTraitRef<'tcx> {
|
|||||||
|
|
||||||
impl<'tcx> Key for (ty::PolyTraitRef<'tcx>, ty::PolyTraitRef<'tcx>) {
|
impl<'tcx> Key for (ty::PolyTraitRef<'tcx>, ty::PolyTraitRef<'tcx>) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
|
||||||
self.0.def_id().is_local().then_some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
tcx.def_span(self.0.def_id())
|
tcx.def_span(self.0.def_id())
|
||||||
@ -513,12 +370,6 @@ impl<'tcx> Key for (ty::PolyTraitRef<'tcx>, ty::PolyTraitRef<'tcx>) {
|
|||||||
|
|
||||||
impl<'tcx> Key for GenericArg<'tcx> {
|
impl<'tcx> Key for GenericArg<'tcx> {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -527,12 +378,6 @@ impl<'tcx> Key for GenericArg<'tcx> {
|
|||||||
|
|
||||||
impl<'tcx> Key for mir::ConstantKind<'tcx> {
|
impl<'tcx> Key for mir::ConstantKind<'tcx> {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -541,12 +386,6 @@ impl<'tcx> Key for mir::ConstantKind<'tcx> {
|
|||||||
|
|
||||||
impl<'tcx> Key for ty::Const<'tcx> {
|
impl<'tcx> Key for ty::Const<'tcx> {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -555,12 +394,6 @@ impl<'tcx> Key for ty::Const<'tcx> {
|
|||||||
|
|
||||||
impl<'tcx> Key for Ty<'tcx> {
|
impl<'tcx> Key for Ty<'tcx> {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -576,12 +409,6 @@ impl<'tcx> Key for Ty<'tcx> {
|
|||||||
|
|
||||||
impl<'tcx> Key for TyAndLayout<'tcx> {
|
impl<'tcx> Key for TyAndLayout<'tcx> {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -590,12 +417,6 @@ impl<'tcx> Key for TyAndLayout<'tcx> {
|
|||||||
|
|
||||||
impl<'tcx> Key for (Ty<'tcx>, Ty<'tcx>) {
|
impl<'tcx> Key for (Ty<'tcx>, Ty<'tcx>) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -604,12 +425,6 @@ impl<'tcx> Key for (Ty<'tcx>, Ty<'tcx>) {
|
|||||||
|
|
||||||
impl<'tcx> Key for &'tcx ty::List<ty::Predicate<'tcx>> {
|
impl<'tcx> Key for &'tcx ty::List<ty::Predicate<'tcx>> {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -618,12 +433,6 @@ impl<'tcx> Key for &'tcx ty::List<ty::Predicate<'tcx>> {
|
|||||||
|
|
||||||
impl<'tcx> Key for ty::ParamEnv<'tcx> {
|
impl<'tcx> Key for ty::ParamEnv<'tcx> {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -632,11 +441,6 @@ impl<'tcx> Key for ty::ParamEnv<'tcx> {
|
|||||||
|
|
||||||
impl<'tcx, T: Key> Key for ty::ParamEnvAnd<'tcx, T> {
|
impl<'tcx, T: Key> Key for ty::ParamEnvAnd<'tcx, T> {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = ty::ParamEnvAnd<'tcx, T::LocalKey>;
|
|
||||||
|
|
||||||
fn as_local_key(&self) -> Option<Self::LocalKey> {
|
|
||||||
self.value.as_local_key().map(|value| ty::ParamEnvAnd { param_env: self.param_env, value })
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
self.value.default_span(tcx)
|
self.value.default_span(tcx)
|
||||||
@ -645,12 +449,6 @@ impl<'tcx, T: Key> Key for ty::ParamEnvAnd<'tcx, T> {
|
|||||||
|
|
||||||
impl Key for Symbol {
|
impl Key for Symbol {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -659,12 +457,6 @@ impl Key for Symbol {
|
|||||||
|
|
||||||
impl Key for Option<Symbol> {
|
impl Key for Option<Symbol> {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -675,12 +467,6 @@ impl Key for Option<Symbol> {
|
|||||||
/// are not tied to any crate in particular.
|
/// are not tied to any crate in particular.
|
||||||
impl<'tcx, T: Clone> Key for Canonical<'tcx, T> {
|
impl<'tcx, T: Clone> Key for Canonical<'tcx, T> {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(self.clone())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -689,12 +475,6 @@ impl<'tcx, T: Clone> Key for Canonical<'tcx, T> {
|
|||||||
|
|
||||||
impl Key for (Symbol, u32, u32) {
|
impl Key for (Symbol, u32, u32) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -703,12 +483,6 @@ impl Key for (Symbol, u32, u32) {
|
|||||||
|
|
||||||
impl<'tcx> Key for (DefId, Ty<'tcx>, SubstsRef<'tcx>, ty::ParamEnv<'tcx>) {
|
impl<'tcx> Key for (DefId, Ty<'tcx>, SubstsRef<'tcx>, ty::ParamEnv<'tcx>) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -717,12 +491,6 @@ impl<'tcx> Key for (DefId, Ty<'tcx>, SubstsRef<'tcx>, ty::ParamEnv<'tcx>) {
|
|||||||
|
|
||||||
impl<'tcx> Key for (ty::Predicate<'tcx>, traits::WellFormedLoc) {
|
impl<'tcx> Key for (ty::Predicate<'tcx>, traits::WellFormedLoc) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -731,12 +499,6 @@ impl<'tcx> Key for (ty::Predicate<'tcx>, traits::WellFormedLoc) {
|
|||||||
|
|
||||||
impl<'tcx> Key for (ty::PolyFnSig<'tcx>, &'tcx ty::List<Ty<'tcx>>) {
|
impl<'tcx> Key for (ty::PolyFnSig<'tcx>, &'tcx ty::List<Ty<'tcx>>) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -745,12 +507,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>>) {
|
impl<'tcx> Key for (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
self.0.default_span(tcx)
|
self.0.default_span(tcx)
|
||||||
@ -759,12 +515,6 @@ impl<'tcx> Key for (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>) {
|
|||||||
|
|
||||||
impl<'tcx> Key for (Ty<'tcx>, ty::ValTree<'tcx>) {
|
impl<'tcx> Key for (Ty<'tcx>, ty::ValTree<'tcx>) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
@ -773,12 +523,6 @@ impl<'tcx> Key for (Ty<'tcx>, ty::ValTree<'tcx>) {
|
|||||||
|
|
||||||
impl Key for HirId {
|
impl Key for HirId {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||||
tcx.hir().span(*self)
|
tcx.hir().span(*self)
|
||||||
@ -792,13 +536,8 @@ impl Key for HirId {
|
|||||||
|
|
||||||
impl<'tcx> Key for (ValidityRequirement, ty::ParamEnvAnd<'tcx, Ty<'tcx>>) {
|
impl<'tcx> Key for (ValidityRequirement, ty::ParamEnvAnd<'tcx, Ty<'tcx>>) {
|
||||||
type CacheSelector = DefaultCacheSelector<Self>;
|
type CacheSelector = DefaultCacheSelector<Self>;
|
||||||
type LocalKey = Self;
|
|
||||||
|
|
||||||
// Just forward to `Ty<'tcx>`
|
// Just forward to `Ty<'tcx>`
|
||||||
#[inline(always)]
|
|
||||||
fn as_local_key(&self) -> Option<Self> {
|
|
||||||
Some(*self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
fn default_span(&self, _: TyCtxt<'_>) -> Span {
|
||||||
DUMMY_SP
|
DUMMY_SP
|
||||||
|
@ -8,7 +8,7 @@ use crate::ty::{self, print::describe_as_module, TyCtxt};
|
|||||||
use rustc_span::def_id::LOCAL_CRATE;
|
use rustc_span::def_id::LOCAL_CRATE;
|
||||||
|
|
||||||
mod keys;
|
mod keys;
|
||||||
pub use keys::Key;
|
pub use keys::{AsLocalKey, Key};
|
||||||
|
|
||||||
// Each of these queries corresponds to a function pointer field in the
|
// Each of these queries corresponds to a function pointer field in the
|
||||||
// `Providers` struct for requesting a value of that type, and a method
|
// `Providers` struct for requesting a value of that type, and a method
|
||||||
@ -796,7 +796,6 @@ rustc_queries! {
|
|||||||
query associated_type_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()) }
|
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 }
|
cache_on_disk_if { true }
|
||||||
separate_provide_extern
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given an `impl_id`, return the trait it implements.
|
/// Given an `impl_id`, return the trait it implements.
|
||||||
|
@ -17,7 +17,7 @@ use crate::mir::interpret::{
|
|||||||
};
|
};
|
||||||
use crate::mir::interpret::{LitToConstError, LitToConstInput};
|
use crate::mir::interpret::{LitToConstError, LitToConstInput};
|
||||||
use crate::mir::mono::CodegenUnit;
|
use crate::mir::mono::CodegenUnit;
|
||||||
use crate::query::Key;
|
use crate::query::{AsLocalKey, Key};
|
||||||
use crate::thir;
|
use crate::thir;
|
||||||
use crate::traits::query::{
|
use crate::traits::query::{
|
||||||
CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal,
|
CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal,
|
||||||
@ -233,7 +233,7 @@ macro_rules! define_callbacks {
|
|||||||
pub mod query_keys_local {
|
pub mod query_keys_local {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
$(pub type $name<'tcx> = <$($K)* as Key>::LocalKey;)*
|
$(pub type $name<'tcx> = <$($K)* as AsLocalKey>::LocalKey;)*
|
||||||
}
|
}
|
||||||
#[allow(nonstandard_style, unused_lifetimes)]
|
#[allow(nonstandard_style, unused_lifetimes)]
|
||||||
pub mod query_values {
|
pub mod query_values {
|
||||||
@ -416,17 +416,14 @@ macro_rules! define_callbacks {
|
|||||||
|
|
||||||
impl Default for Providers {
|
impl Default for Providers {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
use crate::query::Key;
|
|
||||||
|
|
||||||
Providers {
|
Providers {
|
||||||
$($name: |_, key| bug!(
|
$($name: |_, key| bug!(
|
||||||
"`tcx.{}({:?})` is not supported for {} crate;\n\
|
"`tcx.{}({:?})` is not supported for this key;\n\
|
||||||
hint: Queries can be either made to the local crate, or the external crate. \
|
hint: Queries can be either made to the local crate, or the external crate. \
|
||||||
This error means you tried to use it for one that's not supported.\n\
|
This error means you tried to use it for one that's not supported.\n\
|
||||||
If that's not the case, {} was likely never assigned to a provider function.\n",
|
If that's not the case, {} was likely never assigned to a provider function.\n",
|
||||||
stringify!($name),
|
stringify!($name),
|
||||||
key,
|
key,
|
||||||
if key.as_local_key().is_some() { "local" } else { "external" },
|
|
||||||
stringify!($name),
|
stringify!($name),
|
||||||
),)*
|
),)*
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ extern crate rustc_middle;
|
|||||||
use rustc_data_structures::sync::AtomicU64;
|
use rustc_data_structures::sync::AtomicU64;
|
||||||
use rustc_middle::arena::Arena;
|
use rustc_middle::arena::Arena;
|
||||||
use rustc_middle::dep_graph::{self, DepKindStruct};
|
use rustc_middle::dep_graph::{self, DepKindStruct};
|
||||||
use rustc_middle::query::Key;
|
use rustc_middle::query::AsLocalKey;
|
||||||
use rustc_middle::ty::query::{
|
use rustc_middle::ty::query::{
|
||||||
query_keys, query_provided, query_provided_to_value, query_storage, query_values,
|
query_keys, query_provided, query_provided_to_value, query_storage, query_values,
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user