Rollup merge of #115335 - reez12g:issue-114912, r=davidtwco
fix overflow in array length computation addressing https://github.com/rust-lang/rust/issues/114912
This commit is contained in:
commit
b99af95713
@ -643,17 +643,14 @@ 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, plural_len, ..data },
|
||||||
descr_pre,
|
|
||||||
plural_len: len.try_eval_target_usize(fcx.tcx, fcx.param_env).unwrap_or(0)
|
|
||||||
as usize
|
|
||||||
+ 1,
|
|
||||||
..data
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// If drop tracking is enabled, we want to look through references, since the referent
|
// If drop tracking is enabled, we want to look through references, since the referent
|
||||||
|
Loading…
x
Reference in New Issue
Block a user