Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Resolve type_repetition_in_bounds clippy lint
Browse files Browse the repository at this point in the history
    error: this type has already been used as a bound predicate
       --> src/ser.rs:189:9
        |
    189 |         T: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = note: `-D clippy::type-repetition-in-bounds` implied by `-D clippy::pedantic`
        = help: consider combining the bounds: `T: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:203:9
        |
    203 |         T: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `T: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:217:9
        |
    217 |         V: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `V: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:298:9
        |
    298 |         T: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `T: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:318:9
        |
    318 |         T: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `T: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:338:9
        |
    338 |         V: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `V: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:358:9
        |
    358 |         V: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `V: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:378:9
        |
    378 |         T: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `T: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:385:9
        |
    385 |         T: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `T: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:392:9
        |
    392 |         K: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `K: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:393:9
        |
    393 |         V: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `V: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:413:9
        |
    413 |         V: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `V: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:433:9
        |
    433 |         V: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `V: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:566:9
        |
    566 |         T: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `T: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:579:9
        |
    579 |         T: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `T: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:590:9
        |
    590 |         V: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `V: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:685:9
        |
    685 |         T: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `T: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:702:9
        |
    702 |         T: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `T: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:718:9
        |
    718 |         V: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `V: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:734:9
        |
    734 |         V: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `V: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:751:9
        |
    751 |         T: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `T: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:759:9
        |
    759 |         T: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `T: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:770:9
        |
    770 |         K: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `K: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:771:9
        |
    771 |         V: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `V: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:788:9
        |
    788 |         V: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `V: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:805:9
        |
    805 |         V: ser::Serialize,
        |         ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `V: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:823:5
        |
    823 |     T: ser::Serialize,
        |     ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `T: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:834:5
        |
    834 |     T: ser::Serialize,
        |     ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `T: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/ser.rs:847:5
        |
    847 |     T: ser::Serialize,
        |     ^^^^^^^^^^^^^^^^^
        |
        = help: consider combining the bounds: `T: Sized + ser::Serialize`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/value/index.rs:126:5
        |
    126 |     T: Index,
        |     ^^^^^^^^
        |
        = help: consider combining the bounds: `T: Sized + Index`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

    error: this type has already been used as a bound predicate
       --> src/value/index.rs:146:48
        |
    146 |     impl<'a, T: ?Sized> Sealed for &'a T where T: Sealed {}
        |                                                ^^^^^^^^^
        |
        = help: consider combining the bounds: `T: Sized + Sealed`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds
  • Loading branch information
dtolnay committed May 1, 2022
1 parent 85baedf commit 7489760
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 59 deletions.
112 changes: 56 additions & 56 deletions src/ser.rs
Expand Up @@ -184,23 +184,23 @@ where
self.write(doc)
}

fn serialize_newtype_struct<T: ?Sized>(self, name: &'static str, value: &T) -> Result<()>
fn serialize_newtype_struct<T>(self, name: &'static str, value: &T) -> Result<()>
where
T: ser::Serialize,
T: ?Sized + ser::Serialize,
{
let doc = SerializerToYaml.serialize_newtype_struct(name, value)?;
self.write(doc)
}

fn serialize_newtype_variant<T: ?Sized>(
fn serialize_newtype_variant<T>(
self,
name: &'static str,
variant_index: u32,
variant: &'static str,
value: &T,
) -> Result<()>
where
T: ser::Serialize,
T: ?Sized + ser::Serialize,
{
let doc =
SerializerToYaml.serialize_newtype_variant(name, variant_index, variant, value)?;
Expand All @@ -212,9 +212,9 @@ where
self.write(doc)
}

fn serialize_some<V: ?Sized>(self, value: &V) -> Result<()>
fn serialize_some<V>(self, value: &V) -> Result<()>
where
V: ser::Serialize,
V: ?Sized + ser::Serialize,
{
let doc = SerializerToYaml.serialize_some(value)?;
self.write(doc)
Expand Down Expand Up @@ -293,9 +293,9 @@ where
type Ok = ();
type Error = Error;

fn serialize_element<T: ?Sized>(&mut self, elem: &T) -> Result<()>
fn serialize_element<T>(&mut self, elem: &T) -> Result<()>
where
T: ser::Serialize,
T: ?Sized + ser::Serialize,
{
self.delegate.serialize_element(elem)
}
Expand All @@ -313,9 +313,9 @@ where
type Ok = ();
type Error = Error;

fn serialize_element<T: ?Sized>(&mut self, elem: &T) -> Result<()>
fn serialize_element<T>(&mut self, elem: &T) -> Result<()>
where
T: ser::Serialize,
T: ?Sized + ser::Serialize,
{
self.delegate.serialize_element(elem)
}
Expand All @@ -333,9 +333,9 @@ where
type Ok = ();
type Error = Error;

fn serialize_field<V: ?Sized>(&mut self, value: &V) -> Result<()>
fn serialize_field<V>(&mut self, value: &V) -> Result<()>
where
V: ser::Serialize,
V: ?Sized + ser::Serialize,
{
self.delegate.serialize_field(value)
}
Expand All @@ -353,9 +353,9 @@ where
type Ok = ();
type Error = Error;

fn serialize_field<V: ?Sized>(&mut self, v: &V) -> Result<()>
fn serialize_field<V>(&mut self, v: &V) -> Result<()>
where
V: ser::Serialize,
V: ?Sized + ser::Serialize,
{
self.delegate.serialize_field(v)
}
Expand All @@ -373,24 +373,24 @@ where
type Ok = ();
type Error = Error;

fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<()>
fn serialize_key<T>(&mut self, key: &T) -> Result<()>
where
T: ser::Serialize,
T: ?Sized + ser::Serialize,
{
self.delegate.serialize_key(key)
}

fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<()>
fn serialize_value<T>(&mut self, value: &T) -> Result<()>
where
T: ser::Serialize,
T: ?Sized + ser::Serialize,
{
self.delegate.serialize_value(value)
}

fn serialize_entry<K: ?Sized, V: ?Sized>(&mut self, key: &K, value: &V) -> Result<()>
fn serialize_entry<K, V>(&mut self, key: &K, value: &V) -> Result<()>
where
K: ser::Serialize,
V: ser::Serialize,
K: ?Sized + ser::Serialize,
V: ?Sized + ser::Serialize,
{
self.delegate.serialize_entry(key, value)
}
Expand All @@ -408,9 +408,9 @@ where
type Ok = ();
type Error = Error;

fn serialize_field<V: ?Sized>(&mut self, key: &'static str, value: &V) -> Result<()>
fn serialize_field<V>(&mut self, key: &'static str, value: &V) -> Result<()>
where
V: ser::Serialize,
V: ?Sized + ser::Serialize,
{
self.delegate.serialize_field(key, value)
}
Expand All @@ -428,9 +428,9 @@ where
type Ok = ();
type Error = Error;

fn serialize_field<V: ?Sized>(&mut self, field: &'static str, v: &V) -> Result<()>
fn serialize_field<V>(&mut self, field: &'static str, v: &V) -> Result<()>
where
V: ser::Serialize,
V: ?Sized + ser::Serialize,
{
self.delegate.serialize_field(field, v)
}
Expand Down Expand Up @@ -561,22 +561,22 @@ impl ser::Serializer for SerializerToYaml {
Ok(Yaml::String(variant.to_owned()))
}

fn serialize_newtype_struct<T: ?Sized>(self, _name: &'static str, value: &T) -> Result<Yaml>
fn serialize_newtype_struct<T>(self, _name: &'static str, value: &T) -> Result<Yaml>
where
T: ser::Serialize,
T: ?Sized + ser::Serialize,
{
value.serialize(self)
}

fn serialize_newtype_variant<T: ?Sized>(
fn serialize_newtype_variant<T>(
self,
_name: &str,
_variant_index: u32,
variant: &str,
value: &T,
) -> Result<Yaml>
where
T: ser::Serialize,
T: ?Sized + ser::Serialize,
{
Ok(singleton_hash(to_yaml(variant)?, to_yaml(value)?))
}
Expand All @@ -585,9 +585,9 @@ impl ser::Serializer for SerializerToYaml {
self.serialize_unit()
}

fn serialize_some<V: ?Sized>(self, value: &V) -> Result<Yaml>
fn serialize_some<V>(self, value: &V) -> Result<Yaml>
where
V: ser::Serialize,
V: ?Sized + ser::Serialize,
{
value.serialize(self)
}
Expand Down Expand Up @@ -680,9 +680,9 @@ impl ser::SerializeSeq for SerializeArray {
type Ok = yaml::Yaml;
type Error = Error;

fn serialize_element<T: ?Sized>(&mut self, elem: &T) -> Result<()>
fn serialize_element<T>(&mut self, elem: &T) -> Result<()>
where
T: ser::Serialize,
T: ?Sized + ser::Serialize,
{
self.array.push(to_yaml(elem)?);
Ok(())
Expand All @@ -697,9 +697,9 @@ impl ser::SerializeTuple for SerializeArray {
type Ok = yaml::Yaml;
type Error = Error;

fn serialize_element<T: ?Sized>(&mut self, elem: &T) -> Result<()>
fn serialize_element<T>(&mut self, elem: &T) -> Result<()>
where
T: ser::Serialize,
T: ?Sized + ser::Serialize,
{
ser::SerializeSeq::serialize_element(self, elem)
}
Expand All @@ -713,9 +713,9 @@ impl ser::SerializeTupleStruct for SerializeArray {
type Ok = yaml::Yaml;
type Error = Error;

fn serialize_field<V: ?Sized>(&mut self, value: &V) -> Result<()>
fn serialize_field<V>(&mut self, value: &V) -> Result<()>
where
V: ser::Serialize,
V: ?Sized + ser::Serialize,
{
ser::SerializeSeq::serialize_element(self, value)
}
Expand All @@ -729,9 +729,9 @@ impl ser::SerializeTupleVariant for SerializeTupleVariant {
type Ok = yaml::Yaml;
type Error = Error;

fn serialize_field<V: ?Sized>(&mut self, v: &V) -> Result<()>
fn serialize_field<V>(&mut self, v: &V) -> Result<()>
where
V: ser::Serialize,
V: ?Sized + ser::Serialize,
{
self.array.push(to_yaml(v)?);
Ok(())
Expand All @@ -746,17 +746,17 @@ impl ser::SerializeMap for SerializeMap {
type Ok = yaml::Yaml;
type Error = Error;

fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<()>
fn serialize_key<T>(&mut self, key: &T) -> Result<()>
where
T: ser::Serialize,
T: ?Sized + ser::Serialize,
{
self.next_key = Some(to_yaml(key)?);
Ok(())
}

fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<()>
fn serialize_value<T>(&mut self, value: &T) -> Result<()>
where
T: ser::Serialize,
T: ?Sized + ser::Serialize,
{
match self.next_key.take() {
Some(key) => self.hash.insert(key, to_yaml(value)?),
Expand All @@ -765,10 +765,10 @@ impl ser::SerializeMap for SerializeMap {
Ok(())
}

fn serialize_entry<K: ?Sized, V: ?Sized>(&mut self, key: &K, value: &V) -> Result<()>
fn serialize_entry<K, V>(&mut self, key: &K, value: &V) -> Result<()>
where
K: ser::Serialize,
V: ser::Serialize,
K: ?Sized + ser::Serialize,
V: ?Sized + ser::Serialize,
{
self.hash.insert(to_yaml(key)?, to_yaml(value)?);
Ok(())
Expand All @@ -783,9 +783,9 @@ impl ser::SerializeStruct for SerializeStruct {
type Ok = yaml::Yaml;
type Error = Error;

fn serialize_field<V: ?Sized>(&mut self, key: &'static str, value: &V) -> Result<()>
fn serialize_field<V>(&mut self, key: &'static str, value: &V) -> Result<()>
where
V: ser::Serialize,
V: ?Sized + ser::Serialize,
{
self.hash.insert(to_yaml(key)?, to_yaml(value)?);
Ok(())
Expand All @@ -800,9 +800,9 @@ impl ser::SerializeStructVariant for SerializeStructVariant {
type Ok = yaml::Yaml;
type Error = Error;

fn serialize_field<V: ?Sized>(&mut self, field: &'static str, v: &V) -> Result<()>
fn serialize_field<V>(&mut self, field: &'static str, v: &V) -> Result<()>
where
V: ser::Serialize,
V: ?Sized + ser::Serialize,
{
self.hash.insert(to_yaml(field)?, to_yaml(v)?);
Ok(())
Expand All @@ -817,10 +817,10 @@ impl ser::SerializeStructVariant for SerializeStructVariant {
///
/// Serialization can fail if `T`'s implementation of `Serialize` decides to
/// return an error.
pub fn to_writer<W, T: ?Sized>(writer: W, value: &T) -> Result<()>
pub fn to_writer<W, T>(writer: W, value: &T) -> Result<()>
where
W: io::Write,
T: ser::Serialize,
T: ?Sized + ser::Serialize,
{
value.serialize(&mut Serializer::new(writer))
}
Expand All @@ -829,9 +829,9 @@ where
///
/// Serialization can fail if `T`'s implementation of `Serialize` decides to
/// return an error.
pub fn to_vec<T: ?Sized>(value: &T) -> Result<Vec<u8>>
pub fn to_vec<T>(value: &T) -> Result<Vec<u8>>
where
T: ser::Serialize,
T: ?Sized + ser::Serialize,
{
let mut vec = Vec::with_capacity(128);
to_writer(&mut vec, value)?;
Expand All @@ -842,9 +842,9 @@ where
///
/// Serialization can fail if `T`'s implementation of `Serialize` decides to
/// return an error.
pub fn to_string<T: ?Sized>(value: &T) -> Result<String>
pub fn to_string<T>(value: &T) -> Result<String>
where
T: ser::Serialize,
T: ?Sized + ser::Serialize,
{
String::from_utf8(to_vec(value)?).map_err(error::string_utf8)
}
Expand Down
6 changes: 3 additions & 3 deletions src/value/index.rs
Expand Up @@ -121,9 +121,9 @@ impl Index for String {
}
}

impl<'a, T: ?Sized> Index for &'a T
impl<'a, T> Index for &'a T
where
T: Index,
T: ?Sized + Index,
{
fn index_into<'v>(&self, v: &'v Value) -> Option<&'v Value> {
(**self).index_into(v)
Expand All @@ -143,7 +143,7 @@ mod private {
impl Sealed for str {}
impl Sealed for String {}
impl Sealed for super::Value {}
impl<'a, T: ?Sized> Sealed for &'a T where T: Sealed {}
impl<'a, T> Sealed for &'a T where T: ?Sized + Sealed {}
}

/// Used in panic messages.
Expand Down

0 comments on commit 7489760

Please sign in to comment.