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

small nightly clippy fixes #222

Merged
merged 2 commits into from
Jan 8, 2024
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
14 changes: 6 additions & 8 deletions src/cert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ mod tests {
// We expect the distribution point name to be a sequence of GeneralNames, not a name
// relative to the CRL issuer.
let names = match distribution_point_name {
DistributionPointName::NameRelativeToCrlIssuer(_) => {
DistributionPointName::NameRelativeToCrlIssuer => {
panic!("unexpected name relative to crl issuer")
}
DistributionPointName::FullName(names) => names,
Expand Down Expand Up @@ -566,12 +566,10 @@ mod tests {
.expect("missing distribution point name");

// We expect the distribution point name to be a name relative to the CRL issuer.
match distribution_point_name {
DistributionPointName::NameRelativeToCrlIssuer(name) => {
assert!(!name.is_empty());
}
DistributionPointName::FullName(_) => panic!("unexpected full name sequence"),
};
assert!(matches!(
distribution_point_name,
DistributionPointName::NameRelativeToCrlIssuer
));
}

#[test]
Expand Down Expand Up @@ -633,7 +631,7 @@ mod tests {
.expect("failed to parse distribution point names")
.expect("missing distribution point name")
{
DistributionPointName::NameRelativeToCrlIssuer(_) => {
DistributionPointName::NameRelativeToCrlIssuer => {
panic!("unexpected relative name")
}
DistributionPointName::FullName(names) => names,
Expand Down
4 changes: 2 additions & 2 deletions src/crl/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ impl<'a> IssuingDistributionPoint<'a> {
use DistributionPointName::*;
match result.names() {
Ok(Some(FullName(_))) => Ok(result),
Ok(Some(NameRelativeToCrlIssuer(_))) | Ok(None) => {
Ok(Some(NameRelativeToCrlIssuer)) | Ok(None) => {
Err(Error::UnsupportedCrlIssuingDistributionPoint)
}
Err(_) => Err(Error::MalformedExtensions),
Expand Down Expand Up @@ -944,7 +944,7 @@ mod tests {
.expect("failed to parse distribution point names")
.expect("missing distribution point name");
let uri = match dp_name {
DistributionPointName::NameRelativeToCrlIssuer(_) => {
DistributionPointName::NameRelativeToCrlIssuer => {
panic!("unexpected relative dp name")
}
DistributionPointName::FullName(general_names) => {
Expand Down
10 changes: 5 additions & 5 deletions src/subject_name/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ fn check_presented_id_conforms_to_constraints(
dns_name::presented_id_matches_reference_id(name, IdRole::NameConstraint, base)
}

(GeneralName::DirectoryName(_), GeneralName::DirectoryName(_)) => Ok(
(GeneralName::DirectoryName, GeneralName::DirectoryName) => Ok(
// Reject any uses of directory name constraints; we don't implement this.
//
// Rejecting everything technically confirms to RFC5280:
Expand Down Expand Up @@ -237,8 +237,8 @@ impl<'a> Iterator for NameIterator<'a> {
}
}

if let Some(subject_directory_name) = self.subject_directory_name.take() {
return Some(Ok(GeneralName::DirectoryName(subject_directory_name)));
if self.subject_directory_name.take().is_some() {
return Some(Ok(GeneralName::DirectoryName));
}

None
Expand All @@ -253,7 +253,7 @@ impl<'a> Iterator for NameIterator<'a> {
#[derive(Clone, Copy)]
pub(crate) enum GeneralName<'a> {
DnsName(untrusted::Input<'a>),
DirectoryName(untrusted::Input<'a>),
DirectoryName,
IpAddress(untrusted::Input<'a>),
UniformResourceIdentifier(untrusted::Input<'a>),

Expand Down Expand Up @@ -282,7 +282,7 @@ impl<'a> FromDer<'a> for GeneralName<'a> {
let (tag, value) = der::read_tag_and_get_value(reader)?;
Ok(match tag {
DNS_NAME_TAG => DnsName(value),
DIRECTORY_NAME_TAG => DirectoryName(value),
DIRECTORY_NAME_TAG => DirectoryName,
IP_ADDRESS_TAG => IpAddress(value),
UNIFORM_RESOURCE_IDENTIFIER_TAG => UniformResourceIdentifier(value),

Expand Down
6 changes: 2 additions & 4 deletions src/x509.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub(crate) fn remember_extension(
/// [^1]: <https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.13>
pub(crate) enum DistributionPointName<'a> {
/// The distribution point name is a relative distinguished name, relative to the CRL issuer.
NameRelativeToCrlIssuer(untrusted::Input<'a>),
NameRelativeToCrlIssuer,
/// The distribution point name is a sequence of [GeneralName] items.
FullName(DerIterator<'a, GeneralName<'a>>),
}
Expand All @@ -102,9 +102,7 @@ impl<'a> FromDer<'a> for DistributionPointName<'a> {
let (tag, value) = der::read_tag_and_get_value(reader)?;
match tag {
FULL_NAME_TAG => Ok(DistributionPointName::FullName(DerIterator::new(value))),
NAME_RELATIVE_TO_CRL_ISSUER_TAG => {
Ok(DistributionPointName::NameRelativeToCrlIssuer(value))
}
NAME_RELATIVE_TO_CRL_ISSUER_TAG => Ok(DistributionPointName::NameRelativeToCrlIssuer),
_ => Err(Error::BadDer),
}
}
Expand Down