Skip to content

Commit be54947

Browse files
committed
Extract copy bound check into a function
1 parent 018f934 commit be54947

File tree

1 file changed

+12
-3
lines changed
  • compiler/rustc_typeck/src/check

1 file changed

+12
-3
lines changed

compiler/rustc_typeck/src/check/expr.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12921292
return tcx.ty_error();
12931293
}
12941294

1295+
self.check_repeat_element_needs_copy_bound(element, count, element_ty);
1296+
1297+
tcx.mk_ty(ty::Array(t, count))
1298+
}
1299+
1300+
fn check_repeat_element_needs_copy_bound(
1301+
&self,
1302+
element: &hir::Expr<'_>,
1303+
count: ty::Const<'tcx>,
1304+
element_ty: Ty<'tcx>,
1305+
) {
1306+
let tcx = self.tcx;
12951307
let is_const = match &element.kind {
12961308
hir::ExprKind::ConstBlock(..) => true,
12971309
hir::ExprKind::Path(qpath) => {
@@ -1303,7 +1315,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13031315
}
13041316
_ => false,
13051317
};
1306-
13071318
if !is_const {
13081319
let is_const_fn = match element.kind {
13091320
hir::ExprKind::Call(func, _args) => match *self.node_ty(func.hir_id).kind() {
@@ -1319,8 +1330,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13191330
self.require_type_meets(element_ty, element.span, code, lang_item);
13201331
}
13211332
}
1322-
1323-
tcx.mk_ty(ty::Array(t, count))
13241333
}
13251334

13261335
fn check_expr_tuple(

0 commit comments

Comments
 (0)