Skip to content

Commit 4b4948c

Browse files
committed
Remove identity casts
1 parent 81c320e commit 4b4948c

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
686686
fn bclose_maybe_open(&mut self, span: rustc_span::Span, empty: bool, close_box: bool) {
687687
let has_comment = self.maybe_print_comment(span.hi());
688688
if !empty || has_comment {
689-
self.break_offset_if_not_bol(1, -(INDENT_UNIT as isize));
689+
self.break_offset_if_not_bol(1, -INDENT_UNIT);
690690
}
691691
self.word("}");
692692
if close_box {

compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ pub fn enum_def_to_string(
242242
impl<'a> State<'a> {
243243
pub fn bclose_maybe_open(&mut self, span: rustc_span::Span, close_box: bool) {
244244
self.maybe_print_comment(span.hi());
245-
self.break_offset_if_not_bol(1, -(INDENT_UNIT as isize));
245+
self.break_offset_if_not_bol(1, -INDENT_UNIT);
246246
self.word("}");
247247
if close_box {
248248
self.end(); // close the outer-box

compiler/rustc_llvm/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub unsafe extern "C" fn LLVMRustStringWriteImpl(
3030
ptr: *const c_char,
3131
size: size_t,
3232
) {
33-
let slice = slice::from_raw_parts(ptr as *const u8, size as usize);
33+
let slice = slice::from_raw_parts(ptr as *const u8, size);
3434

3535
sr.bytes.borrow_mut().extend_from_slice(slice);
3636
}

compiler/rustc_middle/src/mir/patch.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,21 +133,21 @@ impl<'tcx> MirPatch<'tcx> {
133133
let mut new_decl = LocalDecl::new(ty, span).internal();
134134
**new_decl.local_info.as_mut().assert_crate_local() = local_info;
135135
self.new_locals.push(new_decl);
136-
Local::new(index as usize)
136+
Local::new(index)
137137
}
138138

139139
pub fn new_temp(&mut self, ty: Ty<'tcx>, span: Span) -> Local {
140140
let index = self.next_local;
141141
self.next_local += 1;
142142
self.new_locals.push(LocalDecl::new(ty, span));
143-
Local::new(index as usize)
143+
Local::new(index)
144144
}
145145

146146
pub fn new_internal(&mut self, ty: Ty<'tcx>, span: Span) -> Local {
147147
let index = self.next_local;
148148
self.next_local += 1;
149149
self.new_locals.push(LocalDecl::new(ty, span).internal());
150-
Local::new(index as usize)
150+
Local::new(index)
151151
}
152152

153153
pub fn new_block(&mut self, data: BasicBlockData<'tcx>) -> BasicBlock {

compiler/rustc_middle/src/mir/tcx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl<'tcx> PlaceTy<'tcx> {
9898
ty::Array(inner, _) if !from_end => tcx.mk_array(*inner, (to - from) as u64),
9999
ty::Array(inner, size) if from_end => {
100100
let size = size.eval_target_usize(tcx, param_env);
101-
let len = size - (from as u64) - (to as u64);
101+
let len = size - from - to;
102102
tcx.mk_array(*inner, len)
103103
}
104104
_ => bug!("cannot subslice non-array type: `{:?}`", self),

compiler/rustc_middle/src/ty/consts/int.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ impl ScalarInt {
337337
/// Fails if the size of the `ScalarInt` is not equal to `Size { raw: 16 }`
338338
/// and returns the `ScalarInt`s size in that case.
339339
pub fn try_to_i128(self) -> Result<i128, Size> {
340-
self.try_to_int(Size::from_bits(128)).map(|v| i128::try_from(v).unwrap())
340+
self.try_to_int(Size::from_bits(128))
341341
}
342342
}
343343

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1891,7 +1891,7 @@ impl<'tcx> Ty<'tcx> {
18911891
// The way we evaluate the `N` in `[T; N]` here only works since we use
18921892
// `simd_size_and_type` post-monomorphization. It will probably start to ICE
18931893
// if we use it in generic code. See the `simd-array-trait` ui test.
1894-
(f0_len.eval_target_usize(tcx, ParamEnv::empty()) as u64, *f0_elem_ty)
1894+
(f0_len.eval_target_usize(tcx, ParamEnv::empty()), *f0_elem_ty)
18951895
}
18961896
// Otherwise, the fields of this Adt are the SIMD components (and we assume they
18971897
// all have the same type).

compiler/rustc_parse/src/lexer/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,8 @@ impl<'a> StringReader<'a> {
558558
}
559559

560560
if let Some(possible_offset) = possible_offset {
561-
let lo = start + BytePos(possible_offset as u32);
562-
let hi = lo + BytePos(found_terminators as u32);
561+
let lo = start + BytePos(possible_offset);
562+
let hi = lo + BytePos(found_terminators);
563563
let span = self.mk_sp(lo, hi);
564564
err.span_suggestion(
565565
span,

0 commit comments

Comments
 (0)