Skip to content

Commit f567287

Browse files
committed
don't convert types to the same type with try_into (clippy::useless_conversion)
1 parent a874956 commit f567287

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

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

Lines changed: 1 addition & 4 deletions
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;
@@ -482,10 +481,8 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
482481
let base_ty = base_place.ty(self.builder.body, self.builder.tcx).ty;
483482
let len: u64 = match base_ty.kind() {
484483
ty::Array(_, size) => {
485-
let length = size.eval_usize(self.builder.tcx, self.builder.param_env);
484+
let length: u64 = size.eval_usize(self.builder.tcx, self.builder.param_env);
486485
length
487-
.try_into()
488-
.expect("slice pattern of array with more than u32::MAX elements")
489486
}
490487
_ => bug!("from_end: false slice pattern of non-array type"),
491488
};

compiler/rustc_mir/src/interpret/place.rs

Lines changed: 2 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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)