Auto merge of #101857 - lcnr:make-dyn-again, r=jackh726

change `FnMutDelegate` to trait objects

cc #100016 as mentioned in the last t-compiler meeting

r? `@jackh726`
This commit is contained in:
bors 2022-09-17 13:37:48 +00:00
commit 48de123d7a
3 changed files with 20 additions and 23 deletions

View file

@ -72,15 +72,16 @@ where
value
} else {
let delegate = FnMutDelegate {
regions: |br: ty::BoundRegion| match var_values.var_values[br.var].unpack() {
regions: &mut |br: ty::BoundRegion| match var_values.var_values[br.var].unpack() {
GenericArgKind::Lifetime(l) => l,
r => bug!("{:?} is a region but value is {:?}", br, r),
},
types: |bound_ty: ty::BoundTy| match var_values.var_values[bound_ty.var].unpack() {
types: &mut |bound_ty: ty::BoundTy| match var_values.var_values[bound_ty.var].unpack() {
GenericArgKind::Type(ty) => ty,
r => bug!("{:?} is a type but value is {:?}", bound_ty, r),
},
consts: |bound_ct: ty::BoundVar, _| match var_values.var_values[bound_ct].unpack() {
consts: &mut |bound_ct: ty::BoundVar, _| match var_values.var_values[bound_ct].unpack()
{
GenericArgKind::Const(ct) => ct,
c => bug!("{:?} is a const but value is {:?}", bound_ct, c),
},

View file

@ -81,19 +81,19 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
let next_universe = self.create_next_universe();
let delegate = FnMutDelegate {
regions: |br: ty::BoundRegion| {
regions: &mut |br: ty::BoundRegion| {
self.tcx.mk_region(ty::RePlaceholder(ty::PlaceholderRegion {
universe: next_universe,
name: br.kind,
}))
},
types: |bound_ty: ty::BoundTy| {
types: &mut |bound_ty: ty::BoundTy| {
self.tcx.mk_ty(ty::Placeholder(ty::PlaceholderType {
universe: next_universe,
name: bound_ty.var,
}))
},
consts: |bound_var: ty::BoundVar, ty| {
consts: &mut |bound_var: ty::BoundVar, ty| {
self.tcx.mk_const(ty::ConstS {
kind: ty::ConstKind::Placeholder(ty::PlaceholderConst {
universe: next_universe,