Explicitly (un)implement Ungil
This commit is contained in:
parent
90281f88d3
commit
ec275d49cb
|
@ -261,7 +261,7 @@
|
|||
macro_rules! opaque_struct {
|
||||
($name:ident) => {
|
||||
#[repr(C)]
|
||||
pub struct $name([u8; 0], ::std::marker::PhantomData<$crate::PyObject>);
|
||||
pub struct $name([u8; 0]);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -126,7 +126,6 @@ use crate::type_object::{PyTypeInfo, PyTypeObject};
|
|||
use crate::types::{PyAny, PyDict, PyModule, PyType};
|
||||
use crate::version::PythonVersionInfo;
|
||||
use crate::{ffi, AsPyPointer, FromPyPointer, IntoPyPointer, PyNativeType, PyObject, PyTryFrom};
|
||||
use std::convert::TryFrom;
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::marker::PhantomData;
|
||||
use std::os::raw::c_int;
|
||||
|
@ -159,10 +158,33 @@ unsafe impl<T: Send> Ungil for T {}
|
|||
pub unsafe auto trait Ungil {}
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
impl !Ungil for Python<'_> {}
|
||||
mod negative_impls {
|
||||
use super::Ungil;
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
impl !Ungil for ffi::PyObject {}
|
||||
impl !Ungil for crate::Python<'_> {}
|
||||
|
||||
// This means that PyString, PyList, etc all inherit !Ungil from this.
|
||||
impl !Ungil for crate::PyAny {}
|
||||
|
||||
// All the borrowing wrappers
|
||||
impl<T> !Ungil for crate::PyCell<T> {}
|
||||
impl<T> !Ungil for crate::PyRef<'_, T> {}
|
||||
impl<T> !Ungil for crate::PyRefMut<'_, T> {}
|
||||
|
||||
// FFI pointees
|
||||
impl !Ungil for crate::ffi::PyObject {}
|
||||
impl !Ungil for crate::ffi::PyLongObject {}
|
||||
|
||||
impl !Ungil for crate::ffi::PyThreadState {}
|
||||
impl !Ungil for crate::ffi::PyInterpreterState {}
|
||||
impl !Ungil for crate::ffi::PyWeakReference {}
|
||||
impl !Ungil for crate::ffi::PyFrameObject {}
|
||||
impl !Ungil for crate::ffi::PyCodeObject {}
|
||||
#[cfg(not(Py_LIMITED_API))]
|
||||
impl !Ungil for crate::ffi::PyDictKeysObject {}
|
||||
#[cfg(not(Py_LIMITED_API))]
|
||||
impl !Ungil for crate::ffi::PyArena {}
|
||||
}
|
||||
|
||||
/// A marker token that represents holding the GIL.
|
||||
///
|
||||
|
@ -623,7 +645,7 @@ impl<'py> Python<'py> {
|
|||
// version number.
|
||||
let version_number_str = version_str.split(' ').next().unwrap_or(version_str);
|
||||
|
||||
TryFrom::try_from(version_number_str).unwrap()
|
||||
PythonVersionInfo::from_str(version_number_str).unwrap()
|
||||
}
|
||||
|
||||
/// Registers the object in the release pool, and tries to downcast to specific type.
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
error[E0277]: the trait bound `PyObject: Ungil` is not satisfied in `[closure@$DIR/tests/ui/not_send_auto_trait2.rs:8:26: 10:10]`
|
||||
error[E0277]: the trait bound `PyAny: Ungil` is not satisfied in `[closure@$DIR/tests/ui/not_send_auto_trait2.rs:8:26: 10:10]`
|
||||
--> tests/ui/not_send_auto_trait2.rs:8:12
|
||||
|
|
||||
8 | py.allow_threads(|| {
|
||||
| ____________^^^^^^^^^^^^^_-
|
||||
| | |
|
||||
| | within `[closure@$DIR/tests/ui/not_send_auto_trait2.rs:8:26: 10:10]`, the trait `Ungil` is not implemented for `PyObject`
|
||||
| | within `[closure@$DIR/tests/ui/not_send_auto_trait2.rs:8:26: 10:10]`, the trait `Ungil` is not implemented for `PyAny`
|
||||
9 | | println!("{:?}", string);
|
||||
10 | | });
|
||||
| |_________- within this `[closure@$DIR/tests/ui/not_send_auto_trait2.rs:8:26: 10:10]`
|
||||
|
|
||||
= note: required because it appears within the type `UnsafeCell<PyObject>`
|
||||
= note: required because it appears within the type `PyAny`
|
||||
= note: required because it appears within the type `PyString`
|
||||
= note: required because it appears within the type `&PyString`
|
||||
= note: required because it appears within the type `&&PyString`
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
error[E0277]: the trait bound `PyObject: Ungil` is not satisfied in `[closure@$DIR/tests/ui/send_wrapper.rs:11:26: 14:10]`
|
||||
error[E0277]: the trait bound `PyAny: Ungil` is not satisfied in `[closure@$DIR/tests/ui/send_wrapper.rs:11:26: 14:10]`
|
||||
--> tests/ui/send_wrapper.rs:11:12
|
||||
|
|
||||
11 | py.allow_threads(|| {
|
||||
| ____________^^^^^^^^^^^^^_-
|
||||
| | |
|
||||
| | within `[closure@$DIR/tests/ui/send_wrapper.rs:11:26: 14:10]`, the trait `Ungil` is not implemented for `PyObject`
|
||||
| | within `[closure@$DIR/tests/ui/send_wrapper.rs:11:26: 14:10]`, the trait `Ungil` is not implemented for `PyAny`
|
||||
12 | | let smuggled: &PyString = *wrapped;
|
||||
13 | | println!("{:?}", smuggled);
|
||||
14 | | });
|
||||
| |_________- within this `[closure@$DIR/tests/ui/send_wrapper.rs:11:26: 14:10]`
|
||||
|
|
||||
= note: required because it appears within the type `UnsafeCell<PyObject>`
|
||||
= note: required because it appears within the type `PyAny`
|
||||
= note: required because it appears within the type `PyString`
|
||||
= note: required because it appears within the type `&PyString`
|
||||
= note: required because it appears within the type `*mut &PyString`
|
||||
|
|
Loading…
Reference in New Issue