1
Fork 0

Rollup merge of #108029 - oli-obk:🞋_usize, r=RalfJung

s/eval_usize/eval_target_usize/ for clarity

r? `@nnethercote`

as discussed in https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/.60Const.60.20and.20.60usize.60.2F.60u64.60 it is unclear what `usize` means and why we use a `u64` for something talking about `usize`. This renaming should make it clear that we're talking about `usize`s on the target platform, irrespective of the compiler host platform.
This commit is contained in:
Matthias Krüger 2023-02-14 18:02:54 +01:00 committed by GitHub
commit f68864cbca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 347 additions and 259 deletions

View file

@ -2605,7 +2605,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue {
ty.tuple_fields().iter().find_map(|field| ty_find_init_error(cx, field, init))
}
Array(ty, len) => {
if matches!(len.try_eval_usize(cx.tcx, cx.param_env), Some(v) if v > 0) {
if matches!(len.try_eval_target_usize(cx.tcx, cx.param_env), Some(v) if v > 0) {
// Array length known at array non-empty -- recurse.
ty_find_init_error(cx, *ty, init)
} else {

View file

@ -309,7 +309,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
None
}
}
ty::Array(ty, len) => match len.try_eval_usize(cx.tcx, cx.param_env) {
ty::Array(ty, len) => match len.try_eval_target_usize(cx.tcx, cx.param_env) {
// If the array is empty we don't lint, to avoid false positives
Some(0) | None => None,
// If the array is definitely non-empty, we can do `#[must_use]` checking.