Split bounds from predicates

This commit is contained in:
Matthew Jasper 2020-06-24 19:13:44 +01:00
parent a7ead3bd53
commit d297147e62
10 changed files with 153 additions and 231 deletions

View file

@ -169,8 +169,13 @@ rustc_queries! {
/// ^^^^^^^^^^^^^^^
///
/// `key` is the `DefId` of the associated type or opaque type.
query explicit_item_bounds(key: DefId) -> &'tcx [(ty::Predicate<'tcx>, Span)] {
desc { |tcx| "finding item bounds for `{}`", tcx.def_path_str(key) }
}
/// Elaborated the predicates from `explicit_item_bounds`.
query item_bounds(key: DefId) -> &'tcx ty::List<ty::Predicate<'tcx>> {
desc { |tcx| "finding projection predicates for `{}`", tcx.def_path_str(key) }
desc { |tcx| "elaborating item bounds for `{}`", tcx.def_path_str(key) }
}
query projection_ty_from_predicates(key: (DefId, DefId)) -> Option<ty::ProjectionTy<'tcx>> {

View file

@ -607,12 +607,12 @@ pub trait PrettyPrinter<'tcx>:
}
// Grab the "TraitA + TraitB" from `impl TraitA + TraitB`,
// by looking up the projections associated with the def_id.
let bounds = self.tcx().predicates_of(def_id).instantiate(self.tcx(), substs);
let bounds = self.tcx().item_bounds(def_id).subst(self.tcx(), substs);
let mut first = true;
let mut is_sized = false;
p!("impl");
for predicate in bounds.predicates {
for predicate in bounds {
// Note: We can't use `to_opt_poly_trait_ref` here as `predicate`
// may contain unbound variables. We therefore do this manually.
//