Skip to content

Commit

Permalink
Fix new warnings in clippy unstable (redundant imports)
Browse files Browse the repository at this point in the history
  • Loading branch information
chifflier committed Apr 9, 2024
1 parent 867ffb6 commit 9690362
Show file tree
Hide file tree
Showing 32 changed files with 63 additions and 45 deletions.
9 changes: 5 additions & 4 deletions src/asn1_types/any.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::ber::*;
use crate::*;
use alloc::borrow::Cow;
#[cfg(not(feature = "std"))]
use alloc::string::String;
use core::convert::{TryFrom, TryInto};

Expand Down Expand Up @@ -103,10 +104,10 @@ impl<'a> Any<'a> {
let (rem, any) = Any::from_ber(bytes).map_err(Err::convert)?;
any.tag()
.assert_eq(Tag(tag))
.map_err(|e| nom::Err::Error(e.into()))?;
.map_err(|e| Err::Error(e.into()))?;
any.class()
.assert_eq(class)
.map_err(|e| nom::Err::Error(e.into()))?;
.map_err(|e| Err::Error(e.into()))?;
let (_, res) = op(any.data)?;
Ok((rem, res))
}
Expand All @@ -127,10 +128,10 @@ impl<'a> Any<'a> {
let (rem, any) = Any::from_der(bytes).map_err(Err::convert)?;
any.tag()
.assert_eq(Tag(tag))
.map_err(|e| nom::Err::Error(e.into()))?;
.map_err(|e| Err::Error(e.into()))?;
any.class()
.assert_eq(class)
.map_err(|e| nom::Err::Error(e.into()))?;
.map_err(|e| Err::Error(e.into()))?;
let (_, res) = op(any.data)?;
Ok((rem, res))
}
Expand Down
2 changes: 1 addition & 1 deletion src/asn1_types/generalizedtime.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::datetime::decode_decimal;
use crate::*;
use alloc::format;
#[cfg(not(feature = "std"))]
use alloc::string::String;
use core::convert::TryFrom;
use core::fmt;
Expand Down
1 change: 1 addition & 0 deletions src/asn1_types/object_descriptor.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{asn1_string, TestValidCharset};
use crate::{Error, Result};
#[cfg(not(feature = "std"))]
use alloc::string::String;

// X.680 section 44.3
Expand Down
5 changes: 2 additions & 3 deletions src/asn1_types/oid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ use crate::*;
use alloc::borrow::Cow;
#[cfg(not(feature = "std"))]
use alloc::format;
#[cfg(not(feature = "std"))]
use alloc::string::{String, ToString};
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use core::{
convert::TryFrom, fmt, iter::FusedIterator, marker::PhantomData, ops::Shl, str::FromStr,
};

#[cfg(feature = "bigint")]
use num_bigint::BigUint;
use num_traits::Num;

/// An error for OID parsing functions.
Expand Down
1 change: 0 additions & 1 deletion src/asn1_types/real.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::*;
use alloc::format;
use core::convert::TryFrom;
use nom::Needed;

mod f32;
mod f64;
Expand Down
3 changes: 2 additions & 1 deletion src/asn1_types/sequence.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::*;
use alloc::borrow::Cow;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use core::convert::TryFrom;

Expand Down Expand Up @@ -179,7 +180,7 @@ impl<'a> Sequence<'a> {
{
match self.content {
Cow::Borrowed(b) => f(b),
_ => Err(nom::Err::Error(Error::LifetimeError.into())),
_ => Err(Err::Error(Error::LifetimeError.into())),
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/asn1_types/sequence/sequence_of.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::*;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use core::convert::TryFrom;
use core::fmt::{Debug, Display};
Expand Down Expand Up @@ -142,10 +143,10 @@ where
.map_err(Err::convert)?;
any.header
.assert_tag(Self::TAG)
.map_err(|e| nom::Err::Error(e.into()))?;
.map_err(|e| Err::Error(e.into()))?;
let items = SequenceIterator::<T, DerParser, E>::new(any.data)
.collect::<Result<Vec<T>, E>>()
.map_err(nom::Err::Error)?;
.map_err(Err::Error)?;
Ok((rem, SequenceOf::new(items)))
},
bytes,
Expand Down
5 changes: 3 additions & 2 deletions src/asn1_types/sequence/vec.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::*;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use core::convert::TryFrom;
use core::fmt::Debug;
Expand Down Expand Up @@ -121,10 +122,10 @@ where
.map_err(Err::convert)?;
any.header
.assert_tag(Self::TAG)
.map_err(|e| nom::Err::Error(e.into()))?;
.map_err(|e| Err::Error(e.into()))?;
let v = SequenceIterator::<T, DerParser, E>::new(any.data)
.collect::<Result<Vec<T>, E>>()
.map_err(nom::Err::Error)?;
.map_err(Err::Error)?;
Ok((rem, v))
},
bytes,
Expand Down
3 changes: 2 additions & 1 deletion src/asn1_types/set.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::*;
use alloc::borrow::Cow;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use core::convert::TryFrom;

Expand Down Expand Up @@ -180,7 +181,7 @@ impl<'a> Set<'a> {
{
match self.content {
Cow::Borrowed(b) => f(b),
_ => Err(nom::Err::Error(Error::LifetimeError.into())),
_ => Err(Err::Error(Error::LifetimeError.into())),
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/asn1_types/set/btreeset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ where
.map_err(Err::convert)?;
any.tag()
.assert_eq(Self::TAG)
.map_err(|e| nom::Err::Error(e.into()))?;
.map_err(|e| Err::Error(e.into()))?;
any.header
.assert_constructed()
.map_err(|e| nom::Err::Error(e.into()))?;
.map_err(|e| Err::Error(e.into()))?;
let items = SetIterator::<T, DerParser, E>::new(any.data)
.collect::<Result<BTreeSet<T>, E>>()
.map_err(nom::Err::Error)?;
.map_err(Err::Error)?;
Ok((rem, items))
},
bytes,
Expand Down
6 changes: 3 additions & 3 deletions src/asn1_types/set/hashset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ where
.map_err(Err::convert)?;
any.tag()
.assert_eq(Self::TAG)
.map_err(|e| nom::Err::Error(e.into()))?;
.map_err(|e| Err::Error(e.into()))?;
any.header
.assert_constructed()
.map_err(|e| nom::Err::Error(e.into()))?;
.map_err(|e| Err::Error(e.into()))?;
let items = SetIterator::<T, DerParser, E>::new(any.data)
.collect::<Result<HashSet<T>, E>>()
.map_err(nom::Err::Error)?;
.map_err(Err::Error)?;
Ok((rem, items))
},
bytes,
Expand Down
5 changes: 3 additions & 2 deletions src/asn1_types/set/set_of.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::*;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use core::convert::TryFrom;
use core::fmt::{Debug, Display};
Expand Down Expand Up @@ -142,10 +143,10 @@ where
.map_err(Err::convert)?;
any.header
.assert_tag(Self::TAG)
.map_err(|e| nom::Err::Error(e.into()))?;
.map_err(|e| Err::Error(e.into()))?;
let items = SetIterator::<T, DerParser, E>::new(any.data)
.collect::<Result<Vec<T>, E>>()
.map_err(nom::Err::Error)?;
.map_err(Err::Error)?;
Ok((rem, SetOf::new(items)))
},
bytes,
Expand Down
4 changes: 3 additions & 1 deletion src/asn1_types/strings/bmpstring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

use crate::*;
use alloc::borrow::Cow;
#[cfg(not(feature = "std"))]
use alloc::string::{String, ToString};
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;

/// ASN.1 `BMPSTRING` type
Expand Down Expand Up @@ -42,7 +44,7 @@ impl<'a> From<&'a str> for BmpString<'a> {
impl From<String> for BmpString<'_> {
fn from(s: String) -> Self {
Self {
data: alloc::borrow::Cow::Owned(s),
data: Cow::Owned(s),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/asn1_types/strings/generalstring.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{asn1_string, TestValidCharset};
use crate::{Error, Result};
#[cfg(not(feature = "std"))]
use alloc::string::String;

asn1_string!(GeneralString);
Expand Down
1 change: 1 addition & 0 deletions src/asn1_types/strings/graphicstring.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{asn1_string, TestValidCharset};
use crate::{Error, Result};
#[cfg(not(feature = "std"))]
use alloc::string::String;

asn1_string!(GraphicString);
Expand Down
1 change: 1 addition & 0 deletions src/asn1_types/strings/ia5string.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{asn1_string, TestValidCharset};
use crate::{Error, Result};
#[cfg(not(feature = "std"))]
use alloc::string::String;

asn1_string!(Ia5String);
Expand Down
1 change: 1 addition & 0 deletions src/asn1_types/strings/numericstring.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{asn1_string, TestValidCharset};
use crate::{Error, Result};
#[cfg(not(feature = "std"))]
use alloc::string::String;

asn1_string!(NumericString);
Expand Down
1 change: 1 addition & 0 deletions src/asn1_types/strings/printablestring.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{asn1_string, TestValidCharset};
use crate::{Error, Result};
#[cfg(not(feature = "std"))]
use alloc::string::String;

asn1_string!(PrintableString);
Expand Down
1 change: 1 addition & 0 deletions src/asn1_types/strings/string.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::*;
#[cfg(not(feature = "std"))]
use alloc::string::String;
use core::convert::TryFrom;

Expand Down
1 change: 1 addition & 0 deletions src/asn1_types/strings/teletexstring.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{asn1_string, TestValidCharset};
use crate::{Error, Result};
#[cfg(not(feature = "std"))]
use alloc::string::String;

asn1_string!(TeletexString);
Expand Down
4 changes: 3 additions & 1 deletion src/asn1_types/strings/universalstring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

use crate::*;
use alloc::borrow::Cow;
#[cfg(not(feature = "std"))]
use alloc::string::{String, ToString};
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use core::convert::TryFrom;
use core::iter::FromIterator;
Expand Down Expand Up @@ -43,7 +45,7 @@ impl<'a> From<&'a str> for UniversalString<'a> {
impl From<String> for UniversalString<'_> {
fn from(s: String) -> Self {
Self {
data: alloc::borrow::Cow::Owned(s),
data: Cow::Owned(s),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/asn1_types/strings/utf8string.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::asn1_string;
use crate::Result;
use crate::TestValidCharset;
#[cfg(not(feature = "std"))]
use alloc::string::String;

asn1_string!(Utf8String);
Expand Down
1 change: 1 addition & 0 deletions src/asn1_types/strings/videotexstring.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{asn1_string, TestValidCharset};
use crate::{Error, Result};
#[cfg(not(feature = "std"))]
use alloc::string::String;

asn1_string!(VideotexString);
Expand Down
1 change: 1 addition & 0 deletions src/asn1_types/strings/visiblestring.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{asn1_string, TestValidCharset};
use crate::{Error, Result};
#[cfg(not(feature = "std"))]
use alloc::string::String;

asn1_string!(VisibleString);
Expand Down
12 changes: 5 additions & 7 deletions src/asn1_types/tagged/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ where
parse_der_container(tag, move |any: Any<'a>| {
any.header
.assert_tag(tag)
.map_err(|e| nom::Err::convert(e.into()))?;
.map_err(|e| Err::convert(e.into()))?;
f(any.data, any.header)
})
}
Expand All @@ -51,9 +51,7 @@ where
let tag = tag.into();
move |i| {
let (rem, tagged) = TaggedParser::from_der(i)?;
tagged
.assert_tag(tag)
.map_err(|e| nom::Err::convert(e.into()))?;
tagged.assert_tag(tag).map_err(|e| Err::convert(e.into()))?;
Ok((rem, tagged))
}
}
Expand All @@ -73,7 +71,7 @@ where
// verify tag of external header
any.header
.assert_tag(tag)
.map_err(|e| nom::Err::convert(e.into()))?;
.map_err(|e| Err::convert(e.into()))?;
// build a fake header with the expected tag
let Any { header, data } = any;
let header = Header {
Expand All @@ -93,10 +91,10 @@ where
E: ParseError<&'a [u8]> + From<Error>,
{
move |i: &[u8]| {
let (rem, any) = Any::from_der(i).map_err(nom::Err::convert)?;
let (rem, any) = Any::from_der(i).map_err(Err::convert)?;
any.header
.assert_tag(tag)
.map_err(|e| nom::Err::convert(e.into()))?;
.map_err(|e| Err::convert(e.into()))?;
let (_, output) = f(any)?;
Ok((rem, output))
}
Expand Down
8 changes: 4 additions & 4 deletions src/asn1_types/tagged/implicit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ where
};
match T::try_from(any) {
Ok(inner) => Ok((rem, TaggedValue::implicit(inner))),
Err(e) => Err(nom::Err::Error(e)),
Err(e) => Err(Err::Error(e)),
}
}
}
Expand Down Expand Up @@ -182,7 +182,7 @@ where
};
Ok((rem, tagged_value))
}
Err(e) => Err(nom::Err::Error(e)),
Err(e) => Err(Err::Error(e)),
}
}
}
Expand Down Expand Up @@ -217,7 +217,7 @@ where
},
data,
};
T::check_constraints(&any).map_err(|e| nom::Err::Error(e.into()))?;
T::check_constraints(&any).map_err(|e| Err::Error(e.into()))?;
match T::try_from(any) {
Ok(t) => {
let tagged_value = TaggedParser {
Expand All @@ -228,7 +228,7 @@ where
};
Ok((rem, tagged_value))
}
Err(e) => Err(nom::Err::Error(e)),
Err(e) => Err(Err::Error(e)),
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/asn1_types/tagged/optional.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use super::{explicit::TaggedExplicit, implicit::TaggedImplicit};
use crate::*;

/// Helper object to parse TAGGED OPTIONAL types (explicit or implicit)
Expand Down
1 change: 0 additions & 1 deletion src/asn1_types/utctime.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::datetime::decode_decimal;
use crate::*;
use core::convert::TryFrom;
use core::fmt;
Expand Down
1 change: 1 addition & 0 deletions src/datetime.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{Result, Tag};
use alloc::format;
#[cfg(not(feature = "std"))]
use alloc::string::ToString;
use core::fmt;
#[cfg(feature = "datetime")]
Expand Down
Loading

0 comments on commit 9690362

Please sign in to comment.