diff options
| author | reez12g <reez12g@gmail.com> | 2023-08-29 16:02:18 +0900 |
|---|---|---|
| committer | reez12g <reez12g@gmail.com> | 2023-09-05 15:18:42 +0900 |
| commit | 6672b862c456f0dad14f7cab0d4cae6f7dab89c0 (patch) | |
| tree | 7a2196539500189e68aa5f795d6f34762550ba92 | |
| parent | a517049d8cd49b1a81249f68cdf24ecbadaf7e0d (diff) | |
fix overflow in array length computation
| -rw-r--r-- | compiler/rustc_hir_typeck/src/generator_interior/mod.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/rustc_hir_typeck/src/generator_interior/mod.rs b/compiler/rustc_hir_typeck/src/generator_interior/mod.rs index 6a817122491..38d7d5be97e 100644 --- a/compiler/rustc_hir_typeck/src/generator_interior/mod.rs +++ b/compiler/rustc_hir_typeck/src/generator_interior/mod.rs @@ -643,15 +643,15 @@ fn check_must_not_suspend_ty<'tcx>( } ty::Array(ty, len) => { let descr_pre = &format!("{}array{} of ", data.descr_pre, plural_suffix); + let target_usize = len.try_eval_target_usize(fcx.tcx, fcx.param_env).unwrap_or(0) as usize; + let plural_len = target_usize.saturating_add(1); check_must_not_suspend_ty( fcx, ty, hir_id, SuspendCheckData { descr_pre, - plural_len: len.try_eval_target_usize(fcx.tcx, fcx.param_env).unwrap_or(0) - as usize - + 1, + plural_len, ..data }, ) |
