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")]

0 commit comments

Comments
 (0)