Add bound_type_of

This commit is contained in:
Jack Huey
2022-05-08 15:12:56 -04:00
parent 319575ae8c
commit c92248ab9f
30 changed files with 90 additions and 83 deletions

View File

@@ -592,6 +592,10 @@ impl<'tcx> TyCtxt<'tcx> {
trace!(?expanded_type);
if visitor.found_recursion { Err(expanded_type) } else { Ok(expanded_type) }
}
pub fn bound_type_of(self, def_id: DefId) -> EarlyBinder<Ty<'tcx>> {
EarlyBinder(self.type_of(def_id))
}
}
struct OpaqueTypeExpander<'tcx> {
@@ -623,8 +627,8 @@ impl<'tcx> OpaqueTypeExpander<'tcx> {
let expanded_ty = match self.expanded_cache.get(&(def_id, substs)) {
Some(expanded_ty) => *expanded_ty,
None => {
let generic_ty = self.tcx.type_of(def_id);
let concrete_ty = EarlyBinder(generic_ty).subst(self.tcx, substs);
let generic_ty = self.tcx.bound_type_of(def_id);
let concrete_ty = generic_ty.subst(self.tcx, substs);
let expanded_ty = self.fold_ty(concrete_ty);
self.expanded_cache.insert((def_id, substs), expanded_ty);
expanded_ty