Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 627a151

Browse files
Fix tests
1 parent b7d3c5f commit 627a151

File tree

15 files changed

+46
-41
lines changed

15 files changed

+46
-41
lines changed

‎compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
133133
.expect_const()
134134
.try_to_valtree()
135135
.expect("expected monomorphic const in codegen")
136+
.0
136137
.unwrap_branch();
137138

138139
assert_eq!(x.layout(), y.layout());
@@ -806,8 +807,10 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
806807
ty::Uint(i) if i.bit_width() == Some(expected_int_bits) => m.load_scalar(fx),
807808
ty::Array(elem, len)
808809
if matches!(elem.kind(), ty::Uint(ty::UintTy::U8))
809-
&& len.try_eval_target_usize(fx.tcx, ty::ParamEnv::reveal_all())
810-
== Some(expected_bytes) =>
810+
&& len
811+
.try_to_target_usize(fx.tcx)
812+
.expect("expected monomorphic const in codegen")
813+
== expected_bytes =>
811814
{
812815
m.force_stack(fx).0.load(
813816
fx,
@@ -907,8 +910,10 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
907910
ty::Uint(i) if i.bit_width() == Some(expected_int_bits) => {}
908911
ty::Array(elem, len)
909912
if matches!(elem.kind(), ty::Uint(ty::UintTy::U8))
910-
&& len.try_eval_target_usize(fx.tcx, ty::ParamEnv::reveal_all())
911-
== Some(expected_bytes) => {}
913+
&& len
914+
.try_to_target_usize(fx.tcx)
915+
.expect("expected monomorphic const in codegen")
916+
== expected_bytes => {}
912917
_ => {
913918
fx.tcx.dcx().span_fatal(
914919
span,

‎compiler/rustc_codegen_gcc/src/intrinsic/simd.rs‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
7676
ty::Uint(i) if i.bit_width() == Some(expected_int_bits) => args[0].immediate(),
7777
ty::Array(elem, len)
7878
if matches!(*elem.kind(), ty::Uint(ty::UintTy::U8))
79-
&& len.try_eval_target_usize(bx.tcx, ty::ParamEnv::reveal_all())
80-
== Some(expected_bytes) =>
79+
&& len
80+
.try_to_target_usize(bx.tcx)
81+
.expect("expected monomorphic const in codegen")
82+
== expected_bytes =>
8183
{
8284
let place = PlaceRef::alloca(bx, args[0].layout);
8385
args[0].val.store(bx, place);
@@ -680,8 +682,10 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
680682
}
681683
ty::Array(elem, len)
682684
if matches!(*elem.kind(), ty::Uint(ty::UintTy::U8))
683-
&& len.try_eval_target_usize(bx.tcx, ty::ParamEnv::reveal_all())
684-
== Some(expected_bytes) =>
685+
&& len
686+
.try_to_target_usize(bx.tcx)
687+
.expect("expected monomorphic const in codegen")
688+
== expected_bytes =>
685689
{
686690
// Zero-extend iN to the array length:
687691
let ze = bx.zext(result, bx.type_ix(expected_bytes * 8));

‎src/librustdoc/clean/mod.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,7 +1817,7 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
18171817
// Only anon consts can implicitly capture params.
18181818
// FIXME: is this correct behavior?
18191819
let param_env = cx.tcx.param_env(*def_id);
1820-
ct.normalize(cx.tcx, param_env)
1820+
ct.normalize_internal(cx.tcx, param_env)
18211821
} else {
18221822
ct
18231823
};
@@ -2038,8 +2038,8 @@ pub(crate) fn clean_middle_ty<'tcx>(
20382038
Box::new(clean_middle_ty(bound_ty.rebind(ty), cx, None, None)),
20392039
format!("{pat:?}").into_boxed_str(),
20402040
),
2041-
ty::Array(ty, mutn) => {
2042-
n = n.normalize(cx.tcx, ty::ParamEnv::reveal_all());
2041+
ty::Array(ty, n) => {
2042+
letn = cx.tcx.normalize_erasing_regions(cx.param_env, n);
20432043
let n = print_const(cx, n);
20442044
Array(Box::new(clean_middle_ty(bound_ty.rebind(ty), cx, None, None)), n.into())
20452045
}

‎src/tools/clippy/clippy_lints/src/indexing_slicing.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing {
114114
if let Some(range) = higher::Range::hir(index) {
115115
// Ranged indexes, i.e., &x[n..m], &x[n..], &x[..n] and &x[..]
116116
if let ty::Array(_, s) = ty.kind() {
117-
let size: u128 = if let Some(size) = s.try_eval_target_usize(cx.tcx, cx.param_env) {
117+
let size: u128 = if let Some(size) = s.try_to_target_usize(cx.tcx) {
118118
size.into()
119119
} else {
120120
return;
@@ -183,7 +183,7 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing {
183183
&& let ty::Uint(utype) = cx.typeck_results().expr_ty(index).kind()
184184
&& *utype == ty::UintTy::Usize
185185
&& let ty::Array(_, s) = ty.kind()
186-
&& let Some(size) = s.try_eval_target_usize(cx.tcx, cx.param_env)
186+
&& let Some(size) = s.try_to_target_usize(cx.tcx)
187187
{
188188
// get constant offset and check whether it is in bounds
189189
let off = usize::try_from(off).unwrap();

‎src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub(super) fn check(
3030
return;
3131
}
3232
} else if count
33-
.try_eval_target_usize(cx.tcx, cx.param_env)
33+
.try_to_target_usize(cx.tcx)
3434
.map_or(true, |x| x > 32)
3535
&& !msrv.meets(msrvs::ARRAY_IMPL_ANY_LEN)
3636
{

‎src/tools/clippy/clippy_lints/src/loops/manual_memcpy.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ fn is_array_length_equal_to_range(cx: &LateContext<'_>, start: &Expr<'_>, end: &
472472
let arr_ty = cx.typeck_results().expr_ty(arr).peel_refs();
473473

474474
if let ty::Array(_, s) = arr_ty.kind() {
475-
let size: u128 = if let Some(size) = s.try_eval_target_usize(cx.tcx, cx.param_env) {
475+
let size: u128 = if let Some(size) = s.try_to_target_usize(cx.tcx) {
476476
size.into()
477477
} else {
478478
return false;

‎src/tools/clippy/clippy_lints/src/loops/needless_range_loop.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ fn is_end_eq_array_len<'tcx>(
207207
if let ExprKind::Lit(lit) = end.kind
208208
&& let ast::LitKind::Int(end_int, _) = lit.node
209209
&& let ty::Array(_, arr_len_const) = indexed_ty.kind()
210-
&& let Some(arr_len) = arr_len_const.try_eval_target_usize(cx.tcx, cx.param_env)
210+
&& let Some(arr_len) = arr_len_const.try_to_target_usize(cx.tcx)
211211
{
212212
return match limits {
213213
ast::RangeLimits::Closed => end_int.get() + 1 >= arr_len.into(),

‎src/tools/clippy/clippy_lints/src/matches/single_match.rs‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_hir::def::{DefKind, Res};
1111
use rustc_hir::intravisit::{Visitor, walk_pat};
1212
use rustc_hir::{Arm, Expr, ExprKind, HirId, Node, Pat, PatKind, QPath, StmtKind};
1313
use rustc_lint::LateContext;
14-
use rustc_middle::ty::{self, AdtDef, ParamEnv,TyCtxt, TypeckResults, VariantDef};
14+
use rustc_middle::ty::{self, AdtDef, TyCtxt, TypeckResults, VariantDef};
1515
use rustc_span::{Span, sym};
1616

1717
use super::{MATCH_BOOL, SINGLE_MATCH, SINGLE_MATCH_ELSE};
@@ -67,7 +67,6 @@ pub(crate) fn check<'tcx>(cx: &LateContext<'tcx>, ex: &'tcx Expr<'_>, arms: &'tc
6767
if v.has_enum {
6868
let cx = PatCtxt {
6969
tcx: cx.tcx,
70-
param_env: cx.param_env,
7170
typeck,
7271
arena: DroplessArena::default(),
7372
};
@@ -185,7 +184,6 @@ impl<'tcx> Visitor<'tcx> for PatVisitor<'tcx> {
185184
/// The context needed to manipulate a `PatState`.
186185
struct PatCtxt<'tcx> {
187186
tcx: TyCtxt<'tcx>,
188-
param_env: ParamEnv<'tcx>,
189187
typeck: &'tcx TypeckResults<'tcx>,
190188
arena: DroplessArena,
191189
}
@@ -334,7 +332,7 @@ impl<'a> PatState<'a> {
334332
if match *cx.typeck.pat_ty(pat).peel_refs().kind() {
335333
ty::Adt(adt, _) => adt.is_enum() || (adt.is_struct() && !adt.non_enum_variant().fields.is_empty()),
336334
ty::Tuple(tys) => !tys.is_empty(),
337-
ty::Array(_, len) => len.try_eval_target_usize(cx.tcx, cx.param_env) != Some(1),
335+
ty::Array(_, len) => len.try_to_target_usize(cx.tcx) != Some(1),
338336
ty::Slice(..) => true,
339337
_ => false,
340338
} =>
@@ -353,7 +351,7 @@ impl<'a> PatState<'a> {
353351
},
354352
PatKind::Slice([sub_pat], _, []) | PatKind::Slice([], _, [sub_pat])
355353
if let ty::Array(_, len) = *cx.typeck.pat_ty(pat).kind()
356-
&& len.try_eval_target_usize(cx.tcx, cx.param_env) == Some(1) =>
354+
&& len.try_to_target_usize(cx.tcx) == Some(1) =>
357355
{
358356
self.add_pat(cx, sub_pat)
359357
},

‎src/tools/clippy/clippy_lints/src/methods/iter_out_of_bounds.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ fn get_iterator_length<'tcx>(cx: &LateContext<'tcx>, iter: &'tcx Expr<'tcx>) ->
3131
// parameter.
3232
substs
3333
.const_at(1)
34-
.try_eval_target_usize(cx.tcx, cx.param_env)
34+
.try_to_target_usize(cx.tcx)
3535
.map(u128::from)
3636
} else if cx.tcx.is_diagnostic_item(sym::SliceIter, did)
3737
&& let ExprKind::MethodCall(_, recv, ..) = iter.kind
3838
{
3939
if let ty::Array(_, len) = cx.typeck_results().expr_ty(recv).peel_refs().kind() {
4040
// For slice::Iter<'_, T>, the receiver might be an array literal: [1,2,3].iter().skip(..)
41-
len.try_eval_target_usize(cx.tcx, cx.param_env).map(u128::from)
41+
len.try_to_target_usize(cx.tcx).map(u128::from)
4242
} else if let Some(args) = VecArgs::hir(cx, expr_or_init(cx, recv)) {
4343
match args {
4444
VecArgs::Vec(vec) => vec.len().try_into().ok(),

‎src/tools/clippy/clippy_lints/src/methods/utils.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub(super) fn derefs_to_slice<'tcx>(
1818
ty::Slice(_) => true,
1919
ty::Adt(..) if let Some(boxed) = ty.boxed_ty() => may_slice(cx, boxed),
2020
ty::Adt(..) => is_type_diagnostic_item(cx, ty, sym::Vec),
21-
ty::Array(_, size) => size.try_eval_target_usize(cx.tcx, cx.param_env).is_some(),
21+
ty::Array(_, size) => size.try_to_target_usize(cx.tcx).is_some(),
2222
ty::Ref(_, inner, _) => may_slice(cx, *inner),
2323
_ => false,
2424
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /