Skip to content

Commit

Permalink
fix nightly ci (#4385)
Browse files Browse the repository at this point in the history
  • Loading branch information
Icxolu authored and davidhewitt committed Sep 15, 2024
1 parent 2c66281 commit 560790b
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions guide/src/class.md
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ For simple cases where a member variable is just read and written with no side e

```rust
# use pyo3::prelude::*;
# #[allow(dead_code)]
#[pyclass]
struct MyClass {
#[pyo3(get, set)]
Expand Down Expand Up @@ -1360,6 +1361,7 @@ The `#[pyclass]` macro expands to roughly the code seen below. The `PyClassImplC
# #[cfg(not(feature = "multiple-pymethods"))] {
# use pyo3::prelude::*;
// Note: the implementation differs slightly with the `multiple-pymethods` feature enabled.
# #[allow(dead_code)]
struct MyClass {
# #[allow(dead_code)]
num: i32,
Expand Down
8 changes: 8 additions & 0 deletions guide/src/class/object.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ the subclass name. This is typically done in Python code by accessing
# use pyo3::prelude::*;
# use pyo3::types::PyString;
#
# #[allow(dead_code)]
# #[pyclass]
# struct Number(i32);
#
Expand Down Expand Up @@ -110,6 +111,7 @@ use std::hash::{Hash, Hasher};

# use pyo3::prelude::*;
#
# #[allow(dead_code)]
# #[pyclass]
# struct Number(i32);
#
Expand All @@ -130,6 +132,7 @@ method it should not define a `__hash__()` operation either"
```rust
# use pyo3::prelude::*;
#
# #[allow(dead_code)]
#[pyclass(frozen, eq, hash)]
#[derive(PartialEq, Hash)]
struct Number(i32);
Expand Down Expand Up @@ -173,6 +176,7 @@ use pyo3::class::basic::CompareOp;
# use pyo3::prelude::*;
#
# #[allow(dead_code)]
# #[pyclass]
# struct Number(i32);
#
Expand All @@ -199,6 +203,7 @@ use pyo3::class::basic::CompareOp;

# use pyo3::prelude::*;
#
# #[allow(dead_code)]
# #[pyclass]
# struct Number(i32);
#
Expand Down Expand Up @@ -245,6 +250,7 @@ To implement `__eq__` using the Rust [`PartialEq`] trait implementation, the `eq
```rust
# use pyo3::prelude::*;
#
# #[allow(dead_code)]
#[pyclass(eq)]
#[derive(PartialEq)]
struct Number(i32);
Expand All @@ -255,6 +261,7 @@ To implement `__lt__`, `__le__`, `__gt__`, & `__ge__` using the Rust `PartialOrd
```rust
# use pyo3::prelude::*;
#
# #[allow(dead_code)]
#[pyclass(eq, ord)]
#[derive(PartialEq, PartialOrd)]
struct Number(i32);
Expand All @@ -267,6 +274,7 @@ We'll consider `Number` to be `True` if it is nonzero:
```rust
# use pyo3::prelude::*;
#
# #[allow(dead_code)]
# #[pyclass]
# struct Number(i32);
#
Expand Down
1 change: 1 addition & 0 deletions guide/src/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ done with the `crate` attribute:
# use pyo3::prelude::*;
# pub extern crate pyo3;
# mod reexported { pub use ::pyo3; }
# #[allow(dead_code)]
#[pyclass]
#[pyo3(crate = "reexported::pyo3")]
struct MyClass;
Expand Down
1 change: 1 addition & 0 deletions src/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pub trait ToPyObject {
/// ```rust
/// use pyo3::prelude::*;
///
/// # #[allow(dead_code)]
/// #[pyclass]
/// struct Number {
/// #[pyo3(get, set)]
Expand Down
5 changes: 4 additions & 1 deletion src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,10 @@ macro_rules! pyobject_native_type_named (
#[macro_export]
macro_rules! pyobject_native_static_type_object(
($typeobject:expr) => {
|_py| unsafe { ::std::ptr::addr_of_mut!($typeobject) }
|_py| {
#[allow(unused_unsafe)] // https://github.com/rust-lang/rust/pull/125834
unsafe { ::std::ptr::addr_of_mut!($typeobject) }
}
};
);

Expand Down
2 changes: 1 addition & 1 deletion tests/test_declarative_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl ValueClass {
}

#[pyclass(module = "module")]
struct LocatedClass {}
pub struct LocatedClass {}

#[pyfunction]
fn double(x: usize) -> usize {
Expand Down
1 change: 1 addition & 0 deletions tests/test_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ make_struct_using_macro!(MyBaseClass, "MyClass");
macro_rules! set_extends_via_macro {
($class_name:ident, $base_class:path) => {
// Try and pass a variable into the extends parameter
#[allow(dead_code)]
#[pyclass(extends=$base_class)]
struct $class_name {}
};
Expand Down

0 comments on commit 560790b

Please sign in to comment.