Skip to content

Commit b679842

Browse files
committed
unnecessary_cast
casting to the same type is unnecessary
1 parent 3cf6f95 commit b679842

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

library/std/src/sys/windows/handle.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl Handle {
107107
unsafe { self.synchronous_read(buf.as_mut_ptr().cast(), buf.len(), Some(offset)) };
108108

109109
match res {
110-
Ok(read) => Ok(read as usize),
110+
Ok(read) => Ok(read),
111111
Err(ref e) if e.raw_os_error() == Some(c::ERROR_HANDLE_EOF as i32) => Ok(0),
112112
Err(e) => Err(e),
113113
}
@@ -121,7 +121,7 @@ impl Handle {
121121
Ok(read) => {
122122
// Safety: `read` bytes were written to the initialized portion of the buffer
123123
unsafe {
124-
cursor.advance(read as usize);
124+
cursor.advance(read);
125125
}
126126
Ok(())
127127
}

library/std/src/sys/windows/io.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'a> IoSlice<'a> {
3636

3737
#[inline]
3838
pub fn as_slice(&self) -> &[u8] {
39-
unsafe { slice::from_raw_parts(self.vec.buf as *mut u8, self.vec.len as usize) }
39+
unsafe { slice::from_raw_parts(self.vec.buf, self.vec.len as usize) }
4040
}
4141
}
4242

@@ -70,12 +70,12 @@ impl<'a> IoSliceMut<'a> {
7070

7171
#[inline]
7272
pub fn as_slice(&self) -> &[u8] {
73-
unsafe { slice::from_raw_parts(self.vec.buf as *mut u8, self.vec.len as usize) }
73+
unsafe { slice::from_raw_parts(self.vec.buf, self.vec.len as usize) }
7474
}
7575

7676
#[inline]
7777
pub fn as_mut_slice(&mut self) -> &mut [u8] {
78-
unsafe { slice::from_raw_parts_mut(self.vec.buf as *mut u8, self.vec.len as usize) }
78+
unsafe { slice::from_raw_parts_mut(self.vec.buf, self.vec.len as usize) }
7979
}
8080
}
8181

library/std/src/sys/windows/os.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,5 +364,5 @@ pub fn exit(code: i32) -> ! {
364364
}
365365

366366
pub fn getpid() -> u32 {
367-
unsafe { c::GetCurrentProcessId() as u32 }
367+
unsafe { c::GetCurrentProcessId() }
368368
}

library/std/src/sys/windows/process.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ impl Process {
657657
}
658658

659659
pub fn id(&self) -> u32 {
660-
unsafe { c::GetProcessId(self.handle.as_raw_handle()) as u32 }
660+
unsafe { c::GetProcessId(self.handle.as_raw_handle()) }
661661
}
662662

663663
pub fn main_thread_handle(&self) -> BorrowedHandle<'_> {
@@ -918,7 +918,7 @@ fn make_proc_thread_attribute_list(
918918
};
919919

920920
let mut proc_thread_attribute_list = ProcThreadAttributeList(
921-
vec![MaybeUninit::uninit(); required_size as usize].into_boxed_slice(),
921+
vec![MaybeUninit::uninit(); required_size].into_boxed_slice(),
922922
);
923923

924924
// Once we've allocated the necessary memory, it's safe to invoke

0 commit comments

Comments
 (0)