Skip to content

Commit

Permalink
Fix all clippy checks
Browse files Browse the repository at this point in the history
These errors break the tests and were all added to the latest version of
clippy. This was breaking the bi-daily routine test runs.
  • Loading branch information
acatton committed Oct 9, 2024
1 parent e158e71 commit b77a147
Show file tree
Hide file tree
Showing 18 changed files with 53 additions and 55 deletions.
36 changes: 17 additions & 19 deletions src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl<'de> Deserializer<'de> {
}
}

impl<'de> Iterator for Deserializer<'de> {
impl Iterator for Deserializer<'_> {
type Item = Self;

fn next(&mut self) -> Option<Self> {
Expand Down Expand Up @@ -649,7 +649,7 @@ struct SeqAccess<'de, 'document, 'seq> {
len: usize,
}

impl<'de, 'document, 'seq> de::SeqAccess<'de> for SeqAccess<'de, 'document, 'seq> {
impl<'de> de::SeqAccess<'de> for SeqAccess<'de, '_, '_> {
type Error = Error;

fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>>
Expand Down Expand Up @@ -687,7 +687,7 @@ struct MapAccess<'de, 'document, 'map> {
key: Option<&'document [u8]>,
}

impl<'de, 'document, 'map> de::MapAccess<'de> for MapAccess<'de, 'document, 'map> {
impl<'de> de::MapAccess<'de> for MapAccess<'de, '_, '_> {
type Error = Error;

fn next_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>>
Expand Down Expand Up @@ -743,7 +743,7 @@ struct EnumAccess<'de, 'document, 'variant> {
tag: &'document str,
}

impl<'de, 'document, 'variant> de::EnumAccess<'de> for EnumAccess<'de, 'document, 'variant> {
impl<'de, 'variant> de::EnumAccess<'de> for EnumAccess<'de, '_, 'variant> {
type Error = Error;
type Variant = DeserializerFromEvents<'de, 'variant>;

Expand All @@ -768,7 +768,7 @@ impl<'de, 'document, 'variant> de::EnumAccess<'de> for EnumAccess<'de, 'document
}
}

impl<'de, 'document> de::VariantAccess<'de> for DeserializerFromEvents<'de, 'document> {
impl<'de> de::VariantAccess<'de> for DeserializerFromEvents<'de, '_> {
type Error = Error;

fn unit_variant(mut self) -> Result<()> {
Expand Down Expand Up @@ -801,7 +801,7 @@ struct UnitVariantAccess<'de, 'document, 'variant> {
de: &'variant mut DeserializerFromEvents<'de, 'document>,
}

impl<'de, 'document, 'variant> de::EnumAccess<'de> for UnitVariantAccess<'de, 'document, 'variant> {
impl<'de> de::EnumAccess<'de> for UnitVariantAccess<'de, '_, '_> {
type Error = Error;
type Variant = Self;

Expand All @@ -813,9 +813,7 @@ impl<'de, 'document, 'variant> de::EnumAccess<'de> for UnitVariantAccess<'de, 'd
}
}

impl<'de, 'document, 'variant> de::VariantAccess<'de>
for UnitVariantAccess<'de, 'document, 'variant>
{
impl<'de> de::VariantAccess<'de> for UnitVariantAccess<'de, '_, '_> {
type Error = Error;

fn unit_variant(self) -> Result<()> {
Expand Down Expand Up @@ -1163,7 +1161,7 @@ fn invalid_type(event: &Event, exp: &dyn Expected) -> Error {
exp: &'a dyn Expected,
}

impl<'de, 'a> Visitor<'de> for InvalidType<'a> {
impl Visitor<'_> for InvalidType<'_> {
type Value = Void;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down Expand Up @@ -1195,7 +1193,7 @@ fn invalid_type(event: &Event, exp: &dyn Expected) -> Error {
}
}

fn parse_tag(libyaml_tag: &Option<Tag>) -> Option<&str> {
fn parse_tag(libyaml_tag: Option<&Tag>) -> Option<&str> {
let mut bytes: &[u8] = libyaml_tag.as_ref()?;
if let (b'!', rest) = bytes.split_first()? {
if !rest.is_empty() {
Expand All @@ -1207,7 +1205,7 @@ fn parse_tag(libyaml_tag: &Option<Tag>) -> Option<&str> {
}
}

impl<'de, 'document> de::Deserializer<'de> for &mut DeserializerFromEvents<'de, 'document> {
impl<'de> de::Deserializer<'de> for &mut DeserializerFromEvents<'de, '_> {
type Error = Error;

fn deserialize_any<V>(self, visitor: V) -> Result<V::Value>
Expand All @@ -1216,7 +1214,7 @@ impl<'de, 'document> de::Deserializer<'de> for &mut DeserializerFromEvents<'de,
{
let tagged_already = self.current_enum.is_some();
let (next, mark) = self.next_event_mark()?;
fn enum_tag(tag: &Option<Tag>, tagged_already: bool) -> Option<&str> {
fn enum_tag(tag: Option<&Tag>, tagged_already: bool) -> Option<&str> {
if tagged_already {
return None;
}
Expand All @@ -1226,7 +1224,7 @@ impl<'de, 'document> de::Deserializer<'de> for &mut DeserializerFromEvents<'de,
match next {
Event::Alias(mut pos) => break self.jump(&mut pos)?.deserialize_any(visitor),
Event::Scalar(scalar) => {
if let Some(tag) = enum_tag(&scalar.tag, tagged_already) {
if let Some(tag) = enum_tag(scalar.tag.as_ref(), tagged_already) {
*self.pos -= 1;
break visitor.visit_enum(EnumAccess {
de: self,
Expand All @@ -1237,7 +1235,7 @@ impl<'de, 'document> de::Deserializer<'de> for &mut DeserializerFromEvents<'de,
break visit_scalar(visitor, scalar, tagged_already);
}
Event::SequenceStart(sequence) => {
if let Some(tag) = enum_tag(&sequence.tag, tagged_already) {
if let Some(tag) = enum_tag(sequence.tag.as_ref(), tagged_already) {
*self.pos -= 1;
break visitor.visit_enum(EnumAccess {
de: self,
Expand All @@ -1248,7 +1246,7 @@ impl<'de, 'document> de::Deserializer<'de> for &mut DeserializerFromEvents<'de,
break self.visit_sequence(visitor, mark);
}
Event::MappingStart(mapping) => {
if let Some(tag) = enum_tag(&mapping.tag, tagged_already) {
if let Some(tag) = enum_tag(mapping.tag.as_ref(), tagged_already) {
*self.pos -= 1;
break visitor.visit_enum(EnumAccess {
de: self,
Expand Down Expand Up @@ -1744,7 +1742,7 @@ impl<'de, 'document> de::Deserializer<'de> for &mut DeserializerFromEvents<'de,
.deserialize_enum(name, variants, visitor)
}
Event::Scalar(scalar) => {
if let Some(tag) = parse_tag(&scalar.tag) {
if let Some(tag) = parse_tag(scalar.tag.as_ref()) {
return visitor.visit_enum(EnumAccess {
de: self,
name: Some(name),
Expand All @@ -1754,7 +1752,7 @@ impl<'de, 'document> de::Deserializer<'de> for &mut DeserializerFromEvents<'de,
visitor.visit_enum(UnitVariantAccess { de: self })
}
Event::MappingStart(mapping) => {
if let Some(tag) = parse_tag(&mapping.tag) {
if let Some(tag) = parse_tag(mapping.tag.as_ref()) {
return visitor.visit_enum(EnumAccess {
de: self,
name: Some(name),
Expand All @@ -1766,7 +1764,7 @@ impl<'de, 'document> de::Deserializer<'de> for &mut DeserializerFromEvents<'de,
Err(error::fix_mark(err, mark, self.path))
}
Event::SequenceStart(sequence) => {
if let Some(tag) = parse_tag(&sequence.tag) {
if let Some(tag) = parse_tag(sequence.tag.as_ref()) {
return visitor.visit_enum(EnumAccess {
de: self,
name: Some(name),
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl ErrorImpl {
_ => {
f.write_str("Error(")?;
struct MessageNoMark<'a>(&'a ErrorImpl);
impl<'a> Display for MessageNoMark<'a> {
impl Display for MessageNoMark<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.0.message_no_mark(f)
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,5 @@ mod private {
impl Sealed for str {}
impl Sealed for String {}
impl Sealed for crate::Value {}
impl<'a, T> Sealed for &'a T where T: ?Sized + Sealed {}
impl<T> Sealed for &T where T: ?Sized + Sealed {}
}
8 changes: 4 additions & 4 deletions src/libyaml/cstr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ pub(crate) struct CStr<'a> {
marker: PhantomData<&'a [u8]>,
}

unsafe impl<'a> Send for CStr<'a> {}
unsafe impl<'a> Sync for CStr<'a> {}
unsafe impl Send for CStr<'_> {}
unsafe impl Sync for CStr<'_> {}

impl<'a> CStr<'a> {
pub fn from_bytes_with_nul(bytes: &'static [u8]) -> Self {
Expand Down Expand Up @@ -44,7 +44,7 @@ impl<'a> CStr<'a> {
}
}

impl<'a> Display for CStr<'a> {
impl Display for CStr<'_> {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
let ptr = self.ptr.as_ptr();
let len = self.len();
Expand All @@ -53,7 +53,7 @@ impl<'a> Display for CStr<'a> {
}
}

impl<'a> Debug for CStr<'a> {
impl Debug for CStr<'_> {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
let ptr = self.ptr.as_ptr();
let len = self.len();
Expand Down
2 changes: 1 addition & 1 deletion src/libyaml/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ unsafe fn write_handler(data: *mut c_void, buffer: *mut u8, size: u64) -> i32 {
}
}

impl<'a> Drop for EmitterPinned<'a> {
impl Drop for EmitterPinned<'_> {
fn drop(&mut self) {
unsafe { sys::yaml_emitter_delete(&mut self.sys) }
}
Expand Down
6 changes: 3 additions & 3 deletions src/libyaml/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ unsafe fn optional_tag(tag: *const u8) -> Option<Tag> {
Some(Tag(Box::from(cstr.to_bytes())))
}

impl<'input> Debug for Scalar<'input> {
impl Debug for Scalar<'_> {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
let Scalar {
anchor,
Expand All @@ -172,7 +172,7 @@ impl<'input> Debug for Scalar<'input> {

struct LossySlice<'a>(&'a [u8]);

impl<'a> Debug for LossySlice<'a> {
impl Debug for LossySlice<'_> {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
cstr::debug_lossy(self.0, formatter)
}
Expand All @@ -194,7 +194,7 @@ impl Debug for Anchor {
}
}

impl<'input> Drop for ParserPinned<'input> {
impl Drop for ParserPinned<'_> {
fn drop(&mut self) {
unsafe { sys::yaml_parser_delete(&mut self.sys) }
}
Expand Down
6 changes: 3 additions & 3 deletions src/mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ pub trait Index: private::Sealed {

struct HashLikeValue<'a>(&'a str);

impl<'a> indexmap::Equivalent<Value> for HashLikeValue<'a> {
impl indexmap::Equivalent<Value> for HashLikeValue<'_> {
fn equivalent(&self, key: &Value) -> bool {
match key {
Value::String(string) => self.0 == string,
Expand All @@ -276,7 +276,7 @@ impl<'a> indexmap::Equivalent<Value> for HashLikeValue<'a> {
}

// NOTE: This impl must be consistent with Value's Hash impl.
impl<'a> Hash for HashLikeValue<'a> {
impl Hash for HashLikeValue<'_> {
fn hash<H: Hasher>(&self, state: &mut H) {
const STRING: Value = Value::String(String::new());
mem::discriminant(&STRING).hash(state);
Expand Down Expand Up @@ -835,7 +835,7 @@ struct DuplicateKeyError<'a> {
entry: OccupiedEntry<'a>,
}

impl<'a> Display for DuplicateKeyError<'a> {
impl Display for DuplicateKeyError<'_> {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str("duplicate entry ")?;
match self.entry.key() {
Expand Down
4 changes: 2 additions & 2 deletions src/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ impl Serialize for Number {

struct NumberVisitor;

impl<'de> Visitor<'de> for NumberVisitor {
impl Visitor<'_> for NumberVisitor {
type Value = Number;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down Expand Up @@ -464,7 +464,7 @@ impl<'de> Deserializer<'de> for Number {
}
}

impl<'de, 'a> Deserializer<'de> for &'a Number {
impl<'de> Deserializer<'de> for &Number {
type Error = Error;

#[inline]
Expand Down
4 changes: 2 additions & 2 deletions src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ pub enum Path<'a> {
Unknown { parent: &'a Path<'a> },
}

impl<'a> Display for Path<'a> {
impl Display for Path<'_> {
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
struct Parent<'a>(&'a Path<'a>);

impl<'a> Display for Parent<'a> {
impl Display for Parent<'_> {
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match self.0 {
Path::Root => Ok(()),
Expand Down
18 changes: 9 additions & 9 deletions src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ where
}
}

impl<'a, W> ser::Serializer for &'a mut Serializer<W>
impl<W> ser::Serializer for &mut Serializer<W>
where
W: io::Write,
{
Expand Down Expand Up @@ -308,7 +308,7 @@ where
fn serialize_str(self, value: &str) -> Result<()> {
struct InferScalarStyle;

impl<'de> Visitor<'de> for InferScalarStyle {
impl Visitor<'_> for InferScalarStyle {
type Value = ScalarStyle;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down Expand Up @@ -523,7 +523,7 @@ where
}
}

impl<'a, W> ser::SerializeSeq for &'a mut Serializer<W>
impl<W> ser::SerializeSeq for &mut Serializer<W>
where
W: io::Write,
{
Expand All @@ -542,7 +542,7 @@ where
}
}

impl<'a, W> ser::SerializeTuple for &'a mut Serializer<W>
impl<W> ser::SerializeTuple for &mut Serializer<W>
where
W: io::Write,
{
Expand All @@ -561,7 +561,7 @@ where
}
}

impl<'a, W> ser::SerializeTupleStruct for &'a mut Serializer<W>
impl<W> ser::SerializeTupleStruct for &mut Serializer<W>
where
W: io::Write,
{
Expand All @@ -580,7 +580,7 @@ where
}
}

impl<'a, W> ser::SerializeTupleVariant for &'a mut Serializer<W>
impl<W> ser::SerializeTupleVariant for &mut Serializer<W>
where
W: io::Write,
{
Expand All @@ -599,7 +599,7 @@ where
}
}

impl<'a, W> ser::SerializeMap for &'a mut Serializer<W>
impl<W> ser::SerializeMap for &mut Serializer<W>
where
W: io::Write,
{
Expand Down Expand Up @@ -647,7 +647,7 @@ where
}
}

impl<'a, W> ser::SerializeStruct for &'a mut Serializer<W>
impl<W> ser::SerializeStruct for &mut Serializer<W>
where
W: io::Write,
{
Expand All @@ -667,7 +667,7 @@ where
}
}

impl<'a, W> ser::SerializeStructVariant for &'a mut Serializer<W>
impl<W> ser::SerializeStructVariant for &mut Serializer<W>
where
W: io::Write,
{
Expand Down
2 changes: 1 addition & 1 deletion src/value/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ struct EnumDeserializer<'a> {
value: Option<Value>,
}

impl<'a, 'de> EnumAccess<'de> for EnumDeserializer<'a> {
impl<'de> EnumAccess<'de> for EnumDeserializer<'_> {
type Error = Error;
type Variant = VariantDeserializer;

Expand Down
2 changes: 1 addition & 1 deletion src/value/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl Debug for Value {

struct DisplayNumber<'a>(&'a Number);

impl<'a> Debug for DisplayNumber<'a> {
impl Debug for DisplayNumber<'_> {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Display::fmt(self.0, formatter)
}
Expand Down
Loading

0 comments on commit b77a147

Please sign in to comment.