1
Fork 0

ty::Expr reviews

This commit is contained in:
Boxy 2024-06-04 18:50:14 +01:00
parent 56092a345b
commit 7fa98d0c01
3 changed files with 11 additions and 7 deletions

View file

@ -104,10 +104,12 @@ impl<'tcx> Expr<'tcx> {
tcx: TyCtxt<'tcx>,
func_ty: Ty<'tcx>,
func_expr: Const<'tcx>,
arguments: impl Iterator<Item = Const<'tcx>>,
arguments: impl IntoIterator<Item = Const<'tcx>>,
) -> Self {
let args = tcx.mk_args_from_iter::<_, ty::GenericArg<'tcx>>(
[func_ty.into(), func_expr.into()].into_iter().chain(arguments.map(|ct| ct.into())),
[func_ty.into(), func_expr.into()]
.into_iter()
.chain(arguments.into_iter().map(|ct| ct.into())),
);
Self { kind: ExprKind::FunctionCall, args }
@ -155,7 +157,7 @@ impl<'tcx> Expr<'tcx> {
Self { kind, args }
}
pub fn args(&self) -> ty::GenericArgsRef<'tcx> {
pub fn args(self) -> ty::GenericArgsRef<'tcx> {
self.args
}
}

View file

@ -652,9 +652,11 @@ pub fn structurally_relate_consts<'tcx, R: TypeRelation<'tcx>>(
// and is the better alternative to waiting until `generic_const_exprs` can
// be stabilized.
(ty::ConstKind::Unevaluated(au), ty::ConstKind::Unevaluated(bu)) if au.def == bu.def => {
let a_ty = tcx.type_of(au.def).instantiate(tcx, au.args);
let b_ty = tcx.type_of(bu.def).instantiate(tcx, bu.args);
assert_eq!(a_ty, b_ty);
if cfg!(debug_assertions) {
let a_ty = tcx.type_of(au.def).instantiate(tcx, au.args);
let b_ty = tcx.type_of(bu.def).instantiate(tcx, bu.args);
assert_eq!(a_ty, b_ty);
}
let args = relation.relate_with_variance(
ty::Variance::Invariant,