Merge pull request #3215 from PyO3/bump-edition

Bump Rust edition to 2021 and make current Clippy happy.
This commit is contained in:
Adam Reichold 2023-06-07 19:41:02 +00:00 committed by GitHub
commit 1b92a6fec0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 24 additions and 45 deletions

View file

@ -11,7 +11,7 @@ documentation = "https://docs.rs/crate/pyo3/"
categories = ["api-bindings", "development-tools::ffi"]
license = "Apache-2.0"
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"
[dependencies]
@ -187,7 +187,6 @@ members = [
"pytests",
"examples",
]
resolver = "2"
[package.metadata.docs.rs]
no-default-features = true

View file

@ -53,7 +53,7 @@ The most important files generated by this command are `Cargo.toml` and `lib.rs`
[package]
name = "string_sum"
version = "0.1.0"
edition = "2018"
edition = "2021"
[lib]
# The name of the native library. This is the name which will be used in Python to import the

View file

@ -2,7 +2,7 @@
name = "examples"
version = "0.0.0"
publish = false
edition = "2018"
edition = "2021"
[dev-dependencies]
pyo3 = { version = "0.19.0", path = "..", features = ["auto-initialize", "extension-module"] }

View file

@ -1,7 +1,7 @@
[package]
name = "decorator"
version = "0.1.0"
edition = "2018"
edition = "2021"
[lib]
name = "decorator"

View file

@ -1,7 +1,7 @@
[package]
name = "maturin-starter"
version = "0.1.0"
edition = "2018"
edition = "2021"
[lib]
name = "maturin_starter"

View file

@ -1,7 +1,7 @@
[package]
name = "setuptools-rust-starter"
version = "0.1.0"
edition = "2018"
edition = "2021"
[lib]
name = "setuptools_rust_starter"

View file

@ -1,7 +1,7 @@
[package]
name = "word-count"
version = "0.1.0"
edition = "2018"
edition = "2021"
[lib]
name = "word_count"

View file

@ -71,7 +71,6 @@ impl Number {
With that out of the way, let's implement some operators:
```rust
use std::convert::TryInto;
use pyo3::exceptions::{PyZeroDivisionError, PyValueError};
# use pyo3::prelude::*;

View file

@ -8,7 +8,7 @@ homepage = "https://github.com/pyo3/pyo3"
repository = "https://github.com/pyo3/pyo3"
categories = ["api-bindings", "development-tools::ffi"]
license = "Apache-2.0"
edition = "2018"
edition = "2021"
[dependencies]
once_cell = "1"

View file

@ -1,7 +1,7 @@
[package]
name = "pyo3-ffi-check"
version = "0.1.0"
edition = "2018"
edition = "2021"
publish = false
[dependencies]

View file

@ -1,7 +1,7 @@
[package]
name = "pyo3-ffi-check-macro"
version = "0.1.0"
edition = "2018"
edition = "2021"
publish = false
[lib]

View file

@ -8,7 +8,7 @@ homepage = "https://github.com/pyo3/pyo3"
repository = "https://github.com/pyo3/pyo3"
categories = ["api-bindings", "development-tools::ffi"]
license = "Apache-2.0"
edition = "2018"
edition = "2021"
links = "python"
[dependencies]

View file

@ -41,11 +41,11 @@ extern "C" {
) -> *mut PyObject;
}
#[cfg(all(Py_3_8))]
#[cfg(Py_3_8)]
const PY_VECTORCALL_ARGUMENTS_OFFSET: Py_ssize_t =
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)]
pub unsafe fn PyVectorcall_NARGS(n: size_t) -> Py_ssize_t {
assert!(n <= (PY_SSIZE_T_MAX as size_t));
@ -113,7 +113,7 @@ extern "C" {
kwnames: *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(PyPy, not(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,
) -> *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(PyPy, link_name = "PyPyVectorcall_Call")]
pub fn PyVectorcall_Call(

View file

@ -8,7 +8,7 @@ homepage = "https://github.com/pyo3/pyo3"
repository = "https://github.com/pyo3/pyo3"
categories = ["api-bindings", "development-tools::ffi"]
license = "Apache-2.0"
edition = "2018"
edition = "2021"
# Note: we use default-features = false for proc-macro related crates
# not to depend on proc-macro itself.

View file

@ -416,7 +416,7 @@ impl ContainerOptions {
}
ContainerPyO3Attribute::ItemAll(kw) => {
ensure_spanned!(
matches!(options.from_item_all, None),
options.from_item_all.is_none(),
kw.span() => "`from_item_all` may only be provided once"
);
options.from_item_all = Some(kw);
@ -608,7 +608,7 @@ pub fn build_derive_from_pyobject(tokens: &DeriveInput) -> Result<TokenStream> {
use #krate as _pyo3;
#[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> {
#derives
}

View file

@ -8,7 +8,7 @@ homepage = "https://github.com/pyo3/pyo3"
repository = "https://github.com/pyo3/pyo3"
categories = ["api-bindings", "development-tools::ffi"]
license = "Apache-2.0"
edition = "2018"
edition = "2021"
[lib]
proc-macro = true

View file

@ -3,7 +3,7 @@ authors = ["PyO3 Authors"]
name = "pyo3-pytests"
version = "0.1.0"
description = "Python-based tests for PyO3"
edition = "2018"
edition = "2021"
publish = false
[dependencies]

View file

@ -16,6 +16,7 @@ impl EmptyClass {
/// This is for demonstrating how to return a value from __next__
#[pyclass]
#[derive(Default)]
struct PyClassIter {
count: usize,
}
@ -24,7 +25,7 @@ struct PyClassIter {
impl PyClassIter {
#[new]
pub fn new() -> Self {
PyClassIter { count: 0 }
Default::default()
}
fn __next__(&mut self) -> IterNextOutput<usize, &'static str> {

View file

@ -139,7 +139,7 @@
//! [package]
//! name = "string-sum"
//! version = "0.1.0"
//! edition = "2018"
//! edition = "2021"
//!
//! [lib]
//! name = "string_sum"

View file

@ -499,7 +499,6 @@ impl<T: PyClass> PyCell<T> {
/// Gets the offset of the dictionary from the start of the struct in bytes.
pub(crate) fn dict_offset() -> ffi::Py_ssize_t {
use memoffset::offset_of;
use std::convert::TryInto;
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.
pub(crate) fn weaklist_offset() -> ffi::Py_ssize_t {
use memoffset::offset_of;
use std::convert::TryInto;
let offset = offset_of!(PyCell<T>, contents) + offset_of!(PyCellContents<T>, weakref);

View file

@ -56,6 +56,6 @@ pub struct Foo4 {
field: i32,
#[pyo3(get, set)]
#[cfg(any(not(FALSE)))]
#[cfg(not(FALSE))]
field: u32,
}

View file

@ -8,21 +8,3 @@ error[E0597]: `local_data` does not live long enough
| ---------------------------------------------------- argument requires that `local_data` is borrowed for `'static`
14 | });
| - `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<()> {
| ++++