Skip to content

Commit

Permalink
Merge #3032
Browse files Browse the repository at this point in the history
3032: fix clippy and ui tests for Rust 1.68 r=adamreichold a=davidhewitt

The usual 😄 

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
  • Loading branch information
bors[bot] and davidhewitt authored Mar 10, 2023
2 parents 59bbb40 + cd36c6f commit b8bf93b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 33 deletions.
11 changes: 5 additions & 6 deletions src/types/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -817,10 +817,8 @@ mod tests {

impl Clone for Bad {
fn clone(&self) -> Self {
if self.0 == 42 {
// This panic should not lead to a memory leak
panic!()
};
// This panic should not lead to a memory leak
assert_ne!(self.0, 42);
NEEDS_DESTRUCTING_COUNT.fetch_add(1, SeqCst);

Bad(self.0)
Expand Down Expand Up @@ -859,10 +857,11 @@ mod tests {
}

Python::with_gil(|py| {
let _ = std::panic::catch_unwind(|| {
std::panic::catch_unwind(|| {
let iter = FaultyIter(0..50, 50);
let _list = PyList::new(py, iter);
});
})
.unwrap_err();
});

assert_eq!(
Expand Down
21 changes: 10 additions & 11 deletions src/types/tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -814,9 +814,8 @@ mod tests {

impl Clone for Bad {
fn clone(&self) -> Self {
if self.0 == 42 {
panic!()
};
// This panic should not lead to a memory leak
assert_ne!(self.0, 42);
NEEDS_DESTRUCTING_COUNT.fetch_add(1, SeqCst);

Bad(self.0)
Expand Down Expand Up @@ -855,10 +854,11 @@ mod tests {
}

Python::with_gil(|py| {
let _ = std::panic::catch_unwind(|| {
std::panic::catch_unwind(|| {
let iter = FaultyIter(0..50, 50);
let _tuple = PyTuple::new(py, iter);
});
})
.unwrap_err();
});

assert_eq!(
Expand All @@ -882,10 +882,8 @@ mod tests {

impl Clone for Bad {
fn clone(&self) -> Self {
if self.0 == 3 {
// This panic should not lead to a memory leak
panic!()
};
// This panic should not lead to a memory leak
assert_ne!(self.0, 3);
NEEDS_DESTRUCTING_COUNT.fetch_add(1, SeqCst);

Bad(self.0)
Expand All @@ -907,9 +905,10 @@ mod tests {
let s = (Bad(1), Bad(2), Bad(3), Bad(4));
NEEDS_DESTRUCTING_COUNT.store(4, SeqCst);
Python::with_gil(|py| {
let _ = std::panic::catch_unwind(|| {
std::panic::catch_unwind(|| {
let _tuple: Py<PyAny> = s.to_object(py);
});
})
.unwrap_err();
});
drop(s);

Expand Down
12 changes: 4 additions & 8 deletions tests/ui/invalid_frozen_pyclass_borrow.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
error[E0271]: type mismatch resolving `<Foo as PyClass>::Frozen == False`
--> tests/ui/invalid_frozen_pyclass_borrow.rs:10:18
--> tests/ui/invalid_frozen_pyclass_borrow.rs:10:33
|
10 | let borrow = foo.as_ref(py).borrow_mut();
| ^^^^^^^^^^^^^^ ---------- required by a bound introduced by this call
| |
| expected struct `False`, found struct `True`
| ^^^^^^^^^^ expected struct `False`, found struct `True`
|
note: required by a bound in `PyCell::<T>::borrow_mut`
--> src/pycell.rs
Expand All @@ -13,12 +11,10 @@ note: required by a bound in `PyCell::<T>::borrow_mut`
| ^^^^^^^^^^^^^^ required by this bound in `PyCell::<T>::borrow_mut`

error[E0271]: type mismatch resolving `<ImmutableChild as PyClass>::Frozen == False`
--> tests/ui/invalid_frozen_pyclass_borrow.rs:20:18
--> tests/ui/invalid_frozen_pyclass_borrow.rs:20:35
|
20 | let borrow = child.as_ref(py).borrow_mut();
| ^^^^^^^^^^^^^^^^ ---------- required by a bound introduced by this call
| |
| expected struct `False`, found struct `True`
| ^^^^^^^^^^ expected struct `False`, found struct `True`
|
note: required by a bound in `PyCell::<T>::borrow_mut`
--> src/pycell.rs
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/not_send.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ error[E0277]: `*mut pyo3::Python<'static>` cannot be shared between threads safe
| required by a bound introduced by this call
|
= help: within `pyo3::Python<'_>`, the trait `Sync` is not implemented for `*mut pyo3::Python<'static>`
= note: required because it appears within the type `PhantomData<*mut pyo3::Python<'static>>`
= note: required because it appears within the type `impl_::not_send::NotSend`
= note: required because it appears within the type `(&GILGuard, impl_::not_send::NotSend)`
= note: required because it appears within the type `PhantomData<(&GILGuard, impl_::not_send::NotSend)>`
= note: required because it appears within the type `pyo3::Python<'_>`
= note: required because it appears within the type `PhantomData<*mut Python<'static>>`
= note: required because it appears within the type `NotSend`
= note: required because it appears within the type `(&GILGuard, NotSend)`
= note: required because it appears within the type `PhantomData<(&GILGuard, NotSend)>`
= note: required because it appears within the type `Python<'_>`
= note: required for `&pyo3::Python<'_>` to implement `Send`
note: required because it's used within this closure
--> tests/ui/not_send.rs:4:22
Expand All @@ -23,4 +23,4 @@ note: required by a bound in `pyo3::Python::<'py>::allow_threads`
--> src/marker.rs
|
| F: Ungil + FnOnce() -> T,
| ^^^^^ required by this bound in `pyo3::Python::<'py>::allow_threads`
| ^^^^^ required by this bound in `Python::<'py>::allow_threads`
2 changes: 1 addition & 1 deletion tests/ui/not_send2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ note: required by a bound in `pyo3::Python::<'py>::allow_threads`
--> src/marker.rs
|
| F: Ungil + FnOnce() -> T,
| ^^^^^ required by this bound in `pyo3::Python::<'py>::allow_threads`
| ^^^^^ required by this bound in `Python::<'py>::allow_threads`
2 changes: 1 addition & 1 deletion tests/ui/not_send3.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ note: required by a bound in `pyo3::Python::<'py>::allow_threads`
--> src/marker.rs
|
| F: Ungil + FnOnce() -> T,
| ^^^^^ required by this bound in `pyo3::Python::<'py>::allow_threads`
| ^^^^^ required by this bound in `Python::<'py>::allow_threads`

0 comments on commit b8bf93b

Please sign in to comment.