Skip to content

Commit 6672b86

Browse files
committed
fix overflow in array length computation
1 parent a517049 commit 6672b86

File tree

1 file changed

+3
-3
lines changed
  • compiler/rustc_hir_typeck/src/generator_interior

1 file changed

+3
-3
lines changed

compiler/rustc_hir_typeck/src/generator_interior/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -643,15 +643,15 @@ fn check_must_not_suspend_ty<'tcx>(
643643
}
644644
ty::Array(ty, len) => {
645645
let descr_pre = &format!("{}array{} of ", data.descr_pre, plural_suffix);
646+
let target_usize = len.try_eval_target_usize(fcx.tcx, fcx.param_env).unwrap_or(0) as usize;
647+
let plural_len = target_usize.saturating_add(1);
646648
check_must_not_suspend_ty(
647649
fcx,
648650
ty,
649651
hir_id,
650652
SuspendCheckData {
651653
descr_pre,
652-
plural_len: len.try_eval_target_usize(fcx.tcx, fcx.param_env).unwrap_or(0)
653-
as usize
654-
+ 1,
654+
plural_len,
655655
..data
656656
},
657657
)

0 commit comments

Comments
 (0)