Skip to content

Commit

Permalink
handle clippy new_without_default warnings (#3971)
Browse files Browse the repository at this point in the history
* handle clippy `new_without_default` warnings

* add newsfragment
  • Loading branch information
davidhewitt authored Mar 19, 2024
1 parent 02e188e commit caf80ec
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions newsfragments/3971.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Implement `Default` for `GILOnceCell`.
1 change: 1 addition & 0 deletions pyo3-ffi/src/cpython/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ mod bufferinfo {
}

impl Py_buffer {
#[allow(clippy::new_without_default)]
pub const fn new() -> Self {
Py_buffer {
buf: ptr::null_mut(),
Expand Down
1 change: 1 addition & 0 deletions pyo3-ffi/src/pybuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct Py_buffer {
}

impl Py_buffer {
#[allow(clippy::new_without_default)]
pub const fn new() -> Self {
Py_buffer {
buf: ptr::null_mut(),
Expand Down
1 change: 1 addition & 0 deletions src/impl_/pyclass/lazy_type_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct LazyTypeObjectInner {

impl<T> LazyTypeObject<T> {
/// Creates an uninitialized `LazyTypeObject`.
#[allow(clippy::new_without_default)]
pub const fn new() -> Self {
LazyTypeObject(
LazyTypeObjectInner {
Expand Down
1 change: 1 addition & 0 deletions src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ unsafe impl<T> Sync for GILProtected<T> where T: Send {}
/// }
/// # Python::with_gil(|py| assert_eq!(get_shared_list(py).len(), 0));
/// ```
#[derive(Default)]
pub struct GILOnceCell<T>(UnsafeCell<Option<T>>);

// T: Send is needed for Sync because the thread which drops the GILOnceCell can be different
Expand Down

0 comments on commit caf80ec

Please sign in to comment.