diff --git a/Cargo.toml b/Cargo.toml index c5a3862..0f26555 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,9 +12,8 @@ keywords = [ "crypto", "ECDSA", "secp256k1", "libsecp256k1", "bitcoin" ] readme = "README.md" edition = "2018" -# Should make docs.rs show all functions, even those behind non-default features [package.metadata.docs.rs] -features = [ "rand", "rand-std", "serde", "bitcoin_hashes", "recovery", "global-context" ] +all-features = true rustdoc-args = ["--cfg", "docsrs"] [features] diff --git a/secp256k1-sys/Cargo.toml b/secp256k1-sys/Cargo.toml index 57eea91..d0cea9a 100644 --- a/secp256k1-sys/Cargo.toml +++ b/secp256k1-sys/Cargo.toml @@ -15,9 +15,8 @@ build = "build.rs" links = "rustsecp256k1_v0_8_1" edition = "2018" -# Should make docs.rs show all functions, even those behind non-default features [package.metadata.docs.rs] -features = [ "recovery", "lowmemory" ] +all-features = true rustdoc-args = ["--cfg", "docsrs"] [build-dependencies] diff --git a/secp256k1-sys/src/lib.rs b/secp256k1-sys/src/lib.rs index 87f9f6a..396df48 100644 --- a/secp256k1-sys/src/lib.rs +++ b/secp256k1-sys/src/lib.rs @@ -20,7 +20,7 @@ #![deny(non_upper_case_globals, non_camel_case_types, non_snake_case, unused_mut)] #![cfg_attr(all(not(test), not(feature = "std")), no_std)] -#![cfg_attr(docsrs, feature(doc_cfg))] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] #[cfg(any(test, feature = "std"))] extern crate core; diff --git a/src/context.rs b/src/context.rs index c59017b..5b41bc4 100644 --- a/src/context.rs +++ b/src/context.rs @@ -3,14 +3,12 @@ use core::mem::ManuallyDrop; use core::ptr::NonNull; #[cfg(feature = "alloc")] -#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))] pub use self::alloc_only::*; use crate::ffi::types::{c_uint, c_void, AlignedType}; use crate::ffi::{self, CPtr}; use crate::{Error, Secp256k1}; #[cfg(all(feature = "global-context", feature = "std"))] -#[cfg_attr(docsrs, doc(cfg(all(feature = "global-context", feature = "std"))))] /// Module implementing a singleton pattern for a global `Secp256k1` context. pub mod global { @@ -114,7 +112,6 @@ mod private { } #[cfg(feature = "alloc")] -#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))] mod alloc_only { use core::marker::PhantomData; use core::ptr::NonNull; diff --git a/src/ecdh.rs b/src/ecdh.rs index c0e1576..f5d3a19 100644 --- a/src/ecdh.rs +++ b/src/ecdh.rs @@ -168,7 +168,6 @@ unsafe extern "C" fn c_callback( } #[cfg(feature = "serde")] -#[cfg_attr(docsrs, doc(cfg(feature = "serde")))] impl ::serde::Serialize for SharedSecret { fn serialize(&self, s: S) -> Result { if s.is_human_readable() { @@ -181,7 +180,6 @@ impl ::serde::Serialize for SharedSecret { } #[cfg(feature = "serde")] -#[cfg_attr(docsrs, doc(cfg(feature = "serde")))] impl<'de> ::serde::Deserialize<'de> for SharedSecret { fn deserialize>(d: D) -> Result { if d.is_human_readable() { diff --git a/src/ecdsa/mod.rs b/src/ecdsa/mod.rs index c7083a1..0e91193 100644 --- a/src/ecdsa/mod.rs +++ b/src/ecdsa/mod.rs @@ -8,7 +8,6 @@ pub mod serialized_signature; use core::{fmt, ptr, str}; #[cfg(feature = "recovery")] -#[cfg_attr(docsrs, doc(cfg(feature = "recovery")))] pub use self::recovery::{RecoverableSignature, RecoveryId}; pub use self::serialized_signature::SerializedSignature; use crate::ffi::CPtr; @@ -193,7 +192,6 @@ impl Signature { /// The signature must be normalized or verification will fail (see [`Signature::normalize_s`]). #[inline] #[cfg(feature = "global-context")] - #[cfg_attr(docsrs, doc(cfg(feature = "global-context")))] pub fn verify(&self, msg: &Message, pk: &PublicKey) -> Result<(), Error> { SECP256K1.verify_ecdsa(msg, self, pk) } @@ -214,7 +212,6 @@ impl From for Signature { } #[cfg(feature = "serde")] -#[cfg_attr(docsrs, doc(cfg(feature = "serde")))] impl serde::Serialize for Signature { fn serialize(&self, s: S) -> Result { if s.is_human_readable() { @@ -226,7 +223,6 @@ impl serde::Serialize for Signature { } #[cfg(feature = "serde")] -#[cfg_attr(docsrs, doc(cfg(feature = "serde")))] impl<'de> serde::Deserialize<'de> for Signature { fn deserialize>(d: D) -> Result { if d.is_human_readable() { diff --git a/src/ecdsa/recovery.rs b/src/ecdsa/recovery.rs index 003b7e1..6b63d8f 100644 --- a/src/ecdsa/recovery.rs +++ b/src/ecdsa/recovery.rs @@ -126,7 +126,6 @@ impl RecoverableSignature { /// verify-capable context. #[inline] #[cfg(feature = "global-context")] - #[cfg_attr(docsrs, doc(cfg(feature = "global-context")))] pub fn recover(&self, msg: &Message) -> Result { crate::SECP256K1.recover_ecdsa(msg, self) } diff --git a/src/key.rs b/src/key.rs index afa837e..e32eaf1 100644 --- a/src/key.rs +++ b/src/key.rs @@ -198,7 +198,6 @@ impl SecretKey { /// ``` #[inline] #[cfg(feature = "rand")] - #[cfg_attr(docsrs, doc(cfg(feature = "rand")))] pub fn new(rng: &mut R) -> SecretKey { let mut data = crate::random_32_bytes(rng); unsafe { @@ -286,7 +285,6 @@ impl SecretKey { /// # } /// ``` #[cfg(feature = "bitcoin_hashes")] - #[cfg_attr(docsrs, doc(cfg(feature = "bitcoin-hashes")))] #[inline] pub fn from_hashed_data(data: &[u8]) -> Self { ::hash(data).into() @@ -355,7 +353,6 @@ impl SecretKey { /// Constructs an ECDSA signature for `msg` using the global [`SECP256K1`] context. #[inline] #[cfg(feature = "global-context")] - #[cfg_attr(docsrs, doc(cfg(feature = "global-context")))] pub fn sign_ecdsa(&self, msg: Message) -> ecdsa::Signature { SECP256K1.sign_ecdsa(&msg, self) } /// Returns the [`KeyPair`] for this [`SecretKey`]. @@ -393,7 +390,6 @@ impl From for SecretKey { } #[cfg(feature = "serde")] -#[cfg_attr(docsrs, doc(cfg(feature = "serde")))] impl serde::Serialize for SecretKey { fn serialize(&self, s: S) -> Result { if s.is_human_readable() { @@ -410,7 +406,6 @@ impl serde::Serialize for SecretKey { } #[cfg(feature = "serde")] -#[cfg_attr(docsrs, doc(cfg(feature = "serde")))] impl<'de> serde::Deserialize<'de> for SecretKey { fn deserialize>(d: D) -> Result { if d.is_human_readable() { @@ -469,7 +464,6 @@ impl PublicKey { /// Creates a new public key from a [`SecretKey`] and the global [`SECP256K1`] context. #[inline] #[cfg(feature = "global-context")] - #[cfg_attr(docsrs, doc(cfg(feature = "global-context")))] pub fn from_secret_key_global(sk: &SecretKey) -> PublicKey { PublicKey::from_secret_key(SECP256K1, sk) } @@ -740,7 +734,6 @@ impl From for PublicKey { } #[cfg(feature = "serde")] -#[cfg_attr(docsrs, doc(cfg(feature = "serde")))] impl serde::Serialize for PublicKey { fn serialize(&self, s: S) -> Result { if s.is_human_readable() { @@ -757,7 +750,6 @@ impl serde::Serialize for PublicKey { } #[cfg(feature = "serde")] -#[cfg_attr(docsrs, doc(cfg(feature = "serde")))] impl<'de> serde::Deserialize<'de> for PublicKey { fn deserialize>(d: D) -> Result { if d.is_human_readable() { @@ -877,7 +869,6 @@ impl KeyPair { /// [`Error::InvalidSecretKey`] if corresponding public key for the provided secret key is not even. #[inline] #[cfg(feature = "global-context")] - #[cfg_attr(docsrs, doc(cfg(feature = "global-context")))] pub fn from_seckey_str_global(s: &str) -> Result { KeyPair::from_seckey_str(SECP256K1, s) } @@ -895,7 +886,6 @@ impl KeyPair { /// ``` #[inline] #[cfg(feature = "rand")] - #[cfg_attr(docsrs, doc(cfg(feature = "rand")))] pub fn new(secp: &Secp256k1, rng: &mut R) -> KeyPair { let mut data = crate::random_32_bytes(rng); unsafe { @@ -912,7 +902,6 @@ impl KeyPair { /// Generates a new random secret key using the global [`SECP256K1`] context. #[inline] #[cfg(all(feature = "global-context", feature = "rand"))] - #[cfg_attr(docsrs, doc(cfg(all(feature = "global-context", feature = "rand"))))] pub fn new_global(rng: &mut R) -> KeyPair { KeyPair::new(SECP256K1, rng) } @@ -989,7 +978,6 @@ impl KeyPair { /// Constructs an schnorr signature for `msg` using the global [`SECP256K1`] context. #[inline] #[cfg(all(feature = "global-context", feature = "rand-std"))] - #[cfg_attr(docsrs, doc(cfg(all(feature = "global-context", feature = "rand-std"))))] pub fn sign_schnorr(&self, msg: Message) -> schnorr::Signature { SECP256K1.sign_schnorr(&msg, self) } @@ -1044,7 +1032,6 @@ impl str::FromStr for KeyPair { } #[cfg(feature = "serde")] -#[cfg_attr(docsrs, doc(cfg(feature = "serde")))] impl serde::Serialize for KeyPair { fn serialize(&self, s: S) -> Result { if s.is_human_readable() { @@ -1064,7 +1051,6 @@ impl serde::Serialize for KeyPair { } #[cfg(feature = "serde")] -#[cfg_attr(docsrs, doc(cfg(feature = "serde")))] impl<'de> serde::Deserialize<'de> for KeyPair { fn deserialize>(d: D) -> Result { if d.is_human_readable() { @@ -1439,7 +1425,6 @@ impl fmt::Display for InvalidParityValue { } #[cfg(feature = "std")] -#[cfg_attr(docsrs, doc(cfg(feature = "std")))] impl std::error::Error for InvalidParityValue {} impl From for Error { @@ -1448,7 +1433,6 @@ impl From for Error { /// The parity is serialized as `u8` - `0` for even, `1` for odd. #[cfg(feature = "serde")] -#[cfg_attr(docsrs, doc(cfg(feature = "serde")))] impl serde::Serialize for Parity { fn serialize(&self, s: S) -> Result { s.serialize_u8(self.to_u8()) @@ -1457,7 +1441,6 @@ impl serde::Serialize for Parity { /// The parity is deserialized as `u8` - `0` for even, `1` for odd. #[cfg(feature = "serde")] -#[cfg_attr(docsrs, doc(cfg(feature = "serde")))] impl<'de> serde::Deserialize<'de> for Parity { fn deserialize>(d: D) -> Result { struct Visitor; @@ -1516,7 +1499,6 @@ impl From for XOnlyPublicKey { } #[cfg(feature = "serde")] -#[cfg_attr(docsrs, doc(cfg(feature = "serde")))] impl serde::Serialize for XOnlyPublicKey { fn serialize(&self, s: S) -> Result { if s.is_human_readable() { @@ -1532,7 +1514,6 @@ impl serde::Serialize for XOnlyPublicKey { } #[cfg(feature = "serde")] -#[cfg_attr(docsrs, doc(cfg(feature = "serde")))] impl<'de> serde::Deserialize<'de> for XOnlyPublicKey { fn deserialize>(d: D) -> Result { if d.is_human_readable() { diff --git a/src/lib.rs b/src/lib.rs index b53ce4a..df67989 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -154,7 +154,7 @@ #![warn(missing_docs, missing_copy_implementations, missing_debug_implementations)] #![cfg_attr(all(not(test), not(feature = "std")), no_std)] // Experimental features we need. -#![cfg_attr(docsrs, feature(doc_cfg))] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(bench, feature(test))] #[cfg(feature = "alloc")] @@ -184,17 +184,13 @@ use core::ptr::NonNull; use core::{fmt, mem, str}; #[cfg(feature = "bitcoin_hashes")] -#[cfg_attr(docsrs, doc(cfg(feature = "bitcoin-hashes")))] pub use bitcoin_hashes as hashes; #[cfg(feature = "global-context")] -#[cfg_attr(docsrs, doc(cfg(feature = "global-context")))] pub use context::global::SECP256K1; #[cfg(feature = "rand")] -#[cfg_attr(docsrs, doc(cfg(feature = "rand")))] pub use rand; pub use secp256k1_sys as ffi; #[cfg(feature = "serde")] -#[cfg_attr(docsrs, doc(cfg(feature = "serde")))] pub use serde; pub use crate::context::*; @@ -214,19 +210,16 @@ pub trait ThirtyTwoByteHash { } #[cfg(feature = "bitcoin_hashes")] -#[cfg_attr(docsrs, doc(cfg(feature = "bitcoin-hashes")))] impl ThirtyTwoByteHash for hashes::sha256::Hash { fn into_32(self) -> [u8; 32] { self.to_byte_array() } } #[cfg(feature = "bitcoin_hashes")] -#[cfg_attr(docsrs, doc(cfg(feature = "bitcoin-hashes")))] impl ThirtyTwoByteHash for hashes::sha256d::Hash { fn into_32(self) -> [u8; 32] { self.to_byte_array() } } #[cfg(feature = "bitcoin_hashes")] -#[cfg_attr(docsrs, doc(cfg(feature = "bitcoin-hashes")))] impl ThirtyTwoByteHash for hashes::sha256t::Hash { fn into_32(self) -> [u8; 32] { self.to_byte_array() } } @@ -275,7 +268,6 @@ impl Message { /// # } /// ``` #[cfg(feature = "bitcoin_hashes")] - #[cfg_attr(docsrs, doc(cfg(feature = "bitcoin-hashes")))] pub fn from_hashed_data(data: &[u8]) -> Self { ::hash(data).into() } @@ -349,7 +341,6 @@ impl fmt::Display for Error { } #[cfg(feature = "std")] -#[cfg_attr(docsrs, doc(cfg(feature = "std")))] impl std::error::Error for Error { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { match self { @@ -422,7 +413,6 @@ impl Secp256k1 { /// Requires compilation with "rand" feature. See comment by Gregory Maxwell in /// [libsecp256k1](https://github.com/bitcoin-core/secp256k1/commit/d2275795ff22a6f4738869f5528fbbb61738aa48). #[cfg(feature = "rand")] - #[cfg_attr(docsrs, doc(cfg(feature = "rand")))] pub fn randomize(&mut self, rng: &mut R) { let mut seed = [0u8; 32]; rng.fill_bytes(&mut seed); @@ -453,7 +443,6 @@ impl Secp256k1 { /// [`PublicKey::from_secret_key`]. #[inline] #[cfg(feature = "rand")] - #[cfg_attr(docsrs, doc(cfg(feature = "rand")))] pub fn generate_keypair( &self, rng: &mut R, @@ -467,7 +456,6 @@ impl Secp256k1 { /// Generates a random keypair using the global [`SECP256K1`] context. #[inline] #[cfg(all(feature = "global-context", feature = "rand"))] -#[cfg_attr(docsrs, doc(cfg(all(feature = "global-context", feature = "rand"))))] pub fn generate_keypair(rng: &mut R) -> (key::SecretKey, key::PublicKey) { SECP256K1.generate_keypair(rng) } diff --git a/src/scalar.rs b/src/scalar.rs index 57d1e25..0736192 100644 --- a/src/scalar.rs +++ b/src/scalar.rs @@ -40,12 +40,10 @@ impl Scalar { /// Generates a random scalar #[cfg(feature = "rand-std")] - #[cfg_attr(docsrs, doc(cfg(feature = "rand-std")))] pub fn random() -> Self { Self::random_custom(rand::thread_rng()) } /// Generates a random scalar using supplied RNG #[cfg(feature = "rand")] - #[cfg_attr(docsrs, doc(cfg(feature = "rand")))] pub fn random_custom(mut rng: R) -> Self { let mut bytes = [0u8; 32]; loop { @@ -137,5 +135,4 @@ impl fmt::Display for OutOfRangeError { } #[cfg(feature = "std")] -#[cfg_attr(docsrs, doc(cfg(feature = "std")))] impl std::error::Error for OutOfRangeError {} diff --git a/src/schnorr.rs b/src/schnorr.rs index c29bb57..018beaa 100644 --- a/src/schnorr.rs +++ b/src/schnorr.rs @@ -89,7 +89,6 @@ impl Signature { /// Verifies a schnorr signature for `msg` using `pk` and the global [`SECP256K1`] context. #[inline] #[cfg(feature = "global-context")] - #[cfg_attr(docsrs, doc(cfg(feature = "global-context")))] pub fn verify(&self, msg: &Message, pk: &XOnlyPublicKey) -> Result<(), Error> { SECP256K1.verify_schnorr(self, msg, pk) } @@ -122,7 +121,6 @@ impl Secp256k1 { /// Creates a schnorr signature internally using the [`rand::rngs::ThreadRng`] random number /// generator to generate the auxiliary random data. #[cfg(feature = "rand-std")] - #[cfg_attr(docsrs, doc(cfg(feature = "rand-std")))] pub fn sign_schnorr(&self, msg: &Message, keypair: &KeyPair) -> Signature { self.sign_schnorr_with_rng(msg, keypair, &mut rand::thread_rng()) } @@ -145,7 +143,6 @@ impl Secp256k1 { /// Creates a schnorr signature using the given random number generator to /// generate the auxiliary random data. #[cfg(feature = "rand")] - #[cfg_attr(docsrs, doc(cfg(feature = "rand")))] pub fn sign_schnorr_with_rng( &self, msg: &Message, diff --git a/src/secret.rs b/src/secret.rs index 4faa152..b744592 100644 --- a/src/secret.rs +++ b/src/secret.rs @@ -24,7 +24,6 @@ macro_rules! impl_display_secret { // Default hasher exists only in standard library and not alloc ($thing:ident) => { #[cfg(feature = "std")] - #[cfg_attr(docsrs, doc(cfg(feature = "std")))] impl core::fmt::Debug for $thing { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { use core::hash::Hasher;