Note that type aliases cannot be recursive
This commit is contained in:
@@ -20,6 +20,12 @@ pub trait Key {
|
||||
/// 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;
|
||||
|
||||
/// If the key is a [`DefId`] or `DefId`--equivalent, return that `DefId`.
|
||||
/// Otherwise, return `None`.
|
||||
fn key_as_def_id(&self) -> Option<DefId> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl Key for () {
|
||||
@@ -95,6 +101,9 @@ impl Key for LocalDefId {
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
||||
impl Key for DefId {
|
||||
@@ -105,6 +114,10 @@ impl Key for DefId {
|
||||
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> {
|
||||
|
||||
Reference in New Issue
Block a user