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:
commit
f68864cbca
48 changed files with 347 additions and 259 deletions
|
@ -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 {
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue