use super::combine::CombineFields;
use super::{HigherRankedType, InferCtxt};
use crate::infer::CombinedSnapshot;
+use rustc_middle::ty::fold::FnMutDelegate;
use rustc_middle::ty::relate::{Relate, RelateResult, TypeRelation};
use rustc_middle::ty::{self, Binder, TypeFoldable};
let next_universe = self.create_next_universe();
- let fld_r = |br: ty::BoundRegion| {
- self.tcx.mk_region(ty::RePlaceholder(ty::PlaceholderRegion {
- universe: next_universe,
- name: br.kind,
- }))
- };
-
- let fld_t = |bound_ty: ty::BoundTy| {
- self.tcx.mk_ty(ty::Placeholder(ty::PlaceholderType {
- universe: next_universe,
- name: bound_ty.var,
- }))
- };
-
- let fld_c = |bound_var: ty::BoundVar, ty| {
- self.tcx.mk_const(ty::ConstS {
- kind: ty::ConstKind::Placeholder(ty::PlaceholderConst {
+ let delegate = FnMutDelegate {
+ regions: |br: ty::BoundRegion| {
+ self.tcx.mk_region(ty::RePlaceholder(ty::PlaceholderRegion {
+ universe: next_universe,
+ name: br.kind,
+ }))
+ },
+ types: |bound_ty: ty::BoundTy| {
+ self.tcx.mk_ty(ty::Placeholder(ty::PlaceholderType {
universe: next_universe,
- name: ty::BoundConst { var: bound_var, ty },
- }),
- ty,
- })
+ name: bound_ty.var,
+ }))
+ },
+ consts: |bound_var: ty::BoundVar, ty| {
+ self.tcx.mk_const(ty::ConstS {
+ kind: ty::ConstKind::Placeholder(ty::PlaceholderConst {
+ universe: next_universe,
+ name: ty::BoundConst { var: bound_var, ty },
+ }),
+ ty,
+ })
+ },
};
- let result = self.tcx.replace_bound_vars_uncached(binder, fld_r, fld_t, fld_c);
+ let result = self.tcx.replace_bound_vars_uncached(binder, delegate);
debug!(?next_universe, ?result);
result
}