Refactor tcx mk_const parameters.
This commit is contained in:
parent
6330c27ae2
commit
c97fd8183a
21 changed files with 74 additions and 104 deletions
|
@ -773,10 +773,10 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
|
|||
self.fold_const(bound_to)
|
||||
} else {
|
||||
let var = self.canonical_var(info, const_var.into());
|
||||
self.tcx().mk_const(ty::ConstS {
|
||||
kind: ty::ConstKind::Bound(self.binder_index, var),
|
||||
ty: self.fold_ty(const_var.ty()),
|
||||
})
|
||||
self.tcx().mk_const(
|
||||
ty::ConstKind::Bound(self.binder_index, var),
|
||||
self.fold_ty(const_var.ty()),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,12 +147,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
CanonicalVarKind::PlaceholderConst(ty::PlaceholderConst { universe, name }, ty) => {
|
||||
let universe_mapped = universe_map(universe);
|
||||
let placeholder_mapped = ty::PlaceholderConst { universe: universe_mapped, name };
|
||||
self.tcx
|
||||
.mk_const(ty::ConstS {
|
||||
kind: ty::ConstKind::Placeholder(placeholder_mapped),
|
||||
ty,
|
||||
})
|
||||
.into()
|
||||
self.tcx.mk_const(ty::ConstKind::Placeholder(placeholder_mapped), ty).into()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -741,10 +741,10 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
|
|||
substs,
|
||||
substs,
|
||||
)?;
|
||||
Ok(self.tcx().mk_const(ty::ConstS {
|
||||
ty: c.ty(),
|
||||
kind: ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }),
|
||||
}))
|
||||
Ok(self.tcx().mk_const(
|
||||
ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }),
|
||||
c.ty(),
|
||||
))
|
||||
}
|
||||
_ => relate::super_relate_consts(self, c, c),
|
||||
}
|
||||
|
@ -955,10 +955,10 @@ impl<'tcx> TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
|
|||
substs,
|
||||
)?;
|
||||
|
||||
Ok(self.tcx().mk_const(ty::ConstS {
|
||||
ty: c.ty(),
|
||||
kind: ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }),
|
||||
}))
|
||||
Ok(self.tcx().mk_const(
|
||||
ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }),
|
||||
c.ty(),
|
||||
))
|
||||
}
|
||||
_ => relate::super_relate_consts(self, c, c),
|
||||
}
|
||||
|
|
|
@ -94,13 +94,13 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
}))
|
||||
},
|
||||
consts: &mut |bound_var: ty::BoundVar, ty| {
|
||||
self.tcx.mk_const(ty::ConstS {
|
||||
kind: ty::ConstKind::Placeholder(ty::PlaceholderConst {
|
||||
self.tcx.mk_const(
|
||||
ty::ConstKind::Placeholder(ty::PlaceholderConst {
|
||||
universe: next_universe,
|
||||
name: bound_var,
|
||||
}),
|
||||
ty,
|
||||
})
|
||||
)
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -2065,13 +2065,13 @@ fn replace_param_and_infer_substs_with_placeholder<'tcx>(
|
|||
if ty.has_non_region_param() || ty.has_non_region_infer() {
|
||||
bug!("const `{ct}`'s type should not reference params or types");
|
||||
}
|
||||
tcx.mk_const(ty::ConstS {
|
||||
ty,
|
||||
kind: ty::ConstKind::Placeholder(ty::PlaceholderConst {
|
||||
tcx.mk_const(
|
||||
ty::ConstKind::Placeholder(ty::PlaceholderConst {
|
||||
universe: ty::UniverseIndex::ROOT,
|
||||
name: ty::BoundVar::from_usize(idx),
|
||||
}),
|
||||
})
|
||||
ty,
|
||||
)
|
||||
.into()
|
||||
}
|
||||
_ => arg,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue