Skip to content

Commit 4831523

Browse files
authored
Rollup merge of #76757 - matthiaskrgr:clippy_try_into, r=lcnr
don't convert types to the same type with try_into (clippy::useless_conversion)
2 parents 5631b5d + 0e34142 commit 4831523

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

compiler/rustc_mir/src/dataflow/move_paths/builder.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use rustc_middle::mir::*;
44
use rustc_middle::ty::{self, TyCtxt};
55
use smallvec::{smallvec, SmallVec};
66

7-
use std::convert::TryInto;
87
use std::mem;
98

109
use super::abs_domain::Lift;
@@ -481,12 +480,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
481480
};
482481
let base_ty = base_place.ty(self.builder.body, self.builder.tcx).ty;
483482
let len: u64 = match base_ty.kind() {
484-
ty::Array(_, size) => {
485-
let length = size.eval_usize(self.builder.tcx, self.builder.param_env);
486-
length
487-
.try_into()
488-
.expect("slice pattern of array with more than u32::MAX elements")
489-
}
483+
ty::Array(_, size) => size.eval_usize(self.builder.tcx, self.builder.param_env),
490484
_ => bug!("from_end: false slice pattern of non-array type"),
491485
};
492486
for offset in from..to {

compiler/rustc_mir/src/interpret/place.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ where
551551
let n = base.len(self)?;
552552
if n < min_length {
553553
// This can only be reached in ConstProp and non-rustc-MIR.
554-
throw_ub!(BoundsCheckFailed { len: min_length.into(), index: n });
554+
throw_ub!(BoundsCheckFailed { len: min_length, index: n });
555555
}
556556

557557
let index = if from_end {
@@ -565,9 +565,7 @@ where
565565
self.mplace_index(base, index)?
566566
}
567567

568-
Subslice { from, to, from_end } => {
569-
self.mplace_subslice(base, u64::from(from), u64::from(to), from_end)?
570-
}
568+
Subslice { from, to, from_end } => self.mplace_subslice(base, from, to, from_end)?,
571569
})
572570
}
573571

compiler/rustc_mir_build/src/build/matches/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
3333
let tcx = self.hir.tcx();
3434
let (min_length, exact_size) = match place.ty(&self.local_decls, tcx).ty.kind() {
3535
ty::Array(_, length) => {
36-
(length.eval_usize(tcx, self.hir.param_env).try_into().unwrap(), true)
36+
(length.eval_usize(tcx, self.hir.param_env), true)
3737
}
3838
_ => ((prefix.len() + suffix.len()).try_into().unwrap(), false),
3939
};

0 commit comments

Comments
 (0)