ty::Expr reviews
This commit is contained in:
parent
56092a345b
commit
7fa98d0c01
3 changed files with 11 additions and 7 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -149,7 +149,7 @@ fn recurse_build<'tcx>(
|
|||
for &id in args.iter() {
|
||||
new_args.push(recurse_build(tcx, body, id, root_span)?);
|
||||
}
|
||||
ty::Const::new_expr(tcx, Expr::new_call(tcx, fun_ty, fun, new_args.into_iter()))
|
||||
ty::Const::new_expr(tcx, Expr::new_call(tcx, fun_ty, fun, new_args))
|
||||
}
|
||||
&ExprKind::Binary { op, lhs, rhs } if check_binop(op) => {
|
||||
let lhs_ty = body.exprs[lhs].ty;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue