Add bound_type_of
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user