fix overflow in array length computation
This commit is contained in:
parent
a517049d8c
commit
6672b862c4
@ -643,15 +643,15 @@ fn check_must_not_suspend_ty<'tcx>(
|
|||||||
}
|
}
|
||||||
ty::Array(ty, len) => {
|
ty::Array(ty, len) => {
|
||||||
let descr_pre = &format!("{}array{} of ", data.descr_pre, plural_suffix);
|
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(
|
check_must_not_suspend_ty(
|
||||||
fcx,
|
fcx,
|
||||||
ty,
|
ty,
|
||||||
hir_id,
|
hir_id,
|
||||||
SuspendCheckData {
|
SuspendCheckData {
|
||||||
descr_pre,
|
descr_pre,
|
||||||
plural_len: len.try_eval_target_usize(fcx.tcx, fcx.param_env).unwrap_or(0)
|
plural_len,
|
||||||
as usize
|
|
||||||
+ 1,
|
|
||||||
..data
|
..data
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user