Skip to content

Commit bca90f1

Browse files
authored
Fix missing_transmute_annotations, legacy_numeric_constants added in Rust 1.79.0 clippy (RustPython#5339)
1 parent 7996a10 commit bca90f1

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

common/src/fileutils.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,17 @@ pub mod windows {
327327
if let Some(proc) =
328328
unsafe { GetProcAddress(module, name.as_bytes_with_nul().as_ptr()) }
329329
{
330-
Some(unsafe { std::mem::transmute(proc) })
330+
Some(unsafe {
331+
std::mem::transmute::<
332+
unsafe extern "system" fn() -> isize,
333+
unsafe extern "system" fn(
334+
*const u16,
335+
FILE_INFO_BY_NAME_CLASS,
336+
*mut libc::c_void,
337+
u32,
338+
) -> i32,
339+
>(proc)
340+
})
331341
} else {
332342
unsafe { FreeLibrary(module) };
333343
None

stdlib/src/ssl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ mod _ssl {
379379
#[pyfunction(name = "RAND_add")]
380380
fn rand_add(string: ArgStrOrBytesLike, entropy: f64) {
381381
let f = |b: &[u8]| {
382-
for buf in b.chunks(libc::c_int::max_value() as usize) {
382+
for buf in b.chunks(libc::c_int::MAX as usize) {
383383
unsafe { sys::RAND_add(buf.as_ptr() as *const _, buf.len() as _, entropy) }
384384
}
385385
};
@@ -1513,7 +1513,7 @@ mod bio {
15131513
pub fn new(buf: &'a [u8]) -> Result<MemBioSlice<'a>, ErrorStack> {
15141514
openssl::init();
15151515

1516-
assert!(buf.len() <= c_int::max_value() as usize);
1516+
assert!(buf.len() <= c_int::MAX as usize);
15171517
let bio = unsafe { sys::BIO_new_mem_buf(buf.as_ptr() as *const _, buf.len() as c_int) };
15181518
if bio.is_null() {
15191519
return Err(ErrorStack::get());

vm/src/function/method.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,9 @@ impl std::fmt::Debug for PyMethodDef {
236236
.field("name", &self.name)
237237
.field(
238238
"func",
239-
&(unsafe { std::mem::transmute::<_, [usize; 2]>(self.func)[1] as *const u8 }),
239+
&(unsafe {
240+
std::mem::transmute::<&dyn PyNativeFn, [usize; 2]>(self.func)[1] as *const u8
241+
}),
240242
)
241243
.field("flags", &self.flags)
242244
.field("doc", &self.doc)

vm/src/intern.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ impl MaybeInternedString for Py<PyStr> {
286286
#[inline(always)]
287287
fn as_interned(&self) -> Option<&'static PyStrInterned> {
288288
if self.as_object().is_interned() {
289-
Some(unsafe { std::mem::transmute(self) })
289+
Some(unsafe { std::mem::transmute::<&Py<PyStr>, &PyInterned<PyStr>>(self) })
290290
} else {
291291
None
292292
}

vm/src/stdlib/os.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ pub(super) mod _os {
999999
-1
10001000
} else {
10011001
distance_to_move[0] = ret as _;
1002-
std::mem::transmute(distance_to_move)
1002+
std::mem::transmute::<[i32; 2], i64>(distance_to_move)
10031003
}
10041004
};
10051005
if res < 0 {

0 commit comments

Comments
 (0)