Skip to content

Commit e3a739a

Browse files
committed
s/eval_usize/eval_target_usize/ for clarity
1 parent 42d4bd7 commit e3a739a

File tree

8 files changed

+8
-8
lines changed

8 files changed

+8
-8
lines changed

clippy_lints/src/indexing_slicing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing {
109109
if let Some(range) = higher::Range::hir(index) {
110110
// Ranged indexes, i.e., &x[n..m], &x[n..], &x[..n] and &x[..]
111111
if let ty::Array(_, s) = ty.kind() {
112-
let size: u128 = if let Some(size) = s.try_eval_usize(cx.tcx, cx.param_env) {
112+
let size: u128 = if let Some(size) = s.try_eval_target_usize(cx.tcx, cx.param_env) {
113113
size.into()
114114
} else {
115115
return;

clippy_lints/src/loops/explicit_iter_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fn is_iterable_array<'tcx>(ty: Ty<'tcx>, cx: &LateContext<'tcx>) -> bool {
6868
// IntoIterator is currently only implemented for array sizes <= 32 in rustc
6969
match ty.kind() {
7070
ty::Array(_, n) => n
71-
.try_eval_usize(cx.tcx, cx.param_env)
71+
.try_eval_target_usize(cx.tcx, cx.param_env)
7272
.map_or(false, |val| (0..=32).contains(&val)),
7373
_ => false,
7474
}

clippy_lints/src/loops/needless_range_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ fn is_end_eq_array_len<'tcx>(
211211
if let ExprKind::Lit(ref lit) = end.kind;
212212
if let ast::LitKind::Int(end_int, _) = lit.node;
213213
if let ty::Array(_, arr_len_const) = indexed_ty.kind();
214-
if let Some(arr_len) = arr_len_const.try_eval_usize(cx.tcx, cx.param_env);
214+
if let Some(arr_len) = arr_len_const.try_eval_target_usize(cx.tcx, cx.param_env);
215215
then {
216216
return match limits {
217217
ast::RangeLimits::Closed => end_int + 1 >= arr_len.into(),

clippy_lints/src/methods/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub(super) fn derefs_to_slice<'tcx>(
2222
ty::Slice(_) => true,
2323
ty::Adt(def, _) if def.is_box() => may_slice(cx, ty.boxed_ty()),
2424
ty::Adt(..) => is_type_diagnostic_item(cx, ty, sym::Vec),
25-
ty::Array(_, size) => size.try_eval_usize(cx.tcx, cx.param_env).is_some(),
25+
ty::Array(_, size) => size.try_eval_target_usize(cx.tcx, cx.param_env).is_some(),
2626
ty::Ref(_, inner, _) => may_slice(cx, *inner),
2727
_ => false,
2828
}

clippy_lints/src/mut_key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl MutableKeyType {
166166
Ref(_, inner_ty, mutbl) => mutbl == hir::Mutability::Mut || self.is_interior_mutable_type(cx, inner_ty),
167167
Slice(inner_ty) => self.is_interior_mutable_type(cx, inner_ty),
168168
Array(inner_ty, size) => {
169-
size.try_eval_usize(cx.tcx, cx.param_env).map_or(true, |u| u != 0)
169+
size.try_eval_target_usize(cx.tcx, cx.param_env).map_or(true, |u| u != 0)
170170
&& self.is_interior_mutable_type(cx, inner_ty)
171171
},
172172
Tuple(fields) => fields.iter().any(|ty| self.is_interior_mutable_type(cx, ty)),

clippy_lints/src/trailing_empty_array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fn is_struct_with_trailing_zero_sized_array(cx: &LateContext<'_>, item: &Item<'_
6262

6363
// Then check if that that array zero-sized
6464
let length = Const::from_anon_const(cx.tcx, length.def_id);
65-
let length = length.try_eval_usize(cx.tcx, cx.param_env);
65+
let length = length.try_eval_target_usize(cx.tcx, cx.param_env);
6666
if let Some(length) = length;
6767
then {
6868
length == 0

clippy_utils/src/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
335335
ExprKind::Tup(tup) => self.multi(tup).map(Constant::Tuple),
336336
ExprKind::Repeat(value, _) => {
337337
let n = match self.typeck_results.expr_ty(e).kind() {
338-
ty::Array(_, n) => n.try_eval_usize(self.lcx.tcx, self.lcx.param_env)?,
338+
ty::Array(_, n) => n.try_eval_target_usize(self.lcx.tcx, self.lcx.param_env)?,
339339
_ => span_bug!(e.span, "typeck error"),
340340
};
341341
self.expr(value).map(|v| Constant::Repeat(Box::new(v), n))

clippy_utils/src/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ pub fn approx_ty_size<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> u64 {
949949
(Ok(size), _) => size,
950950
(Err(_), ty::Tuple(list)) => list.as_substs().types().map(|t| approx_ty_size(cx, t)).sum(),
951951
(Err(_), ty::Array(t, n)) => {
952-
n.try_eval_usize(cx.tcx, cx.param_env).unwrap_or_default() * approx_ty_size(cx, *t)
952+
n.try_eval_target_usize(cx.tcx, cx.param_env).unwrap_or_default() * approx_ty_size(cx, *t)
953953
},
954954
(Err(_), ty::Adt(def, subst)) if def.is_struct() => def
955955
.variants()

0 commit comments

Comments
 (0)