Skip to content

Commit 82661d4

Browse files
committed
ty::Expr reviews
1 parent 3d5e01f commit 82661d4

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

compiler/rustc_middle/src/ty/consts/kind.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,12 @@ impl<'tcx> Expr<'tcx> {
104104
tcx: TyCtxt<'tcx>,
105105
func_ty: Ty<'tcx>,
106106
func_expr: Const<'tcx>,
107-
arguments: impl Iterator<Item = Const<'tcx>>,
107+
arguments: impl IntoIterator<Item = Const<'tcx>>,
108108
) -> Self {
109109
let args = tcx.mk_args_from_iter::<_, ty::GenericArg<'tcx>>(
110-
[func_ty.into(), func_expr.into()].into_iter().chain(arguments.map(|ct| ct.into())),
110+
[func_ty.into(), func_expr.into()]
111+
.into_iter()
112+
.chain(arguments.into_iter().map(|ct| ct.into())),
111113
);
112114

113115
Self { kind: ExprKind::FunctionCall, args }
@@ -155,7 +157,7 @@ impl<'tcx> Expr<'tcx> {
155157
Self { kind, args }
156158
}
157159

158-
pub fn args(&self) -> ty::GenericArgsRef<'tcx> {
160+
pub fn args(self) -> ty::GenericArgsRef<'tcx> {
159161
self.args
160162
}
161163
}

compiler/rustc_middle/src/ty/relate.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -652,9 +652,11 @@ pub fn structurally_relate_consts<'tcx, R: TypeRelation<'tcx>>(
652652
// and is the better alternative to waiting until `generic_const_exprs` can
653653
// be stabilized.
654654
(ty::ConstKind::Unevaluated(au), ty::ConstKind::Unevaluated(bu)) if au.def == bu.def => {
655-
let a_ty = tcx.type_of(au.def).instantiate(tcx, au.args);
656-
let b_ty = tcx.type_of(bu.def).instantiate(tcx, bu.args);
657-
assert_eq!(a_ty, b_ty);
655+
if cfg!(debug_assertions) {
656+
let a_ty = tcx.type_of(au.def).instantiate(tcx, au.args);
657+
let b_ty = tcx.type_of(bu.def).instantiate(tcx, bu.args);
658+
assert_eq!(a_ty, b_ty);
659+
}
658660

659661
let args = relation.relate_with_variance(
660662
ty::Variance::Invariant,

compiler/rustc_ty_utils/src/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ fn recurse_build<'tcx>(
149149
for &id in args.iter() {
150150
new_args.push(recurse_build(tcx, body, id, root_span)?);
151151
}
152-
ty::Const::new_expr(tcx, Expr::new_call(tcx, fun_ty, fun, new_args.into_iter()))
152+
ty::Const::new_expr(tcx, Expr::new_call(tcx, fun_ty, fun, new_args))
153153
}
154154
&ExprKind::Binary { op, lhs, rhs } if check_binop(op) => {
155155
let lhs_ty = body.exprs[lhs].ty;

0 commit comments

Comments
 (0)