Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use doc_auto_cfg and remove manual doc(cfg()) gates #150

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/crl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ pub trait CertRevocationList: Sealed + Debug {
///
/// [^1]: <https://www.rfc-editor.org/rfc/rfc5280#section-5>
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
#[derive(Debug, Clone)]
pub struct OwnedCertRevocationList {
/// A map of the revoked certificates contained in then CRL, keyed by the DER encoding
Expand Down Expand Up @@ -144,7 +143,6 @@ impl<'a> BorrowedCertRevocationList<'a> {
/// Convert the CRL to an [`OwnedCertRevocationList`]. This may error if any of the revoked
/// certificates in the CRL are malformed or contain unsupported features.
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
pub fn to_owned(&self) -> Result<OwnedCertRevocationList, Error> {
// Parse and collect the CRL's revoked cert entries, ensuring there are no errors. With
// the full set in-hand, create a lookup map by serial number for fast revocation checking.
Expand Down Expand Up @@ -452,7 +450,6 @@ pub struct BorrowedRevokedCert<'a> {
impl<'a> BorrowedRevokedCert<'a> {
/// Construct an owned representation of the revoked certificate.
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
pub fn to_owned(&self) -> OwnedRevokedCert {
OwnedRevokedCert {
serial_number: self.serial_number.to_vec(),
Expand Down
1 change: 0 additions & 1 deletion src/end_entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ impl<'a> EndEntityCert<'a> {
/// Verification functions are already provided as `verify_is_valid_for_dns_name`
/// and `verify_is_valid_for_at_least_one_dns_name`.
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
pub fn dns_names(&'a self) -> Result<impl Iterator<Item = GeneralDnsNameRef<'a>>, Error> {
subject_name::list_cert_dns_names(self)
}
Expand Down
1 change: 0 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ impl fmt::Display for Error {
}

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

impl From<untrusted::EndOfInput> for Error {
Expand Down
5 changes: 1 addition & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
clippy::upper_case_acronyms
)]
// Enable documentation for all features on docs.rs
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

#[cfg(any(test, feature = "alloc"))]
#[cfg_attr(test, macro_use)]
Expand Down Expand Up @@ -78,20 +78,17 @@ pub use {
},
};

#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
#[cfg(feature = "alloc")]
pub use {
crl::{OwnedCertRevocationList, OwnedRevokedCert},
subject_name::{DnsName, IpAddr},
};

#[cfg_attr(docsrs, doc(cfg(feature = "ring")))]
#[cfg(feature = "ring")]
pub use ring_algs::{
ECDSA_P256_SHA256, ECDSA_P256_SHA384, ECDSA_P384_SHA256, ECDSA_P384_SHA384, ED25519,
};

#[cfg_attr(docsrs, doc(cfg(all(feature = "ring", feature = "alloc"))))]
#[cfg(all(feature = "ring", feature = "alloc"))]
pub use ring_algs::{
RSA_PKCS1_2048_8192_SHA256, RSA_PKCS1_2048_8192_SHA384, RSA_PKCS1_2048_8192_SHA512,
Expand Down
14 changes: 0 additions & 14 deletions src/ring_algs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ pub static ECDSA_P384_SHA384: &dyn SignatureVerificationAlgorithm = &RingAlgorit
};

/// RSA PKCS#1 1.5 signatures using SHA-256 for keys of 2048-8192 bits.
///
/// Requires the `alloc` feature.
#[cfg(feature = "alloc")]
pub static RSA_PKCS1_2048_8192_SHA256: &dyn SignatureVerificationAlgorithm = &RingAlgorithm {
public_key_alg_id: alg_id::RSA_ENCRYPTION,
Expand All @@ -82,8 +80,6 @@ pub static RSA_PKCS1_2048_8192_SHA256: &dyn SignatureVerificationAlgorithm = &Ri
};

/// RSA PKCS#1 1.5 signatures using SHA-384 for keys of 2048-8192 bits.
///
/// Requires the `alloc` feature.
#[cfg(feature = "alloc")]
pub static RSA_PKCS1_2048_8192_SHA384: &dyn SignatureVerificationAlgorithm = &RingAlgorithm {
public_key_alg_id: alg_id::RSA_ENCRYPTION,
Expand All @@ -92,8 +88,6 @@ pub static RSA_PKCS1_2048_8192_SHA384: &dyn SignatureVerificationAlgorithm = &Ri
};

/// RSA PKCS#1 1.5 signatures using SHA-512 for keys of 2048-8192 bits.
///
/// Requires the `alloc` feature.
#[cfg(feature = "alloc")]
pub static RSA_PKCS1_2048_8192_SHA512: &dyn SignatureVerificationAlgorithm = &RingAlgorithm {
public_key_alg_id: alg_id::RSA_ENCRYPTION,
Expand All @@ -102,8 +96,6 @@ pub static RSA_PKCS1_2048_8192_SHA512: &dyn SignatureVerificationAlgorithm = &Ri
};

/// RSA PKCS#1 1.5 signatures using SHA-384 for keys of 3072-8192 bits.
///
/// Requires the `alloc` feature.
#[cfg(feature = "alloc")]
pub static RSA_PKCS1_3072_8192_SHA384: &dyn SignatureVerificationAlgorithm = &RingAlgorithm {
public_key_alg_id: alg_id::RSA_ENCRYPTION,
Expand All @@ -115,8 +107,6 @@ pub static RSA_PKCS1_3072_8192_SHA384: &dyn SignatureVerificationAlgorithm = &Ri
/// type rsaEncryption; see [RFC 4055 Section 1.2].
///
/// [RFC 4055 Section 1.2]: https://tools.ietf.org/html/rfc4055#section-1.2
///
/// Requires the `alloc` feature.
#[cfg(feature = "alloc")]
pub static RSA_PSS_2048_8192_SHA256_LEGACY_KEY: &dyn SignatureVerificationAlgorithm =
&RingAlgorithm {
Expand All @@ -129,8 +119,6 @@ pub static RSA_PSS_2048_8192_SHA256_LEGACY_KEY: &dyn SignatureVerificationAlgori
/// type rsaEncryption; see [RFC 4055 Section 1.2].
///
/// [RFC 4055 Section 1.2]: https://tools.ietf.org/html/rfc4055#section-1.2
///
/// Requires the `alloc` feature.
#[cfg(feature = "alloc")]
pub static RSA_PSS_2048_8192_SHA384_LEGACY_KEY: &dyn SignatureVerificationAlgorithm =
&RingAlgorithm {
Expand All @@ -143,8 +131,6 @@ pub static RSA_PSS_2048_8192_SHA384_LEGACY_KEY: &dyn SignatureVerificationAlgori
/// type rsaEncryption; see [RFC 4055 Section 1.2].
///
/// [RFC 4055 Section 1.2]: https://tools.ietf.org/html/rfc4055#section-1.2
///
/// Requires the `alloc` feature.
#[cfg(feature = "alloc")]
pub static RSA_PSS_2048_8192_SHA512_LEGACY_KEY: &dyn SignatureVerificationAlgorithm =
&RingAlgorithm {
Expand Down
2 changes: 0 additions & 2 deletions src/signed_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use alloc::vec::Vec;
/// X.509 certificates and related items that are signed are almost always
/// encoded in the format "tbs||signatureAlgorithm||signature". This structure
/// captures this pattern as an owned data type.
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
#[cfg(feature = "alloc")]
#[derive(Clone, Debug)]
pub(crate) struct OwnedSignedData {
Expand Down Expand Up @@ -132,7 +131,6 @@ impl<'a> SignedData<'a> {

/// Convert the borrowed signed data to an [`OwnedSignedData`].
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
pub(crate) fn to_owned(&self) -> OwnedSignedData {
OwnedSignedData {
data: self.data.as_slice_less_safe().to_vec(),
Expand Down
5 changes: 0 additions & 5 deletions src/subject_name/dns_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ use crate::Error;
///
/// Requires the `alloc` feature.
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct DnsName(String);

#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
impl DnsName {
/// Returns a `DnsNameRef` that refers to this `DnsName`.
pub fn as_ref(&self) -> DnsNameRef {
Expand All @@ -47,7 +45,6 @@ impl DnsName {
}

#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
impl AsRef<str> for DnsName {
fn as_ref(&self) -> &str {
self.0.as_ref()
Expand Down Expand Up @@ -87,7 +84,6 @@ impl core::fmt::Display for InvalidDnsNameError {
}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl ::std::error::Error for InvalidDnsNameError {}

impl<'a> DnsNameRef<'a> {
Expand All @@ -113,7 +109,6 @@ impl<'a> DnsNameRef<'a> {

/// Constructs a `DnsName` from this `DnsNameRef`
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
pub fn to_owned(&self) -> DnsName {
// DnsNameRef is already guaranteed to be valid ASCII, which is a
// subset of UTF-8.
Expand Down
7 changes: 0 additions & 7 deletions src/subject_name/ip_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const VALID_IP_BY_CONSTRUCTION: &str = "IP address is a valid string by construc

/// Either a IPv4 or IPv6 address, plus its owned string representation
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub enum IpAddr {
/// An IPv4 address and its owned string representation
Expand All @@ -34,7 +33,6 @@ pub enum IpAddr {
}

#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
impl AsRef<str> for IpAddr {
fn as_ref(&self) -> &str {
match self {
Expand All @@ -53,7 +51,6 @@ pub enum IpAddrRef<'a> {
}

#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
impl<'a> From<IpAddrRef<'a>> for IpAddr {
fn from(ip_address: IpAddrRef<'a>) -> IpAddr {
match ip_address {
Expand All @@ -70,7 +67,6 @@ impl<'a> From<IpAddrRef<'a>> for IpAddr {
}

#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
impl<'a> From<&'a IpAddr> for IpAddrRef<'a> {
fn from(ip_address: &'a IpAddr) -> IpAddrRef<'a> {
match ip_address {
Expand All @@ -96,7 +92,6 @@ impl core::fmt::Display for AddrParseError {
}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl ::std::error::Error for AddrParseError {}

impl<'a> IpAddrRef<'a> {
Expand All @@ -120,7 +115,6 @@ impl<'a> IpAddrRef<'a> {

/// Constructs an `IpAddr` from this `IpAddrRef`
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
pub fn to_owned(&self) -> IpAddr {
match self {
IpAddrRef::V4(ip_address, ip_address_octets) => IpAddr::V4(
Expand Down Expand Up @@ -155,7 +149,6 @@ fn ipv6_to_uncompressed_string(octets: [u8; 16]) -> String {
}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl From<std::net::IpAddr> for IpAddr {
fn from(ip_address: std::net::IpAddr) -> IpAddr {
match ip_address {
Expand Down
1 change: 0 additions & 1 deletion src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ impl<'a> FromDer<'a> for Time {
}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl TryFrom<std::time::SystemTime> for Time {
type Error = std::time::SystemTimeError;

Expand Down