Merge pull request #3215 from PyO3/bump-edition
Bump Rust edition to 2021 and make current Clippy happy.
This commit is contained in:
commit
1b92a6fec0
|
@ -11,7 +11,7 @@ documentation = "https://docs.rs/crate/pyo3/"
|
||||||
categories = ["api-bindings", "development-tools::ffi"]
|
categories = ["api-bindings", "development-tools::ffi"]
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
exclude = ["/.gitignore", ".cargo/config", "/codecov.yml", "/Makefile", "/pyproject.toml", "/noxfile.py", "/.github", "/tests/test_compile_error.rs", "/tests/ui"]
|
exclude = ["/.gitignore", ".cargo/config", "/codecov.yml", "/Makefile", "/pyproject.toml", "/noxfile.py", "/.github", "/tests/test_compile_error.rs", "/tests/ui"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
rust-version = "1.56"
|
rust-version = "1.56"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -187,7 +187,6 @@ members = [
|
||||||
"pytests",
|
"pytests",
|
||||||
"examples",
|
"examples",
|
||||||
]
|
]
|
||||||
resolver = "2"
|
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
no-default-features = true
|
no-default-features = true
|
||||||
|
|
|
@ -53,7 +53,7 @@ The most important files generated by this command are `Cargo.toml` and `lib.rs`
|
||||||
[package]
|
[package]
|
||||||
name = "string_sum"
|
name = "string_sum"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
# The name of the native library. This is the name which will be used in Python to import the
|
# The name of the native library. This is the name which will be used in Python to import the
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
name = "examples"
|
name = "examples"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
publish = false
|
publish = false
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
pyo3 = { version = "0.19.0", path = "..", features = ["auto-initialize", "extension-module"] }
|
pyo3 = { version = "0.19.0", path = "..", features = ["auto-initialize", "extension-module"] }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "decorator"
|
name = "decorator"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "decorator"
|
name = "decorator"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "maturin-starter"
|
name = "maturin-starter"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "maturin_starter"
|
name = "maturin_starter"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "setuptools-rust-starter"
|
name = "setuptools-rust-starter"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "setuptools_rust_starter"
|
name = "setuptools_rust_starter"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "word-count"
|
name = "word-count"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "word_count"
|
name = "word_count"
|
||||||
|
|
|
@ -71,7 +71,6 @@ impl Number {
|
||||||
|
|
||||||
With that out of the way, let's implement some operators:
|
With that out of the way, let's implement some operators:
|
||||||
```rust
|
```rust
|
||||||
use std::convert::TryInto;
|
|
||||||
use pyo3::exceptions::{PyZeroDivisionError, PyValueError};
|
use pyo3::exceptions::{PyZeroDivisionError, PyValueError};
|
||||||
|
|
||||||
# use pyo3::prelude::*;
|
# use pyo3::prelude::*;
|
||||||
|
|
|
@ -8,7 +8,7 @@ homepage = "https://github.com/pyo3/pyo3"
|
||||||
repository = "https://github.com/pyo3/pyo3"
|
repository = "https://github.com/pyo3/pyo3"
|
||||||
categories = ["api-bindings", "development-tools::ffi"]
|
categories = ["api-bindings", "development-tools::ffi"]
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
once_cell = "1"
|
once_cell = "1"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "pyo3-ffi-check"
|
name = "pyo3-ffi-check"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "pyo3-ffi-check-macro"
|
name = "pyo3-ffi-check-macro"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
|
|
|
@ -8,7 +8,7 @@ homepage = "https://github.com/pyo3/pyo3"
|
||||||
repository = "https://github.com/pyo3/pyo3"
|
repository = "https://github.com/pyo3/pyo3"
|
||||||
categories = ["api-bindings", "development-tools::ffi"]
|
categories = ["api-bindings", "development-tools::ffi"]
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
links = "python"
|
links = "python"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
|
@ -41,11 +41,11 @@ extern "C" {
|
||||||
) -> *mut PyObject;
|
) -> *mut PyObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(Py_3_8))]
|
#[cfg(Py_3_8)]
|
||||||
const PY_VECTORCALL_ARGUMENTS_OFFSET: Py_ssize_t =
|
const PY_VECTORCALL_ARGUMENTS_OFFSET: Py_ssize_t =
|
||||||
1 << (8 * std::mem::size_of::<Py_ssize_t>() as Py_ssize_t - 1);
|
1 << (8 * std::mem::size_of::<Py_ssize_t>() as Py_ssize_t - 1);
|
||||||
|
|
||||||
#[cfg(all(Py_3_8))]
|
#[cfg(Py_3_8)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn PyVectorcall_NARGS(n: size_t) -> Py_ssize_t {
|
pub unsafe fn PyVectorcall_NARGS(n: size_t) -> Py_ssize_t {
|
||||||
assert!(n <= (PY_SSIZE_T_MAX as size_t));
|
assert!(n <= (PY_SSIZE_T_MAX as size_t));
|
||||||
|
@ -113,7 +113,7 @@ extern "C" {
|
||||||
kwnames: *mut PyObject,
|
kwnames: *mut PyObject,
|
||||||
) -> *mut PyObject;
|
) -> *mut PyObject;
|
||||||
|
|
||||||
#[cfg(all(Py_3_8))]
|
#[cfg(Py_3_8)]
|
||||||
#[cfg_attr(all(not(PyPy), not(Py_3_9)), link_name = "_PyObject_VectorcallDict")]
|
#[cfg_attr(all(not(PyPy), not(Py_3_9)), link_name = "_PyObject_VectorcallDict")]
|
||||||
#[cfg_attr(all(PyPy, not(Py_3_9)), link_name = "_PyPyObject_VectorcallDict")]
|
#[cfg_attr(all(PyPy, not(Py_3_9)), link_name = "_PyPyObject_VectorcallDict")]
|
||||||
#[cfg_attr(all(PyPy, Py_3_9), link_name = "PyPyObject_VectorcallDict")]
|
#[cfg_attr(all(PyPy, Py_3_9), link_name = "PyPyObject_VectorcallDict")]
|
||||||
|
@ -124,7 +124,7 @@ extern "C" {
|
||||||
kwdict: *mut PyObject,
|
kwdict: *mut PyObject,
|
||||||
) -> *mut PyObject;
|
) -> *mut PyObject;
|
||||||
|
|
||||||
#[cfg(all(Py_3_8))]
|
#[cfg(Py_3_8)]
|
||||||
#[cfg_attr(not(any(Py_3_9, PyPy)), link_name = "_PyVectorcall_Call")]
|
#[cfg_attr(not(any(Py_3_9, PyPy)), link_name = "_PyVectorcall_Call")]
|
||||||
#[cfg_attr(PyPy, link_name = "PyPyVectorcall_Call")]
|
#[cfg_attr(PyPy, link_name = "PyPyVectorcall_Call")]
|
||||||
pub fn PyVectorcall_Call(
|
pub fn PyVectorcall_Call(
|
||||||
|
|
|
@ -8,7 +8,7 @@ homepage = "https://github.com/pyo3/pyo3"
|
||||||
repository = "https://github.com/pyo3/pyo3"
|
repository = "https://github.com/pyo3/pyo3"
|
||||||
categories = ["api-bindings", "development-tools::ffi"]
|
categories = ["api-bindings", "development-tools::ffi"]
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
# Note: we use default-features = false for proc-macro related crates
|
# Note: we use default-features = false for proc-macro related crates
|
||||||
# not to depend on proc-macro itself.
|
# not to depend on proc-macro itself.
|
||||||
|
|
|
@ -416,7 +416,7 @@ impl ContainerOptions {
|
||||||
}
|
}
|
||||||
ContainerPyO3Attribute::ItemAll(kw) => {
|
ContainerPyO3Attribute::ItemAll(kw) => {
|
||||||
ensure_spanned!(
|
ensure_spanned!(
|
||||||
matches!(options.from_item_all, None),
|
options.from_item_all.is_none(),
|
||||||
kw.span() => "`from_item_all` may only be provided once"
|
kw.span() => "`from_item_all` may only be provided once"
|
||||||
);
|
);
|
||||||
options.from_item_all = Some(kw);
|
options.from_item_all = Some(kw);
|
||||||
|
@ -608,7 +608,7 @@ pub fn build_derive_from_pyobject(tokens: &DeriveInput) -> Result<TokenStream> {
|
||||||
use #krate as _pyo3;
|
use #krate as _pyo3;
|
||||||
|
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl#trait_generics _pyo3::FromPyObject<#lt_param> for #ident#generics #where_clause {
|
impl #trait_generics _pyo3::FromPyObject<#lt_param> for #ident #generics #where_clause {
|
||||||
fn extract(obj: &#lt_param _pyo3::PyAny) -> _pyo3::PyResult<Self> {
|
fn extract(obj: &#lt_param _pyo3::PyAny) -> _pyo3::PyResult<Self> {
|
||||||
#derives
|
#derives
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ homepage = "https://github.com/pyo3/pyo3"
|
||||||
repository = "https://github.com/pyo3/pyo3"
|
repository = "https://github.com/pyo3/pyo3"
|
||||||
categories = ["api-bindings", "development-tools::ffi"]
|
categories = ["api-bindings", "development-tools::ffi"]
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
|
@ -3,7 +3,7 @@ authors = ["PyO3 Authors"]
|
||||||
name = "pyo3-pytests"
|
name = "pyo3-pytests"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
description = "Python-based tests for PyO3"
|
description = "Python-based tests for PyO3"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
|
@ -16,6 +16,7 @@ impl EmptyClass {
|
||||||
|
|
||||||
/// This is for demonstrating how to return a value from __next__
|
/// This is for demonstrating how to return a value from __next__
|
||||||
#[pyclass]
|
#[pyclass]
|
||||||
|
#[derive(Default)]
|
||||||
struct PyClassIter {
|
struct PyClassIter {
|
||||||
count: usize,
|
count: usize,
|
||||||
}
|
}
|
||||||
|
@ -24,7 +25,7 @@ struct PyClassIter {
|
||||||
impl PyClassIter {
|
impl PyClassIter {
|
||||||
#[new]
|
#[new]
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
PyClassIter { count: 0 }
|
Default::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn __next__(&mut self) -> IterNextOutput<usize, &'static str> {
|
fn __next__(&mut self) -> IterNextOutput<usize, &'static str> {
|
||||||
|
|
|
@ -139,7 +139,7 @@
|
||||||
//! [package]
|
//! [package]
|
||||||
//! name = "string-sum"
|
//! name = "string-sum"
|
||||||
//! version = "0.1.0"
|
//! version = "0.1.0"
|
||||||
//! edition = "2018"
|
//! edition = "2021"
|
||||||
//!
|
//!
|
||||||
//! [lib]
|
//! [lib]
|
||||||
//! name = "string_sum"
|
//! name = "string_sum"
|
||||||
|
|
|
@ -499,7 +499,6 @@ impl<T: PyClass> PyCell<T> {
|
||||||
/// Gets the offset of the dictionary from the start of the struct in bytes.
|
/// Gets the offset of the dictionary from the start of the struct in bytes.
|
||||||
pub(crate) fn dict_offset() -> ffi::Py_ssize_t {
|
pub(crate) fn dict_offset() -> ffi::Py_ssize_t {
|
||||||
use memoffset::offset_of;
|
use memoffset::offset_of;
|
||||||
use std::convert::TryInto;
|
|
||||||
|
|
||||||
let offset = offset_of!(PyCell<T>, contents) + offset_of!(PyCellContents<T>, dict);
|
let offset = offset_of!(PyCell<T>, contents) + offset_of!(PyCellContents<T>, dict);
|
||||||
|
|
||||||
|
@ -511,7 +510,6 @@ impl<T: PyClass> PyCell<T> {
|
||||||
/// Gets the offset of the weakref list from the start of the struct in bytes.
|
/// Gets the offset of the weakref list from the start of the struct in bytes.
|
||||||
pub(crate) fn weaklist_offset() -> ffi::Py_ssize_t {
|
pub(crate) fn weaklist_offset() -> ffi::Py_ssize_t {
|
||||||
use memoffset::offset_of;
|
use memoffset::offset_of;
|
||||||
use std::convert::TryInto;
|
|
||||||
|
|
||||||
let offset = offset_of!(PyCell<T>, contents) + offset_of!(PyCellContents<T>, weakref);
|
let offset = offset_of!(PyCell<T>, contents) + offset_of!(PyCellContents<T>, weakref);
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,6 @@ pub struct Foo4 {
|
||||||
field: i32,
|
field: i32,
|
||||||
|
|
||||||
#[pyo3(get, set)]
|
#[pyo3(get, set)]
|
||||||
#[cfg(any(not(FALSE)))]
|
#[cfg(not(FALSE))]
|
||||||
field: u32,
|
field: u32,
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,21 +8,3 @@ error[E0597]: `local_data` does not live long enough
|
||||||
| ---------------------------------------------------- argument requires that `local_data` is borrowed for `'static`
|
| ---------------------------------------------------- argument requires that `local_data` is borrowed for `'static`
|
||||||
14 | });
|
14 | });
|
||||||
| - `local_data` dropped here while still borrowed
|
| - `local_data` dropped here while still borrowed
|
||||||
|
|
||||||
error[E0373]: closure may outlive the current function, but it borrows `ref_`, which is owned by the current function
|
|
||||||
--> tests/ui/invalid_closure.rs:9:26
|
|
||||||
|
|
|
||||||
9 | let closure_fn = |_args: &PyTuple, _kwargs: Option<&PyDict>| -> PyResult<()> {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ may outlive borrowed value `ref_`
|
|
||||||
10 | println!("This is five: {:?}", ref_.len());
|
|
||||||
| ---- `ref_` is borrowed here
|
|
||||||
|
|
|
||||||
note: function requires argument type to outlive `'static`
|
|
||||||
--> tests/ui/invalid_closure.rs:13:9
|
|
||||||
|
|
|
||||||
13 | PyCFunction::new_closure(py, None, None, closure_fn).unwrap().into()
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
help: to force the closure to take ownership of `ref_` (and any other referenced variables), use the `move` keyword
|
|
||||||
|
|
|
||||||
9 | let closure_fn = move |_args: &PyTuple, _kwargs: Option<&PyDict>| -> PyResult<()> {
|
|
||||||
| ++++
|
|
||||||
|
|
Loading…
Reference in New Issue