Skip to content

Commit 3baa398

Browse files
committed
Merge #610: Use doc_auto_cfg
b6d0c3b Use doc_auto_cfg (Tobin C. Harding) Pull request description: We can build docs using feature markers by using `doc_auto_cfg` now, no need to manually call the `doc` attribute. ACKs for top commit: Kixunil: ACK b6d0c3b apoelstra: ACK b6d0c3b Tree-SHA512: ab95968dcb664543d6e1ab5f00866fda1ac2862b86793bda0e19cdc354fbf22471c46a044ceabe8cba2d2fc32671604219fdcb5e96107e14096d20d2aceab0f3
2 parents be2999a + b6d0c3b commit 3baa398

File tree

12 files changed

+4
-54
lines changed

12 files changed

+4
-54
lines changed

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ keywords = [ "crypto", "ECDSA", "secp256k1", "libsecp256k1", "bitcoin" ]
1212
readme = "README.md"
1313
edition = "2018"
1414

15-
# Should make docs.rs show all functions, even those behind non-default features
1615
[package.metadata.docs.rs]
17-
features = [ "rand", "rand-std", "serde", "bitcoin_hashes", "recovery", "global-context" ]
16+
all-features = true
1817
rustdoc-args = ["--cfg", "docsrs"]
1918

2019
[features]

secp256k1-sys/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ build = "build.rs"
1515
links = "rustsecp256k1_v0_8_1"
1616
edition = "2018"
1717

18-
# Should make docs.rs show all functions, even those behind non-default features
1918
[package.metadata.docs.rs]
20-
features = [ "recovery", "lowmemory" ]
19+
all-features = true
2120
rustdoc-args = ["--cfg", "docsrs"]
2221

2322
[build-dependencies]

secp256k1-sys/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#![deny(non_upper_case_globals, non_camel_case_types, non_snake_case, unused_mut)]
2121

2222
#![cfg_attr(all(not(test), not(feature = "std")), no_std)]
23-
#![cfg_attr(docsrs, feature(doc_cfg))]
23+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2424

2525
#[cfg(any(test, feature = "std"))]
2626
extern crate core;

src/context.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ use core::mem::ManuallyDrop;
33
use core::ptr::NonNull;
44

55
#[cfg(feature = "alloc")]
6-
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
76
pub use self::alloc_only::*;
87
use crate::ffi::types::{c_uint, c_void, AlignedType};
98
use crate::ffi::{self, CPtr};
109
use crate::{Error, Secp256k1};
1110

1211
#[cfg(all(feature = "global-context", feature = "std"))]
13-
#[cfg_attr(docsrs, doc(cfg(all(feature = "global-context", feature = "std"))))]
1412
/// Module implementing a singleton pattern for a global `Secp256k1` context.
1513
pub mod global {
1614

@@ -114,7 +112,6 @@ mod private {
114112
}
115113

116114
#[cfg(feature = "alloc")]
117-
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
118115
mod alloc_only {
119116
use core::marker::PhantomData;
120117
use core::ptr::NonNull;

src/ecdh.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ unsafe extern "C" fn c_callback(
168168
}
169169

170170
#[cfg(feature = "serde")]
171-
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
172171
impl ::serde::Serialize for SharedSecret {
173172
fn serialize<S: ::serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
174173
if s.is_human_readable() {
@@ -181,7 +180,6 @@ impl ::serde::Serialize for SharedSecret {
181180
}
182181

183182
#[cfg(feature = "serde")]
184-
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
185183
impl<'de> ::serde::Deserialize<'de> for SharedSecret {
186184
fn deserialize<D: ::serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
187185
if d.is_human_readable() {

src/ecdsa/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ pub mod serialized_signature;
88
use core::{fmt, ptr, str};
99

1010
#[cfg(feature = "recovery")]
11-
#[cfg_attr(docsrs, doc(cfg(feature = "recovery")))]
1211
pub use self::recovery::{RecoverableSignature, RecoveryId};
1312
pub use self::serialized_signature::SerializedSignature;
1413
use crate::ffi::CPtr;
@@ -193,7 +192,6 @@ impl Signature {
193192
/// The signature must be normalized or verification will fail (see [`Signature::normalize_s`]).
194193
#[inline]
195194
#[cfg(feature = "global-context")]
196-
#[cfg_attr(docsrs, doc(cfg(feature = "global-context")))]
197195
pub fn verify(&self, msg: &Message, pk: &PublicKey) -> Result<(), Error> {
198196
SECP256K1.verify_ecdsa(msg, self, pk)
199197
}
@@ -214,7 +212,6 @@ impl From<ffi::Signature> for Signature {
214212
}
215213

216214
#[cfg(feature = "serde")]
217-
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
218215
impl serde::Serialize for Signature {
219216
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
220217
if s.is_human_readable() {
@@ -226,7 +223,6 @@ impl serde::Serialize for Signature {
226223
}
227224

228225
#[cfg(feature = "serde")]
229-
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
230226
impl<'de> serde::Deserialize<'de> for Signature {
231227
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
232228
if d.is_human_readable() {

src/ecdsa/recovery.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ impl RecoverableSignature {
126126
/// verify-capable context.
127127
#[inline]
128128
#[cfg(feature = "global-context")]
129-
#[cfg_attr(docsrs, doc(cfg(feature = "global-context")))]
130129
pub fn recover(&self, msg: &Message) -> Result<key::PublicKey, Error> {
131130
crate::SECP256K1.recover_ecdsa(msg, self)
132131
}

src/key.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ impl SecretKey {
198198
/// ```
199199
#[inline]
200200
#[cfg(feature = "rand")]
201-
#[cfg_attr(docsrs, doc(cfg(feature = "rand")))]
202201
pub fn new<R: rand::Rng + ?Sized>(rng: &mut R) -> SecretKey {
203202
let mut data = crate::random_32_bytes(rng);
204203
unsafe {
@@ -286,7 +285,6 @@ impl SecretKey {
286285
/// # }
287286
/// ```
288287
#[cfg(feature = "bitcoin_hashes")]
289-
#[cfg_attr(docsrs, doc(cfg(feature = "bitcoin-hashes")))]
290288
#[inline]
291289
pub fn from_hashed_data<H: ThirtyTwoByteHash + hashes::Hash>(data: &[u8]) -> Self {
292290
<H as hashes::Hash>::hash(data).into()
@@ -355,7 +353,6 @@ impl SecretKey {
355353
/// Constructs an ECDSA signature for `msg` using the global [`SECP256K1`] context.
356354
#[inline]
357355
#[cfg(feature = "global-context")]
358-
#[cfg_attr(docsrs, doc(cfg(feature = "global-context")))]
359356
pub fn sign_ecdsa(&self, msg: Message) -> ecdsa::Signature { SECP256K1.sign_ecdsa(&msg, self) }
360357

361358
/// Returns the [`KeyPair`] for this [`SecretKey`].
@@ -393,7 +390,6 @@ impl<T: ThirtyTwoByteHash> From<T> for SecretKey {
393390
}
394391

395392
#[cfg(feature = "serde")]
396-
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
397393
impl serde::Serialize for SecretKey {
398394
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
399395
if s.is_human_readable() {
@@ -410,7 +406,6 @@ impl serde::Serialize for SecretKey {
410406
}
411407

412408
#[cfg(feature = "serde")]
413-
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
414409
impl<'de> serde::Deserialize<'de> for SecretKey {
415410
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
416411
if d.is_human_readable() {
@@ -469,7 +464,6 @@ impl PublicKey {
469464
/// Creates a new public key from a [`SecretKey`] and the global [`SECP256K1`] context.
470465
#[inline]
471466
#[cfg(feature = "global-context")]
472-
#[cfg_attr(docsrs, doc(cfg(feature = "global-context")))]
473467
pub fn from_secret_key_global(sk: &SecretKey) -> PublicKey {
474468
PublicKey::from_secret_key(SECP256K1, sk)
475469
}
@@ -740,7 +734,6 @@ impl From<ffi::PublicKey> for PublicKey {
740734
}
741735

742736
#[cfg(feature = "serde")]
743-
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
744737
impl serde::Serialize for PublicKey {
745738
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
746739
if s.is_human_readable() {
@@ -757,7 +750,6 @@ impl serde::Serialize for PublicKey {
757750
}
758751

759752
#[cfg(feature = "serde")]
760-
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
761753
impl<'de> serde::Deserialize<'de> for PublicKey {
762754
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<PublicKey, D::Error> {
763755
if d.is_human_readable() {
@@ -877,7 +869,6 @@ impl KeyPair {
877869
/// [`Error::InvalidSecretKey`] if corresponding public key for the provided secret key is not even.
878870
#[inline]
879871
#[cfg(feature = "global-context")]
880-
#[cfg_attr(docsrs, doc(cfg(feature = "global-context")))]
881872
pub fn from_seckey_str_global(s: &str) -> Result<KeyPair, Error> {
882873
KeyPair::from_seckey_str(SECP256K1, s)
883874
}
@@ -895,7 +886,6 @@ impl KeyPair {
895886
/// ```
896887
#[inline]
897888
#[cfg(feature = "rand")]
898-
#[cfg_attr(docsrs, doc(cfg(feature = "rand")))]
899889
pub fn new<R: rand::Rng + ?Sized, C: Signing>(secp: &Secp256k1<C>, rng: &mut R) -> KeyPair {
900890
let mut data = crate::random_32_bytes(rng);
901891
unsafe {
@@ -912,7 +902,6 @@ impl KeyPair {
912902
/// Generates a new random secret key using the global [`SECP256K1`] context.
913903
#[inline]
914904
#[cfg(all(feature = "global-context", feature = "rand"))]
915-
#[cfg_attr(docsrs, doc(cfg(all(feature = "global-context", feature = "rand"))))]
916905
pub fn new_global<R: ::rand::Rng + ?Sized>(rng: &mut R) -> KeyPair {
917906
KeyPair::new(SECP256K1, rng)
918907
}
@@ -989,7 +978,6 @@ impl KeyPair {
989978
/// Constructs an schnorr signature for `msg` using the global [`SECP256K1`] context.
990979
#[inline]
991980
#[cfg(all(feature = "global-context", feature = "rand-std"))]
992-
#[cfg_attr(docsrs, doc(cfg(all(feature = "global-context", feature = "rand-std"))))]
993981
pub fn sign_schnorr(&self, msg: Message) -> schnorr::Signature {
994982
SECP256K1.sign_schnorr(&msg, self)
995983
}
@@ -1044,7 +1032,6 @@ impl str::FromStr for KeyPair {
10441032
}
10451033

10461034
#[cfg(feature = "serde")]
1047-
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
10481035
impl serde::Serialize for KeyPair {
10491036
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
10501037
if s.is_human_readable() {
@@ -1064,7 +1051,6 @@ impl serde::Serialize for KeyPair {
10641051
}
10651052

10661053
#[cfg(feature = "serde")]
1067-
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
10681054
impl<'de> serde::Deserialize<'de> for KeyPair {
10691055
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
10701056
if d.is_human_readable() {
@@ -1439,7 +1425,6 @@ impl fmt::Display for InvalidParityValue {
14391425
}
14401426

14411427
#[cfg(feature = "std")]
1442-
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
14431428
impl std::error::Error for InvalidParityValue {}
14441429

14451430
impl From<InvalidParityValue> for Error {
@@ -1448,7 +1433,6 @@ impl From<InvalidParityValue> for Error {
14481433

14491434
/// The parity is serialized as `u8` - `0` for even, `1` for odd.
14501435
#[cfg(feature = "serde")]
1451-
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
14521436
impl serde::Serialize for Parity {
14531437
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
14541438
s.serialize_u8(self.to_u8())
@@ -1457,7 +1441,6 @@ impl serde::Serialize for Parity {
14571441

14581442
/// The parity is deserialized as `u8` - `0` for even, `1` for odd.
14591443
#[cfg(feature = "serde")]
1460-
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
14611444
impl<'de> serde::Deserialize<'de> for Parity {
14621445
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
14631446
struct Visitor;
@@ -1516,7 +1499,6 @@ impl From<PublicKey> for XOnlyPublicKey {
15161499
}
15171500

15181501
#[cfg(feature = "serde")]
1519-
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
15201502
impl serde::Serialize for XOnlyPublicKey {
15211503
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
15221504
if s.is_human_readable() {
@@ -1532,7 +1514,6 @@ impl serde::Serialize for XOnlyPublicKey {
15321514
}
15331515

15341516
#[cfg(feature = "serde")]
1535-
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
15361517
impl<'de> serde::Deserialize<'de> for XOnlyPublicKey {
15371518
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
15381519
if d.is_human_readable() {

src/lib.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
#![warn(missing_docs, missing_copy_implementations, missing_debug_implementations)]
155155
#![cfg_attr(all(not(test), not(feature = "std")), no_std)]
156156
// Experimental features we need.
157-
#![cfg_attr(docsrs, feature(doc_cfg))]
157+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
158158
#![cfg_attr(bench, feature(test))]
159159

160160
#[cfg(feature = "alloc")]
@@ -184,17 +184,13 @@ use core::ptr::NonNull;
184184
use core::{fmt, mem, str};
185185

186186
#[cfg(feature = "bitcoin_hashes")]
187-
#[cfg_attr(docsrs, doc(cfg(feature = "bitcoin-hashes")))]
188187
pub use bitcoin_hashes as hashes;
189188
#[cfg(feature = "global-context")]
190-
#[cfg_attr(docsrs, doc(cfg(feature = "global-context")))]
191189
pub use context::global::SECP256K1;
192190
#[cfg(feature = "rand")]
193-
#[cfg_attr(docsrs, doc(cfg(feature = "rand")))]
194191
pub use rand;
195192
pub use secp256k1_sys as ffi;
196193
#[cfg(feature = "serde")]
197-
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
198194
pub use serde;
199195

200196
pub use crate::context::*;
@@ -214,19 +210,16 @@ pub trait ThirtyTwoByteHash {
214210
}
215211

216212
#[cfg(feature = "bitcoin_hashes")]
217-
#[cfg_attr(docsrs, doc(cfg(feature = "bitcoin-hashes")))]
218213
impl ThirtyTwoByteHash for hashes::sha256::Hash {
219214
fn into_32(self) -> [u8; 32] { self.to_byte_array() }
220215
}
221216

222217
#[cfg(feature = "bitcoin_hashes")]
223-
#[cfg_attr(docsrs, doc(cfg(feature = "bitcoin-hashes")))]
224218
impl ThirtyTwoByteHash for hashes::sha256d::Hash {
225219
fn into_32(self) -> [u8; 32] { self.to_byte_array() }
226220
}
227221

228222
#[cfg(feature = "bitcoin_hashes")]
229-
#[cfg_attr(docsrs, doc(cfg(feature = "bitcoin-hashes")))]
230223
impl<T: hashes::sha256t::Tag> ThirtyTwoByteHash for hashes::sha256t::Hash<T> {
231224
fn into_32(self) -> [u8; 32] { self.to_byte_array() }
232225
}
@@ -275,7 +268,6 @@ impl Message {
275268
/// # }
276269
/// ```
277270
#[cfg(feature = "bitcoin_hashes")]
278-
#[cfg_attr(docsrs, doc(cfg(feature = "bitcoin-hashes")))]
279271
pub fn from_hashed_data<H: ThirtyTwoByteHash + hashes::Hash>(data: &[u8]) -> Self {
280272
<H as hashes::Hash>::hash(data).into()
281273
}
@@ -349,7 +341,6 @@ impl fmt::Display for Error {
349341
}
350342

351343
#[cfg(feature = "std")]
352-
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
353344
impl std::error::Error for Error {
354345
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
355346
match self {
@@ -422,7 +413,6 @@ impl<C: Context> Secp256k1<C> {
422413
/// Requires compilation with "rand" feature. See comment by Gregory Maxwell in
423414
/// [libsecp256k1](https://github.com/bitcoin-core/secp256k1/commit/d2275795ff22a6f4738869f5528fbbb61738aa48).
424415
#[cfg(feature = "rand")]
425-
#[cfg_attr(docsrs, doc(cfg(feature = "rand")))]
426416
pub fn randomize<R: rand::Rng + ?Sized>(&mut self, rng: &mut R) {
427417
let mut seed = [0u8; 32];
428418
rng.fill_bytes(&mut seed);
@@ -453,7 +443,6 @@ impl<C: Signing> Secp256k1<C> {
453443
/// [`PublicKey::from_secret_key`].
454444
#[inline]
455445
#[cfg(feature = "rand")]
456-
#[cfg_attr(docsrs, doc(cfg(feature = "rand")))]
457446
pub fn generate_keypair<R: rand::Rng + ?Sized>(
458447
&self,
459448
rng: &mut R,
@@ -467,7 +456,6 @@ impl<C: Signing> Secp256k1<C> {
467456
/// Generates a random keypair using the global [`SECP256K1`] context.
468457
#[inline]
469458
#[cfg(all(feature = "global-context", feature = "rand"))]
470-
#[cfg_attr(docsrs, doc(cfg(all(feature = "global-context", feature = "rand"))))]
471459
pub fn generate_keypair<R: rand::Rng + ?Sized>(rng: &mut R) -> (key::SecretKey, key::PublicKey) {
472460
SECP256K1.generate_keypair(rng)
473461
}

src/scalar.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@ impl Scalar {
4040

4141
/// Generates a random scalar
4242
#[cfg(feature = "rand-std")]
43-
#[cfg_attr(docsrs, doc(cfg(feature = "rand-std")))]
4443
pub fn random() -> Self { Self::random_custom(rand::thread_rng()) }
4544

4645
/// Generates a random scalar using supplied RNG
4746
#[cfg(feature = "rand")]
48-
#[cfg_attr(docsrs, doc(cfg(feature = "rand")))]
4947
pub fn random_custom<R: rand::Rng>(mut rng: R) -> Self {
5048
let mut bytes = [0u8; 32];
5149
loop {
@@ -137,5 +135,4 @@ impl fmt::Display for OutOfRangeError {
137135
}
138136

139137
#[cfg(feature = "std")]
140-
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
141138
impl std::error::Error for OutOfRangeError {}

0 commit comments

Comments
 (0)