Remove identity casts

This commit is contained in:
Nilstrieb 2023-04-09 23:07:45 +02:00
parent 81c320ea77
commit 4b4948c2e3
8 changed files with 11 additions and 11 deletions

View File

@ -686,7 +686,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
fn bclose_maybe_open(&mut self, span: rustc_span::Span, empty: bool, close_box: bool) {
let has_comment = self.maybe_print_comment(span.hi());
if !empty || has_comment {
self.break_offset_if_not_bol(1, -(INDENT_UNIT as isize));
self.break_offset_if_not_bol(1, -INDENT_UNIT);
}
self.word("}");
if close_box {

View File

@ -242,7 +242,7 @@ pub fn enum_def_to_string(
impl<'a> State<'a> {
pub fn bclose_maybe_open(&mut self, span: rustc_span::Span, close_box: bool) {
self.maybe_print_comment(span.hi());
self.break_offset_if_not_bol(1, -(INDENT_UNIT as isize));
self.break_offset_if_not_bol(1, -INDENT_UNIT);
self.word("}");
if close_box {
self.end(); // close the outer-box

View File

@ -30,7 +30,7 @@ pub unsafe extern "C" fn LLVMRustStringWriteImpl(
ptr: *const c_char,
size: size_t,
) {
let slice = slice::from_raw_parts(ptr as *const u8, size as usize);
let slice = slice::from_raw_parts(ptr as *const u8, size);
sr.bytes.borrow_mut().extend_from_slice(slice);
}

View File

@ -133,21 +133,21 @@ impl<'tcx> MirPatch<'tcx> {
let mut new_decl = LocalDecl::new(ty, span).internal();
**new_decl.local_info.as_mut().assert_crate_local() = local_info;
self.new_locals.push(new_decl);
Local::new(index as usize)
Local::new(index)
}
pub fn new_temp(&mut self, ty: Ty<'tcx>, span: Span) -> Local {
let index = self.next_local;
self.next_local += 1;
self.new_locals.push(LocalDecl::new(ty, span));
Local::new(index as usize)
Local::new(index)
}
pub fn new_internal(&mut self, ty: Ty<'tcx>, span: Span) -> Local {
let index = self.next_local;
self.next_local += 1;
self.new_locals.push(LocalDecl::new(ty, span).internal());
Local::new(index as usize)
Local::new(index)
}
pub fn new_block(&mut self, data: BasicBlockData<'tcx>) -> BasicBlock {

View File

@ -98,7 +98,7 @@ impl<'tcx> PlaceTy<'tcx> {
ty::Array(inner, _) if !from_end => tcx.mk_array(*inner, (to - from) as u64),
ty::Array(inner, size) if from_end => {
let size = size.eval_target_usize(tcx, param_env);
let len = size - (from as u64) - (to as u64);
let len = size - from - to;
tcx.mk_array(*inner, len)
}
_ => bug!("cannot subslice non-array type: `{:?}`", self),

View File

@ -337,7 +337,7 @@ impl ScalarInt {
/// Fails if the size of the `ScalarInt` is not equal to `Size { raw: 16 }`
/// and returns the `ScalarInt`s size in that case.
pub fn try_to_i128(self) -> Result<i128, Size> {
self.try_to_int(Size::from_bits(128)).map(|v| i128::try_from(v).unwrap())
self.try_to_int(Size::from_bits(128))
}
}

View File

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

View File

@ -558,8 +558,8 @@ impl<'a> StringReader<'a> {
}
if let Some(possible_offset) = possible_offset {
let lo = start + BytePos(possible_offset as u32);
let hi = lo + BytePos(found_terminators as u32);
let lo = start + BytePos(possible_offset);
let hi = lo + BytePos(found_terminators);
let span = self.mk_sp(lo, hi);
err.span_suggestion(
span,