Skip to content

Commit afefcce

Browse files
authored
ci: fix nightly rust compile failure on function pointers cast to usize (#5625)
* ci: fix nightly rust compile failure on function pointers cast to usize * missing import * remove clippy expectations
1 parent d424586 commit afefcce

File tree

1 file changed

+30
-12
lines changed

1 file changed

+30
-12
lines changed

src/impl_/pyclass.rs

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,10 +1497,16 @@ mod tests {
14971497

14981498
assert_eq!(def.name, c"my_field");
14991499
assert_eq!(def.doc, c"My field doc");
1500-
assert_eq!(
1501-
def.meth as usize,
1502-
pyo3_get_value_into_pyobject_ref::<MyClass, i32, FIELD_OFFSET> as usize
1503-
);
1500+
1501+
#[cfg(fn_ptr_eq)]
1502+
{
1503+
use crate::impl_::pymethods::Getter;
1504+
1505+
assert!(std::ptr::fn_addr_eq(
1506+
def.meth,
1507+
pyo3_get_value_into_pyobject_ref::<MyClass, i32, FIELD_OFFSET> as Getter
1508+
));
1509+
}
15041510

15051511
// generate for a field via `IntoPyObject` + `Clone`
15061512
// SAFETY: offset is correct
@@ -1512,10 +1518,16 @@ mod tests {
15121518
};
15131519
assert_eq!(def.name, c"my_field");
15141520
assert_eq!(def.doc, c"My field doc");
1515-
assert_eq!(
1516-
def.meth as usize,
1517-
pyo3_get_value_into_pyobject::<MyClass, String, FIELD_OFFSET> as usize
1518-
);
1521+
1522+
#[cfg(fn_ptr_eq)]
1523+
{
1524+
use crate::impl_::pymethods::Getter;
1525+
1526+
assert!(std::ptr::fn_addr_eq(
1527+
def.meth,
1528+
pyo3_get_value_into_pyobject::<MyClass, String, FIELD_OFFSET> as Getter
1529+
));
1530+
}
15191531
}
15201532

15211533
#[test]
@@ -1563,9 +1575,15 @@ mod tests {
15631575
};
15641576
assert_eq!(def.name, c"my_field");
15651577
assert_eq!(def.doc, c"My field doc");
1566-
assert_eq!(
1567-
def.meth as usize,
1568-
pyo3_get_value_into_pyobject_ref::<MyClass, Py<PyAny>, FIELD_OFFSET> as usize
1569-
);
1578+
1579+
#[cfg(fn_ptr_eq)]
1580+
{
1581+
use crate::impl_::pymethods::Getter;
1582+
1583+
assert!(std::ptr::fn_addr_eq(
1584+
def.meth,
1585+
pyo3_get_value_into_pyobject_ref::<MyClass, Py<PyAny>, FIELD_OFFSET> as Getter
1586+
));
1587+
}
15701588
}
15711589
}

0 commit comments

Comments
 (0)