1
Fork 0

Allow to self reference associated types in where clauses

This commit is contained in:
Santiago Pastorino 2020-11-13 14:01:16 -03:00
parent 24dcf6f7a2
commit 2ca4964db5
No known key found for this signature in database
GPG key ID: 8131A24E0C79EFAF
8 changed files with 205 additions and 64 deletions

View file

@ -436,6 +436,16 @@ rustc_queries! {
desc { |tcx| "computing the supertraits of `{}`", tcx.def_path_str(key) }
}
/// Maps from the `DefId` of a trait to the list of
/// super-predicates. This is a subset of the full list of
/// predicates. We store these in a separate map because we must
/// evaluate them even during type conversion, often before the
/// full predicates are available (note that supertraits have
/// additional acyclicity requirements).
query super_predicates_that_define_assoc_type(key: (DefId, Option<rustc_span::symbol::Ident>)) -> ty::GenericPredicates<'tcx> {
desc { |tcx| "computing the supertraits of `{}`", tcx.def_path_str(key.0) }
}
/// 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> {

View file

@ -149,6 +149,17 @@ impl Key for (LocalDefId, DefId) {
}
}
impl Key for (DefId, Option<Ident>) {
type CacheSelector = DefaultCacheSelector;
fn query_crate(&self) -> CrateNum {
self.0.krate
}
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.0)
}
}
impl Key for (DefId, LocalDefId, Ident) {
type CacheSelector = DefaultCacheSelector;