Skip to content

Commit 7b7cab1

Browse files
authored
Merge pull request #1928 from mejrs/remove_doc_cfg
Remove doc_cfg attributes
2 parents fd9b0ca + dd0bf81 commit 7b7cab1

33 files changed

+72
-139
lines changed

src/buffer.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![cfg(not(Py_LIMITED_API))]
2-
#![cfg_attr(docsrs, doc(cfg(not(Py_LIMITED_API))))]
32
// Copyright (c) 2017 Daniel Grunwald
43
//
54
// Permission is hereby granted, free of charge, to any person obtaining a copy of this

src/class/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ mod macros;
77

88
pub mod basic;
99
#[cfg(not(Py_LIMITED_API))]
10-
#[cfg_attr(docsrs, doc(cfg(not(Py_LIMITED_API))))]
1110
pub mod buffer;
1211
pub mod context;
1312
pub mod descr;
@@ -24,7 +23,6 @@ pub mod sequence;
2423

2524
pub use self::basic::PyObjectProtocol;
2625
#[cfg(not(Py_LIMITED_API))]
27-
#[cfg_attr(docsrs, doc(cfg(not(Py_LIMITED_API))))]
2826
pub use self::buffer::PyBufferProtocol;
2927
pub use self::context::PyContextProtocol;
3028
pub use self::descr::PyDescrProtocol;

src/conversions/eyre.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![cfg(feature = "eyre")]
2-
#![cfg_attr(docsrs, doc(cfg(feature = "eyre")))]
2+
33
//! A conversion from [eyre]’s [`Report`] type to [`PyErr`].
44
//!
55
//! Use of an error handling library like [eyre] is common in application code and when you just

src/conversions/hashbrown.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![cfg(feature = "hashbrown")]
2-
#![cfg_attr(docsrs, doc(cfg(feature = "hashbrown")))]
32

43
//! Conversions to and from [hashbrown](https://docs.rs/hashbrown/)’s
54
//! `HashMap` and `HashSet`.

src/conversions/indexmap.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![cfg(feature = "indexmap")]
2-
#![cfg_attr(docsrs, doc(cfg(feature = "indexmap")))]
32

43
//! Conversions to and from [indexmap](https://docs.rs/indexmap/)’s
54
//! `IndexMap`.

src/conversions/num_bigint.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
// based on Daniel Grunwald's https://github.com/dgrunwald/rust-cpython
44

55
#![cfg(all(feature = "num-bigint", not(any(Py_LIMITED_API, PyPy))))]
6-
#![cfg_attr(
7-
docsrs,
8-
doc(cfg(all(feature = "num-bigint", not(any(Py_LIMITED_API, PyPy)))))
9-
)]
10-
116
//! Conversions to and from [num-bigint](https://docs.rs/num-bigint)’s [`BigInt`] and [`BigUint`] types.
127
//!
138
//! This is useful for converting Python integers when they may not fit in Rust's built-in integer types.
@@ -85,6 +80,7 @@ unsafe fn extract(ob: &PyLong, buffer: &mut [c_uchar], is_signed: c_int) -> PyRe
8580

8681
macro_rules! bigint_conversion {
8782
($rust_ty: ty, $is_signed: expr, $to_bytes: path, $from_bytes: path) => {
83+
#[cfg_attr(docsrs, doc(cfg(feature = "num-bigint")))]
8884
impl ToPyObject for $rust_ty {
8985
fn to_object(&self, py: Python) -> PyObject {
9086
unsafe {
@@ -99,11 +95,15 @@ macro_rules! bigint_conversion {
9995
}
10096
}
10197
}
98+
99+
#[cfg_attr(docsrs, doc(cfg(feature = "num-bigint")))]
102100
impl IntoPy<PyObject> for $rust_ty {
103101
fn into_py(self, py: Python) -> PyObject {
104102
self.to_object(py)
105103
}
106104
}
105+
106+
#[cfg_attr(docsrs, doc(cfg(feature = "num-bigint")))]
107107
impl<'source> FromPyObject<'source> for $rust_ty {
108108
fn extract(ob: &'source PyAny) -> PyResult<$rust_ty> {
109109
let py = ob.py();

src/conversions/num_complex.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![cfg(feature = "num-complex")]
2-
#![cfg_attr(docsrs, doc(cfg(feature = "num-complex")))]
2+
33
//! Conversions to and from [num-complex](https://docs.rs/num-complex)’
44
//! [`Complex`]`<`[`f32`]`>` and [`Complex`]`<`[`f64`]`>`.
55
//!
@@ -117,12 +117,15 @@ impl PyComplex {
117117

118118
macro_rules! complex_conversion {
119119
($float: ty) => {
120+
#[cfg_attr(docsrs, doc(cfg(feature = "num-complex")))]
120121
impl ToPyObject for Complex<$float> {
121122
#[inline]
122123
fn to_object(&self, py: Python) -> PyObject {
123124
crate::IntoPy::<PyObject>::into_py(self.to_owned(), py)
124125
}
125126
}
127+
128+
#[cfg_attr(docsrs, doc(cfg(feature = "num-complex")))]
126129
impl crate::IntoPy<PyObject> for Complex<$float> {
127130
fn into_py(self, py: Python) -> PyObject {
128131
unsafe {
@@ -132,10 +135,12 @@ macro_rules! complex_conversion {
132135
}
133136
}
134137
}
135-
#[cfg(not(any(Py_LIMITED_API, PyPy)))]
138+
139+
#[cfg_attr(docsrs, doc(cfg(feature = "num-complex")))]
136140
#[allow(clippy::float_cmp)] // The comparison is for an error value
137141
impl<'source> FromPyObject<'source> for Complex<$float> {
138142
fn extract(obj: &'source PyAny) -> PyResult<Complex<$float>> {
143+
#[cfg(not(any(Py_LIMITED_API, PyPy)))]
139144
unsafe {
140145
let val = ffi::PyComplex_AsCComplex(obj.as_ptr());
141146
if val.real == -1.0 && PyErr::occurred(obj.py()) {
@@ -144,12 +149,8 @@ macro_rules! complex_conversion {
144149
Ok(Complex::new(val.real as $float, val.imag as $float))
145150
}
146151
}
147-
}
148-
}
149-
#[cfg(any(Py_LIMITED_API, PyPy))]
150-
#[allow(clippy::float_cmp)] // The comparison is for an error value
151-
impl<'source> FromPyObject<'source> for Complex<$float> {
152-
fn extract(obj: &'source PyAny) -> PyResult<Complex<$float>> {
152+
153+
#[cfg(any(Py_LIMITED_API, PyPy))]
153154
unsafe {
154155
let ptr = obj.as_ptr();
155156
let real = ffi::PyComplex_RealAsDouble(ptr);

src/conversions/serde.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![cfg_attr(docsrs, doc(cfg(feature = "serde")))]
21
#![cfg(feature = "serde")]
32

43
//! Enables (de)serialization of [`Py`]`<T>` objects via [serde](https://docs.rs/serde).

src/exceptions.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,22 @@ macro_rules! impl_native_exception (
225225
)
226226
);
227227

228+
#[cfg(windows)]
229+
macro_rules! impl_windows_native_exception (
230+
($name:ident, $exc_name:ident, $doc:expr, $layout:path) => (
231+
#[cfg(windows)]
232+
#[doc = $doc]
233+
#[allow(clippy::upper_case_acronyms)]
234+
pub struct $name($crate::PyAny);
235+
236+
$crate::impl_exception_boilerplate!($name);
237+
$crate::pyobject_native_type!($name, $layout, *($crate::ffi::$exc_name as *mut $crate::ffi::PyTypeObject));
238+
);
239+
($name:ident, $exc_name:ident, $doc:expr) => (
240+
impl_windows_native_exception!($name, $exc_name, $doc, $crate::ffi::PyBaseExceptionObject);
241+
)
242+
);
243+
228244
macro_rules! native_doc(
229245
($name: literal, $alt: literal) => (
230246
concat!(
@@ -516,8 +532,9 @@ impl_native_exception!(
516532
native_doc!("EnvironmentError")
517533
);
518534
impl_native_exception!(PyIOError, PyExc_IOError, native_doc!("IOError"));
535+
519536
#[cfg(windows)]
520-
impl_native_exception!(
537+
impl_windows_native_exception!(
521538
PyWindowsError,
522539
PyExc_WindowsError,
523540
native_doc!("WindowsError")

src/ffi/abstract_.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ extern "C" {
113113
#[cfg_attr(PyPy, link_name = "PyPyIter_Next")]
114114
pub fn PyIter_Next(arg1: *mut PyObject) -> *mut PyObject;
115115
#[cfg(all(not(PyPy), Py_3_10))]
116-
#[cfg_attr(docsrs, doc(cfg(all(not(PyPy), Py_3_10))))]
117116
pub fn PyIter_Send(iter: *mut PyObject, arg: *mut PyObject, presult: *mut *mut PyObject);
118117

119118
#[cfg_attr(PyPy, link_name = "PyPyNumber_Check")]

src/ffi/cpython/pystate.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,14 @@ extern "C" {
4343
// skipped _PyThread_CurrentExceptions
4444

4545
#[cfg(not(PyPy))]
46-
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
4746
pub fn PyInterpreterState_Main() -> *mut PyInterpreterState;
4847
#[cfg_attr(PyPy, link_name = "PyPyInterpreterState_Head")]
4948
pub fn PyInterpreterState_Head() -> *mut PyInterpreterState;
5049
#[cfg_attr(PyPy, link_name = "PyPyInterpreterState_Next")]
5150
pub fn PyInterpreterState_Next(interp: *mut PyInterpreterState) -> *mut PyInterpreterState;
5251
#[cfg(not(PyPy))]
53-
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
5452
pub fn PyInterpreterState_ThreadHead(interp: *mut PyInterpreterState) -> *mut PyThreadState;
5553
#[cfg(not(PyPy))]
56-
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
5754
pub fn PyThreadState_Next(tstate: *mut PyThreadState) -> *mut PyThreadState;
5855

5956
#[cfg(py_sys_config = "WITH_THREAD")]
@@ -62,7 +59,6 @@ extern "C" {
6259
}
6360

6461
#[cfg(Py_3_9)]
65-
#[cfg_attr(docsrs, doc(cfg(Py_3_9)))]
6662
pub type _PyFrameEvalFunction = extern "C" fn(
6763
*mut crate::ffi::PyThreadState,
6864
*mut crate::ffi::PyFrameObject,
@@ -72,13 +68,11 @@ pub type _PyFrameEvalFunction = extern "C" fn(
7268
#[cfg(Py_3_9)]
7369
extern "C" {
7470
/// Get the frame evaluation function.
75-
#[cfg_attr(docsrs, doc(cfg(Py_3_9)))]
7671
pub fn _PyInterpreterState_GetEvalFrameFunc(
7772
interp: *mut PyInterpreterState,
7873
) -> _PyFrameEvalFunction;
7974

8075
///Set the frame evaluation function.
81-
#[cfg_attr(docsrs, doc(cfg(Py_3_9)))]
8276
pub fn _PyInterpreterState_SetEvalFrameFunc(
8377
interp: *mut PyInterpreterState,
8478
eval_frame: _PyFrameEvalFunction,

src/ffi/cpython/unicodeobject.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub struct PyASCIIObject {
5252
///
5353
/// In addition, they are disabled on big-endian architectures to restrict this to most "common"
5454
/// platforms, which are at least tested on CI and appear to be sound.
55-
#[cfg(not(target_endian = "big"))]
55+
#[cfg(target_endian = "little")]
5656
impl PyASCIIObject {
5757
#[inline]
5858
pub unsafe fn interned(&self) -> c_uint {
@@ -117,7 +117,7 @@ pub const SSTATE_INTERNED_MORTAL: c_uint = 1;
117117
pub const SSTATE_INTERNED_IMMORTAL: c_uint = 2;
118118

119119
#[inline]
120-
#[cfg(not(target_endian = "big"))]
120+
#[cfg(target_endian = "little")]
121121
pub unsafe fn PyUnicode_IS_ASCII(op: *mut PyObject) -> c_uint {
122122
debug_assert!(crate::ffi::PyUnicode_Check(op) != 0);
123123
debug_assert!(PyUnicode_IS_READY(op) != 0);
@@ -126,13 +126,13 @@ pub unsafe fn PyUnicode_IS_ASCII(op: *mut PyObject) -> c_uint {
126126
}
127127

128128
#[inline]
129-
#[cfg(not(target_endian = "big"))]
129+
#[cfg(target_endian = "little")]
130130
pub unsafe fn PyUnicode_IS_COMPACT(op: *mut PyObject) -> c_uint {
131131
(*(op as *mut PyASCIIObject)).compact()
132132
}
133133

134134
#[inline]
135-
#[cfg(not(target_endian = "big"))]
135+
#[cfg(target_endian = "little")]
136136
pub unsafe fn PyUnicode_IS_COMPACT_ASCII(op: *mut PyObject) -> c_uint {
137137
if (*(op as *mut PyASCIIObject)).ascii() != 0 && PyUnicode_IS_COMPACT(op) != 0 {
138138
1
@@ -150,25 +150,25 @@ pub const PyUnicode_2BYTE_KIND: c_uint = 2;
150150
pub const PyUnicode_4BYTE_KIND: c_uint = 4;
151151

152152
#[inline]
153-
#[cfg(not(target_endian = "big"))]
153+
#[cfg(target_endian = "little")]
154154
pub unsafe fn PyUnicode_1BYTE_DATA(op: *mut PyObject) -> *mut Py_UCS1 {
155155
PyUnicode_DATA(op) as *mut Py_UCS1
156156
}
157157

158158
#[inline]
159-
#[cfg(not(target_endian = "big"))]
159+
#[cfg(target_endian = "little")]
160160
pub unsafe fn PyUnicode_2BYTE_DATA(op: *mut PyObject) -> *mut Py_UCS2 {
161161
PyUnicode_DATA(op) as *mut Py_UCS2
162162
}
163163

164164
#[inline]
165-
#[cfg(not(target_endian = "big"))]
165+
#[cfg(target_endian = "little")]
166166
pub unsafe fn PyUnicode_4BYTE_DATA(op: *mut PyObject) -> *mut Py_UCS4 {
167167
PyUnicode_DATA(op) as *mut Py_UCS4
168168
}
169169

170170
#[inline]
171-
#[cfg(not(target_endian = "big"))]
171+
#[cfg(target_endian = "little")]
172172
pub unsafe fn PyUnicode_KIND(op: *mut PyObject) -> c_uint {
173173
debug_assert!(crate::ffi::PyUnicode_Check(op) != 0);
174174
debug_assert!(PyUnicode_IS_READY(op) != 0);
@@ -177,7 +177,7 @@ pub unsafe fn PyUnicode_KIND(op: *mut PyObject) -> c_uint {
177177
}
178178

179179
#[inline]
180-
#[cfg(not(target_endian = "big"))]
180+
#[cfg(target_endian = "little")]
181181
pub unsafe fn _PyUnicode_COMPACT_DATA(op: *mut PyObject) -> *mut c_void {
182182
if PyUnicode_IS_ASCII(op) != 0 {
183183
(op as *mut PyASCIIObject).offset(1) as *mut c_void
@@ -187,15 +187,15 @@ pub unsafe fn _PyUnicode_COMPACT_DATA(op: *mut PyObject) -> *mut c_void {
187187
}
188188

189189
#[inline]
190-
#[cfg(not(target_endian = "big"))]
190+
#[cfg(target_endian = "little")]
191191
pub unsafe fn _PyUnicode_NONCOMPACT_DATA(op: *mut PyObject) -> *mut c_void {
192192
debug_assert!(!(*(op as *mut PyUnicodeObject)).data.any.is_null());
193193

194194
(*(op as *mut PyUnicodeObject)).data.any
195195
}
196196

197197
#[inline]
198-
#[cfg(not(target_endian = "big"))]
198+
#[cfg(target_endian = "little")]
199199
pub unsafe fn PyUnicode_DATA(op: *mut PyObject) -> *mut c_void {
200200
debug_assert!(crate::ffi::PyUnicode_Check(op) != 0);
201201

@@ -211,7 +211,7 @@ pub unsafe fn PyUnicode_DATA(op: *mut PyObject) -> *mut c_void {
211211
// skipped PyUnicode_READ_CHAR
212212

213213
#[inline]
214-
#[cfg(not(target_endian = "big"))]
214+
#[cfg(target_endian = "little")]
215215
pub unsafe fn PyUnicode_GET_LENGTH(op: *mut PyObject) -> Py_ssize_t {
216216
debug_assert!(crate::ffi::PyUnicode_Check(op) != 0);
217217
debug_assert!(PyUnicode_IS_READY(op) != 0);
@@ -220,15 +220,15 @@ pub unsafe fn PyUnicode_GET_LENGTH(op: *mut PyObject) -> Py_ssize_t {
220220
}
221221

222222
#[inline]
223-
#[cfg(not(target_endian = "big"))]
223+
#[cfg(target_endian = "little")]
224224
pub unsafe fn PyUnicode_IS_READY(op: *mut PyObject) -> c_uint {
225225
(*(op as *mut PyASCIIObject)).ready()
226226
}
227227

228228
#[cfg(not(Py_3_12))]
229229
#[cfg_attr(Py_3_10, deprecated(note = "Python 3.10"))]
230230
#[inline]
231-
#[cfg(not(target_endian = "big"))]
231+
#[cfg(target_endian = "little")]
232232
pub unsafe fn PyUnicode_READY(op: *mut PyObject) -> c_int {
233233
debug_assert!(crate::ffi::PyUnicode_Check(op) != 0);
234234

@@ -252,7 +252,6 @@ extern "C" {
252252
// skipped _PyUnicode_Copy
253253

254254
#[cfg(not(PyPy))]
255-
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
256255
pub fn PyUnicode_CopyCharacters(
257256
to: *mut PyObject,
258257
to_start: Py_ssize_t,
@@ -264,7 +263,6 @@ extern "C" {
264263
// skipped _PyUnicode_FastCopyCharacters
265264

266265
#[cfg(not(PyPy))]
267-
#[cfg_attr(docsrs, doc(cfg(not(PyPy))))]
268266
pub fn PyUnicode_Fill(
269267
unicode: *mut PyObject,
270268
start: Py_ssize_t,
@@ -489,7 +487,7 @@ extern "C" {
489487
// skipped _PyUnicode_ScanIdentifier
490488

491489
#[cfg(test)]
492-
#[cfg(not(target_endian = "big"))]
490+
#[cfg(target_endian = "little")]
493491
mod tests {
494492
use super::*;
495493
use crate::types::PyString;

src/ffi/modsupport.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ extern "C" {
5454
// skipped non-limited _PyArg_Fini
5555

5656
#[cfg(Py_3_10)]
57-
#[cfg_attr(docsrs, doc(cfg(Py_3_10)))]
5857
pub fn PyModule_AddObjectRef(
5958
module: *mut PyObject,
6059
name: *const c_char,

0 commit comments

Comments
 (0)