Skip to content

Commit b041511

Browse files
committed
Auto merge of #4340 - lzutao:rustup, r=oli-obk
Rustup rust-lang/rust#59369 Unblock rust-lang/rust#63280 changelog: none
2 parents ea26a95 + e4f8cd9 commit b041511

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

clippy_lints/src/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
230230
ExprKind::Tup(ref tup) => self.multi(tup).map(Constant::Tuple),
231231
ExprKind::Repeat(ref value, _) => {
232232
let n = match self.tables.expr_ty(e).sty {
233-
ty::Array(_, n) => n.assert_usize(self.lcx.tcx).expect("array length"),
233+
ty::Array(_, n) => n.eval_usize(self.lcx.tcx, self.lcx.param_env),
234234
_ => span_bug!(e.span, "typeck error"),
235235
};
236236
self.expr(value).map(|v| Constant::Repeat(Box::new(v), n))

clippy_lints/src/indexing_slicing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing {
9494
if let Some(range) = higher::range(cx, index) {
9595
// Ranged indexes, i.e., &x[n..m], &x[n..], &x[..n] and &x[..]
9696
if let ty::Array(_, s) = ty.sty {
97-
let size: u128 = s.assert_usize(cx.tcx).unwrap().into();
97+
let size: u128 = s.eval_usize(cx.tcx, cx.param_env).into();
9898

9999
let const_range = to_const_range(cx, range, size);
100100

clippy_lints/src/loops.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ fn is_end_eq_array_len<'tcx>(
12531253
if let ExprKind::Lit(ref lit) = end.node;
12541254
if let ast::LitKind::Int(end_int, _) = lit.node;
12551255
if let ty::Array(_, arr_len_const) = indexed_ty.sty;
1256-
if let Some(arr_len) = arr_len_const.assert_usize(cx.tcx);
1256+
if let Some(arr_len) = arr_len_const.try_eval_usize(cx.tcx, cx.param_env);
12571257
then {
12581258
return match limits {
12591259
ast::RangeLimits::Closed => end_int + 1 >= arr_len.into(),
@@ -1375,7 +1375,7 @@ fn check_for_loop_arg(cx: &LateContext<'_, '_>, pat: &Pat, arg: &Expr, expr: &Ex
13751375
match cx.tables.expr_ty(&args[0]).sty {
13761376
// If the length is greater than 32 no traits are implemented for array and
13771377
// therefore we cannot use `&`.
1378-
ty::Array(_, size) if size.assert_usize(cx.tcx).expect("array size") > 32 => (),
1378+
ty::Array(_, size) if size.eval_usize(cx.tcx, cx.param_env) > 32 => {},
13791379
_ => lint_iter_method(cx, args, arg, method_name),
13801380
};
13811381
} else {
@@ -1988,7 +1988,7 @@ fn is_ref_iterable_type(cx: &LateContext<'_, '_>, e: &Expr) -> bool {
19881988
fn is_iterable_array<'tcx>(ty: Ty<'tcx>, cx: &LateContext<'_, 'tcx>) -> bool {
19891989
// IntoIterator is currently only implemented for array sizes <= 32 in rustc
19901990
match ty.sty {
1991-
ty::Array(_, n) => (0..=32).contains(&n.assert_usize(cx.tcx).expect("array length")),
1991+
ty::Array(_, n) => (0..=32).contains(&n.eval_usize(cx.tcx, cx.param_env)),
19921992
_ => false,
19931993
}
19941994
}

clippy_lints/src/methods/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1825,7 +1825,7 @@ fn derefs_to_slice<'a, 'tcx>(
18251825
ty::Slice(_) => true,
18261826
ty::Adt(def, _) if def.is_box() => may_slice(cx, ty.boxed_ty()),
18271827
ty::Adt(..) => match_type(cx, ty, &paths::VEC),
1828-
ty::Array(_, size) => size.assert_usize(cx.tcx).expect("array length") < 32,
1828+
ty::Array(_, size) => size.eval_usize(cx.tcx, cx.param_env) < 32,
18291829
ty::Ref(_, inner, _) => may_slice(cx, inner),
18301830
_ => false,
18311831
}

0 commit comments

Comments
 (0)