Skip to content

Fix missing_transmute_annotations, legacy_numeric_constants added in Rust 1.79.0 clippy #5339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion common/src/fileutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,17 @@ pub mod windows {
if let Some(proc) =
unsafe { GetProcAddress(module, name.as_bytes_with_nul().as_ptr()) }
{
Some(unsafe { std::mem::transmute(proc) })
Some(unsafe {
std::mem::transmute::<
unsafe extern "system" fn() -> isize,
unsafe extern "system" fn(
*const u16,
FILE_INFO_BY_NAME_CLASS,
*mut libc::c_void,
u32,
) -> i32,
>(proc)
})
} else {
unsafe { FreeLibrary(module) };
None
Expand Down
4 changes: 2 additions & 2 deletions stdlib/src/ssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ mod _ssl {
#[pyfunction(name = "RAND_add")]
fn rand_add(string: ArgStrOrBytesLike, entropy: f64) {
let f = |b: &[u8]| {
for buf in b.chunks(libc::c_int::max_value() as usize) {
for buf in b.chunks(libc::c_int::MAX as usize) {
unsafe { sys::RAND_add(buf.as_ptr() as *const _, buf.len() as _, entropy) }
}
};
Expand Down Expand Up @@ -1513,7 +1513,7 @@ mod bio {
pub fn new(buf: &'a [u8]) -> Result<MemBioSlice<'a>, ErrorStack> {
openssl::init();

assert!(buf.len() <= c_int::max_value() as usize);
assert!(buf.len() <= c_int::MAX as usize);
let bio = unsafe { sys::BIO_new_mem_buf(buf.as_ptr() as *const _, buf.len() as c_int) };
if bio.is_null() {
return Err(ErrorStack::get());
Expand Down
4 changes: 3 additions & 1 deletion vm/src/function/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@ impl std::fmt::Debug for PyMethodDef {
.field("name", &self.name)
.field(
"func",
&(unsafe { std::mem::transmute::<_, [usize; 2]>(self.func)[1] as *const u8 }),
&(unsafe {
std::mem::transmute::<&dyn PyNativeFn, [usize; 2]>(self.func)[1] as *const u8
}),
)
.field("flags", &self.flags)
.field("doc", &self.doc)
Expand Down
2 changes: 1 addition & 1 deletion vm/src/intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ impl MaybeInternedString for Py<PyStr> {
#[inline(always)]
fn as_interned(&self) -> Option<&'static PyStrInterned> {
if self.as_object().is_interned() {
Some(unsafe { std::mem::transmute(self) })
Some(unsafe { std::mem::transmute::<&Py<PyStr>, &PyInterned<PyStr>>(self) })
} else {
None
}
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ pub(super) mod _os {
-1
} else {
distance_to_move[0] = ret as _;
std::mem::transmute(distance_to_move)
std::mem::transmute::<[i32; 2], i64>(distance_to_move)
}
};
if res < 0 {
Expand Down
Loading