Skip to content

Commit

Permalink
Merge #3209
Browse files Browse the repository at this point in the history
3209: Remove the conditional compilation flags which are made redundant  by the MSRV bump r=davidhewitt a=adamreichold



Co-authored-by: Adam Reichold <[email protected]>
  • Loading branch information
bors[bot] and adamreichold authored Jun 5, 2023
2 parents dbf7b23 + edf50ee commit e1f028f
Show file tree
Hide file tree
Showing 42 changed files with 247 additions and 443 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
with:
toolchain: 1.56.0
targets: x86_64-unknown-linux-gnu
components: clippy,rust-src
components: rust-src
- uses: actions/setup-python@v4
with:
architecture: "x64"
Expand Down
4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ chrono = { version = "0.4" }
criterion = "0.3.5"
# Required for "and $N others" normalization
trybuild = ">=1.0.70"
rustversion = "1.0"
# 1.0.0 requires Rust 1.50
proptest = { version = "0.10.1", default-features = false, features = ["std"] }
proptest = { version = "1.0", default-features = false, features = ["std"] }
send_wrapper = "0.6"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.61"
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn configure_pyo3() -> Result<()> {

ensure_auto_initialize_ok(interpreter_config)?;

// Emit cfgs like `addr_of` and `min_const_generics`
// Emit cfgs like `thread_local_const_init`
print_feature_cfgs();

Ok(())
Expand Down
1 change: 1 addition & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ def set_minimal_package_versions(session: nox.Session):
"rayon": "1.6.1",
"rayon-core": "1.10.2",
"regex": "1.7.3",
"proptest": "1.0.0",
}

# run cargo update first to ensure that everything is at highest
Expand Down
20 changes: 0 additions & 20 deletions pyo3-build-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,30 +142,10 @@ pub fn print_feature_cfgs() {

let rustc_minor_version = rustc_minor_version().unwrap_or(0);

// Enable use of const generics on Rust 1.51 and greater
if rustc_minor_version >= 51 {
println!("cargo:rustc-cfg=min_const_generics");
}

// Enable use of std::ptr::addr_of! on Rust 1.51 and greater
if rustc_minor_version >= 51 {
println!("cargo:rustc-cfg=addr_of");
}

// Enable use of Option::insert on Rust 1.53 and greater
if rustc_minor_version >= 53 {
println!("cargo:rustc-cfg=option_insert");
}

// Enable use of const initializer for thread_local! on Rust 1.59 and greater
if rustc_minor_version >= 59 {
println!("cargo:rustc-cfg=thread_local_const_init");
}

// Enable use of `#[cfg(panic = "...")]` on Rust 1.60 and greater
if rustc_minor_version >= 60 {
println!("cargo:rustc-cfg=panic_unwind");
}
}

/// Private exports used in PyO3's build.rs
Expand Down
2 changes: 1 addition & 1 deletion pyo3-ffi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fn configure_pyo3() -> Result<()> {
println!("{}", line);
}

// Emit cfgs like `addr_of` and `min_const_generics`
// Emit cfgs like `thread_local_const_init`
print_feature_cfgs();

Ok(())
Expand Down
7 changes: 4 additions & 3 deletions pyo3-ffi/src/boolobject.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::longobject::PyLongObject;
use crate::object::*;
use std::os::raw::{c_int, c_long};
use std::ptr::addr_of_mut;

#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
Expand All @@ -10,7 +11,7 @@ extern "C" {

#[inline]
pub unsafe fn PyBool_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyBool_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyBool_Type)) as c_int
}

#[cfg_attr(windows, link(name = "pythonXY"))]
Expand All @@ -23,12 +24,12 @@ extern "C" {

#[inline]
pub unsafe fn Py_False() -> *mut PyObject {
addr_of_mut_shim!(_Py_FalseStruct) as *mut PyLongObject as *mut PyObject
addr_of_mut!(_Py_FalseStruct) as *mut PyLongObject as *mut PyObject
}

#[inline]
pub unsafe fn Py_True() -> *mut PyObject {
addr_of_mut_shim!(_Py_TrueStruct) as *mut PyLongObject as *mut PyObject
addr_of_mut!(_Py_TrueStruct) as *mut PyLongObject as *mut PyObject
}

#[inline]
Expand Down
5 changes: 3 additions & 2 deletions pyo3-ffi/src/bytearrayobject.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::object::*;
use crate::pyport::Py_ssize_t;
use std::os::raw::{c_char, c_int};
use std::ptr::addr_of_mut;

#[cfg(not(any(PyPy, Py_LIMITED_API)))]
#[repr(C)]
Expand Down Expand Up @@ -29,12 +30,12 @@ extern "C" {

#[inline]
pub unsafe fn PyByteArray_Check(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, addr_of_mut_shim!(PyByteArray_Type))
PyObject_TypeCheck(op, addr_of_mut!(PyByteArray_Type))
}

#[inline]
pub unsafe fn PyByteArray_CheckExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyByteArray_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyByteArray_Type)) as c_int
}

extern "C" {
Expand Down
3 changes: 2 additions & 1 deletion pyo3-ffi/src/bytesobject.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::object::*;
use crate::pyport::Py_ssize_t;
use std::os::raw::{c_char, c_int};
use std::ptr::addr_of_mut;

#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
Expand All @@ -16,7 +17,7 @@ pub unsafe fn PyBytes_Check(op: *mut PyObject) -> c_int {

#[inline]
pub unsafe fn PyBytes_CheckExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyBytes_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyBytes_Type)) as c_int
}

extern "C" {
Expand Down
5 changes: 3 additions & 2 deletions pyo3-ffi/src/complexobject.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::object::*;
use std::os::raw::{c_double, c_int};
use std::ptr::addr_of_mut;

#[repr(C)]
#[derive(Copy, Clone)]
Expand Down Expand Up @@ -40,12 +41,12 @@ extern "C" {

#[inline]
pub unsafe fn PyComplex_Check(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, addr_of_mut_shim!(PyComplex_Type))
PyObject_TypeCheck(op, addr_of_mut!(PyComplex_Type))
}

#[inline]
pub unsafe fn PyComplex_CheckExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyComplex_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyComplex_Type)) as c_int
}

extern "C" {
Expand Down
7 changes: 4 additions & 3 deletions pyo3-ffi/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::object::{PyObject, PyTypeObject, Py_TYPE};
use std::os::raw::{c_char, c_int};
use std::ptr::addr_of_mut;

extern "C" {
pub static mut PyContext_Type: PyTypeObject;
Expand All @@ -12,17 +13,17 @@ extern "C" {

#[inline]
pub unsafe fn PyContext_CheckExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyContext_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyContext_Type)) as c_int
}

#[inline]
pub unsafe fn PyContextVar_CheckExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyContextVar_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyContextVar_Type)) as c_int
}

#[inline]
pub unsafe fn PyContextToken_CheckExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyContextToken_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyContextToken_Type)) as c_int
}

extern "C" {
Expand Down
4 changes: 3 additions & 1 deletion pyo3-ffi/src/cpython/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use crate::pyport::Py_ssize_t;

#[allow(unused_imports)]
use std::os::raw::{c_char, c_int, c_uchar, c_void};
#[cfg(not(PyPy))]
use std::ptr::addr_of_mut;

// skipped _Py_CODEUNIT
// skipped _Py_OPCODE
Expand Down Expand Up @@ -159,7 +161,7 @@ extern "C" {
#[inline]
#[cfg(not(PyPy))]
pub unsafe fn PyCode_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyCode_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyCode_Type)) as c_int
}

#[inline]
Expand Down
3 changes: 2 additions & 1 deletion pyo3-ffi/src/cpython/frameobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::pystate::PyThreadState;
#[cfg(not(any(PyPy, Py_3_11)))]
use std::os::raw::c_char;
use std::os::raw::c_int;
use std::ptr::addr_of_mut;

#[cfg(not(any(PyPy, Py_3_11)))]
pub type PyFrameState = c_char;
Expand Down Expand Up @@ -64,7 +65,7 @@ extern "C" {

#[inline]
pub unsafe fn PyFrame_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyFrame_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyFrame_Type)) as c_int
}

extern "C" {
Expand Down
4 changes: 3 additions & 1 deletion pyo3-ffi/src/cpython/funcobject.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use std::os::raw::c_int;
#[cfg(not(all(PyPy, not(Py_3_8))))]
use std::ptr::addr_of_mut;

use crate::PyObject;

Expand Down Expand Up @@ -61,7 +63,7 @@ extern "C" {
#[cfg(not(all(PyPy, not(Py_3_8))))]
#[inline]
pub unsafe fn PyFunction_Check(op: *mut PyObject) -> c_int {
(crate::Py_TYPE(op) == addr_of_mut_shim!(PyFunction_Type)) as c_int
(crate::Py_TYPE(op) == addr_of_mut!(PyFunction_Type)) as c_int
}

extern "C" {
Expand Down
9 changes: 5 additions & 4 deletions pyo3-ffi/src/cpython/genobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::_PyErr_StackItem;
#[cfg(Py_3_11)]
use std::os::raw::c_char;
use std::os::raw::c_int;
use std::ptr::addr_of_mut;

#[cfg(not(PyPy))]
#[repr(C)]
Expand Down Expand Up @@ -41,12 +42,12 @@ extern "C" {

#[inline]
pub unsafe fn PyGen_Check(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, addr_of_mut_shim!(PyGen_Type))
PyObject_TypeCheck(op, addr_of_mut!(PyGen_Type))
}

#[inline]
pub unsafe fn PyGen_CheckExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyGen_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyGen_Type)) as c_int
}

extern "C" {
Expand All @@ -71,7 +72,7 @@ extern "C" {

#[inline]
pub unsafe fn PyCoro_CheckExact(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, addr_of_mut_shim!(PyCoro_Type))
PyObject_TypeCheck(op, addr_of_mut!(PyCoro_Type))
}

// skipped _PyCoro_GetAwaitableIter
Expand All @@ -91,7 +92,7 @@ extern "C" {

#[inline]
pub unsafe fn PyAsyncGen_CheckExact(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, addr_of_mut_shim!(PyAsyncGen_Type))
PyObject_TypeCheck(op, addr_of_mut!(PyAsyncGen_Type))
}

// skipped _PyAsyncGenValueWrapperNew
5 changes: 3 additions & 2 deletions pyo3-ffi/src/cpython/methodobject.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::object::*;
use crate::{PyCFunctionObject, PyMethodDefPointer, METH_METHOD, METH_STATIC};
use std::os::raw::c_int;
use std::ptr::addr_of_mut;

pub struct PyCMethodObject {
pub func: PyCFunctionObject,
Expand All @@ -14,12 +15,12 @@ extern "C" {

#[inline]
pub unsafe fn PyCMethod_CheckExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyCMethod_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyCMethod_Type)) as c_int
}

#[inline]
pub unsafe fn PyCMethod_Check(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, addr_of_mut_shim!(PyCMethod_Type))
PyObject_TypeCheck(op, addr_of_mut!(PyCMethod_Type))
}

#[inline]
Expand Down
9 changes: 5 additions & 4 deletions pyo3-ffi/src/dictobject.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::object::*;
use crate::pyport::Py_ssize_t;
use std::os::raw::{c_char, c_int};
use std::ptr::addr_of_mut;

#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
Expand All @@ -15,7 +16,7 @@ pub unsafe fn PyDict_Check(op: *mut PyObject) -> c_int {

#[inline]
pub unsafe fn PyDict_CheckExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyDict_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyDict_Type)) as c_int
}

extern "C" {
Expand Down Expand Up @@ -76,17 +77,17 @@ extern "C" {

#[inline]
pub unsafe fn PyDictKeys_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyDictKeys_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyDictKeys_Type)) as c_int
}

#[inline]
pub unsafe fn PyDictValues_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyDictValues_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyDictValues_Type)) as c_int
}

#[inline]
pub unsafe fn PyDictItems_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyDictItems_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyDictItems_Type)) as c_int
}

#[inline]
Expand Down
5 changes: 3 additions & 2 deletions pyo3-ffi/src/floatobject.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::object::*;
use std::os::raw::{c_double, c_int};
use std::ptr::addr_of_mut;

#[cfg(Py_LIMITED_API)]
// TODO: remove (see https://github.com/PyO3/pyo3/pull/1341#issuecomment-751515985)
Expand All @@ -20,12 +21,12 @@ extern "C" {

#[inline]
pub unsafe fn PyFloat_Check(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, addr_of_mut_shim!(PyFloat_Type))
PyObject_TypeCheck(op, addr_of_mut!(PyFloat_Type))
}

#[inline]
pub unsafe fn PyFloat_CheckExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyFloat_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyFloat_Type)) as c_int
}

// skipped Py_RETURN_NAN
Expand Down
5 changes: 3 additions & 2 deletions pyo3-ffi/src/iterobject.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::object::*;
use std::os::raw::c_int;
use std::ptr::addr_of_mut;

#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
Expand All @@ -9,7 +10,7 @@ extern "C" {

#[inline]
pub unsafe fn PySeqIter_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PySeqIter_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PySeqIter_Type)) as c_int
}

extern "C" {
Expand All @@ -19,7 +20,7 @@ extern "C" {

#[inline]
pub unsafe fn PyCallIter_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyCallIter_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyCallIter_Type)) as c_int
}

extern "C" {
Expand Down
Loading

0 comments on commit e1f028f

Please sign in to comment.