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

Commit

Permalink
Resolve multiple_bound_locations clippy lint
Browse files Browse the repository at this point in the history
    warning: bound is defined in more than one place
      --> src/assert.rs:67:26
       |
    67 | pub fn assert_ser_tokens<T: ?Sized>(value: &T, tokens: &[Token])
       |                          ^
    68 | where
    69 |     T: Serialize,
       |     ^
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
       = note: `#[warn(clippy::multiple_bound_locations)]` on by default

    warning: bound is defined in more than one place
       --> src/assert.rs:125:32
        |
    125 | pub fn assert_ser_tokens_error<T: ?Sized>(value: &T, tokens: &[Token], error: &str)
        |                                ^
    126 | where
    127 |     T: Serialize,
        |     ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> src/configure.rs:234:41
        |
    234 |             fn serialize_newtype_struct<T: ?Sized>(
        |                                         ^
    ...
    240 |                 T: Serialize,
        |                 ^
    ...
    469 | impl_serializer!(Readable, true);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:245:42
        |
    245 |             fn serialize_newtype_variant<T: ?Sized>(
        |                                          ^
    ...
    253 |                 T: Serialize,
        |                 ^
    ...
    469 | impl_serializer!(Readable, true);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:263:31
        |
    263 |             fn serialize_some<T: ?Sized>(self, value: &T) -> Result<S::Ok, Self::Error>
        |                               ^
    264 |             where
    265 |                 T: Serialize,
        |                 ^
    ...
    469 | impl_serializer!(Readable, true);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:329:34
        |
    329 |             fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), S::Error>
        |                                  ^
    330 |             where
    331 |                 T: Serialize,
        |                 ^
    ...
    469 | impl_serializer!(Readable, true);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:346:34
        |
    346 |             fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), S::Error>
        |                                  ^
    347 |             where
    348 |                 T: Serialize,
        |                 ^
    ...
    469 | impl_serializer!(Readable, true);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:363:32
        |
    363 |             fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), S::Error>
        |                                ^
    364 |             where
    365 |                 T: Serialize,
        |                 ^
    ...
    469 | impl_serializer!(Readable, true);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:380:32
        |
    380 |             fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), S::Error>
        |                                ^
    381 |             where
    382 |                 T: Serialize,
        |                 ^
    ...
    469 | impl_serializer!(Readable, true);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:397:30
        |
    397 |             fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), S::Error>
        |                              ^
    398 |             where
    399 |                 T: Serialize,
        |                 ^
    ...
    469 | impl_serializer!(Readable, true);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:403:32
        |
    403 |             fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), S::Error>
        |                                ^
    404 |             where
    405 |                 T: Serialize,
        |                 ^
    ...
    469 | impl_serializer!(Readable, true);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:409:32
        |
    409 |             fn serialize_entry<K: ?Sized, V: ?Sized>(
        |                                ^
    ...
    415 |                 K: Serialize,
        |                 ^
    ...
    469 | impl_serializer!(Readable, true);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:409:43
        |
    409 |             fn serialize_entry<K: ?Sized, V: ?Sized>(
        |                                           ^
    ...
    416 |                 V: Serialize,
        |                 ^
    ...
    469 | impl_serializer!(Readable, true);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:431:32
        |
    431 |             fn serialize_field<T: ?Sized>(
        |                                ^
    ...
    437 |                 T: Serialize,
        |                 ^
    ...
    469 | impl_serializer!(Readable, true);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:452:32
        |
    452 |             fn serialize_field<T: ?Sized>(
        |                                ^
    ...
    458 |                 T: Serialize,
        |                 ^
    ...
    469 | impl_serializer!(Readable, true);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:234:41
        |
    234 |             fn serialize_newtype_struct<T: ?Sized>(
        |                                         ^
    ...
    240 |                 T: Serialize,
        |                 ^
    ...
    470 | impl_serializer!(Compact, false);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:245:42
        |
    245 |             fn serialize_newtype_variant<T: ?Sized>(
        |                                          ^
    ...
    253 |                 T: Serialize,
        |                 ^
    ...
    470 | impl_serializer!(Compact, false);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:263:31
        |
    263 |             fn serialize_some<T: ?Sized>(self, value: &T) -> Result<S::Ok, Self::Error>
        |                               ^
    264 |             where
    265 |                 T: Serialize,
        |                 ^
    ...
    470 | impl_serializer!(Compact, false);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:329:34
        |
    329 |             fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), S::Error>
        |                                  ^
    330 |             where
    331 |                 T: Serialize,
        |                 ^
    ...
    470 | impl_serializer!(Compact, false);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:346:34
        |
    346 |             fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), S::Error>
        |                                  ^
    347 |             where
    348 |                 T: Serialize,
        |                 ^
    ...
    470 | impl_serializer!(Compact, false);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:363:32
        |
    363 |             fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), S::Error>
        |                                ^
    364 |             where
    365 |                 T: Serialize,
        |                 ^
    ...
    470 | impl_serializer!(Compact, false);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:380:32
        |
    380 |             fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), S::Error>
        |                                ^
    381 |             where
    382 |                 T: Serialize,
        |                 ^
    ...
    470 | impl_serializer!(Compact, false);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:397:30
        |
    397 |             fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), S::Error>
        |                              ^
    398 |             where
    399 |                 T: Serialize,
        |                 ^
    ...
    470 | impl_serializer!(Compact, false);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:403:32
        |
    403 |             fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), S::Error>
        |                                ^
    404 |             where
    405 |                 T: Serialize,
        |                 ^
    ...
    470 | impl_serializer!(Compact, false);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:409:32
        |
    409 |             fn serialize_entry<K: ?Sized, V: ?Sized>(
        |                                ^
    ...
    415 |                 K: Serialize,
        |                 ^
    ...
    470 | impl_serializer!(Compact, false);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:409:43
        |
    409 |             fn serialize_entry<K: ?Sized, V: ?Sized>(
        |                                           ^
    ...
    416 |                 V: Serialize,
        |                 ^
    ...
    470 | impl_serializer!(Compact, false);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:431:32
        |
    431 |             fn serialize_field<T: ?Sized>(
        |                                ^
    ...
    437 |                 T: Serialize,
        |                 ^
    ...
    470 | impl_serializer!(Compact, false);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/configure.rs:452:32
        |
    452 |             fn serialize_field<T: ?Sized>(
        |                                ^
    ...
    458 |                 T: Serialize,
        |                 ^
    ...
    470 | impl_serializer!(Compact, false);
        | -------------------------------- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
        = note: this warning originates in the macro `impl_serializer` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: bound is defined in more than one place
       --> src/ser.rs:191:33
        |
    191 |     fn serialize_newtype_struct<T: ?Sized>(self, name: &'static str, value: &T) -> Result<(), Error>
        |                                 ^
    192 |     where
    193 |         T: Serialize,
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> src/ser.rs:199:34
        |
    199 |     fn serialize_newtype_variant<T: ?Sized>(
        |                                  ^
    ...
    207 |         T: Serialize,
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> src/ser.rs:223:23
        |
    223 |     fn serialize_some<T: ?Sized>(self, value: &T) -> Result<(), Error>
        |                       ^
    224 |     where
    225 |         T: Serialize,
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> src/ser.rs:323:26
        |
    323 |     fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Error>
        |                          ^
    324 |     where
    325 |         T: Serialize,
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> src/ser.rs:340:26
        |
    340 |     fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Error>
        |                          ^
    341 |     where
    342 |         T: Serialize,
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> src/ser.rs:357:24
        |
    357 |     fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Error>
        |                        ^
    358 |     where
    359 |         T: Serialize,
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> src/ser.rs:374:24
        |
    374 |     fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Error>
        |                        ^
    375 |     where
    376 |         T: Serialize,
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> src/ser.rs:395:22
        |
    395 |     fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), Self::Error>
        |                      ^
    396 |     where
    397 |         T: Serialize,
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> src/ser.rs:402:24
        |
    402 |     fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
        |                        ^
    403 |     where
    404 |         T: Serialize,
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> src/ser.rs:419:24
        |
    419 |     fn serialize_field<T: ?Sized>(
        |                        ^
    ...
    425 |         T: Serialize,
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations

    warning: bound is defined in more than one place
       --> src/ser.rs:441:24
        |
    441 |     fn serialize_field<T: ?Sized>(
        |                        ^
    ...
    447 |         T: Serialize,
        |         ^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations
  • Loading branch information
dtolnay committed Feb 28, 2024
1 parent 1bedc0c commit 0d64285
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 76 deletions.
8 changes: 4 additions & 4 deletions src/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ where
/// );
/// ```
#[cfg_attr(not(no_track_caller), track_caller)]
pub fn assert_ser_tokens<T: ?Sized>(value: &T, tokens: &[Token])
pub fn assert_ser_tokens<T>(value: &T, tokens: &[Token])
where
T: Serialize,
T: ?Sized + Serialize,
{
let mut ser = Serializer::new(tokens);
match value.serialize(&mut ser) {
Expand Down Expand Up @@ -122,9 +122,9 @@ where
/// }
/// ```
#[cfg_attr(not(no_track_caller), track_caller)]
pub fn assert_ser_tokens_error<T: ?Sized>(value: &T, tokens: &[Token], error: &str)
pub fn assert_ser_tokens_error<T>(value: &T, tokens: &[Token], error: &str)
where
T: Serialize,
T: ?Sized + Serialize,
{
let mut ser = Serializer::new(tokens);
match value.serialize(&mut ser) {
Expand Down
72 changes: 30 additions & 42 deletions src/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ pub trait Configure {
}
}

impl<T: ?Sized> Configure for T {}
impl<T> Configure for T where T: ?Sized {}

impl<T: ?Sized> Serialize for Readable<T>
impl<T> Serialize for Readable<T>
where
T: Serialize,
T: ?Sized + Serialize,
{
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
Expand All @@ -100,9 +100,9 @@ where
self.0.serialize(Readable(serializer))
}
}
impl<T: ?Sized> Serialize for Compact<T>
impl<T> Serialize for Compact<T>
where
T: Serialize,
T: ?Sized + Serialize,
{
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
Expand Down Expand Up @@ -231,26 +231,26 @@ macro_rules! impl_serializer {
self.0.serialize_unit_variant(name, variant_index, variant)
}

fn serialize_newtype_struct<T: ?Sized>(
fn serialize_newtype_struct<T>(
self,
name: &'static str,
value: &T,
) -> Result<S::Ok, S::Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
self.0.serialize_newtype_struct(name, &$wrapper(value))
}

fn serialize_newtype_variant<T: ?Sized>(
fn serialize_newtype_variant<T>(
self,
name: &'static str,
variant_index: u32,
variant: &'static str,
value: &T,
) -> Result<S::Ok, S::Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
self.0
.serialize_newtype_variant(name, variant_index, variant, &$wrapper(value))
Expand All @@ -260,9 +260,9 @@ macro_rules! impl_serializer {
self.0.serialize_none()
}

fn serialize_some<T: ?Sized>(self, value: &T) -> Result<S::Ok, Self::Error>
fn serialize_some<T>(self, value: &T) -> Result<S::Ok, Self::Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
self.0.serialize_some(&$wrapper(value))
}
Expand Down Expand Up @@ -326,9 +326,9 @@ macro_rules! impl_serializer {
{
type Ok = S::Ok;
type Error = S::Error;
fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), S::Error>
fn serialize_element<T>(&mut self, value: &T) -> Result<(), S::Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
self.0.serialize_element(&$wrapper(value))
}
Expand All @@ -343,9 +343,9 @@ macro_rules! impl_serializer {
{
type Ok = S::Ok;
type Error = S::Error;
fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), S::Error>
fn serialize_element<T>(&mut self, value: &T) -> Result<(), S::Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
self.0.serialize_element(&$wrapper(value))
}
Expand All @@ -360,9 +360,9 @@ macro_rules! impl_serializer {
{
type Ok = S::Ok;
type Error = S::Error;
fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), S::Error>
fn serialize_field<T>(&mut self, value: &T) -> Result<(), S::Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
self.0.serialize_field(&$wrapper(value))
}
Expand All @@ -377,9 +377,9 @@ macro_rules! impl_serializer {
{
type Ok = S::Ok;
type Error = S::Error;
fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), S::Error>
fn serialize_field<T>(&mut self, value: &T) -> Result<(), S::Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
self.0.serialize_field(&$wrapper(value))
}
Expand All @@ -394,26 +394,22 @@ macro_rules! impl_serializer {
{
type Ok = S::Ok;
type Error = S::Error;
fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), S::Error>
fn serialize_key<T>(&mut self, key: &T) -> Result<(), S::Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
self.0.serialize_key(&$wrapper(key))
}
fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), S::Error>
fn serialize_value<T>(&mut self, value: &T) -> Result<(), S::Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
self.0.serialize_value(&$wrapper(value))
}
fn serialize_entry<K: ?Sized, V: ?Sized>(
&mut self,
key: &K,
value: &V,
) -> Result<(), S::Error>
fn serialize_entry<K, V>(&mut self, key: &K, value: &V) -> Result<(), S::Error>
where
K: Serialize,
V: Serialize,
K: ?Sized + Serialize,
V: ?Sized + Serialize,
{
self.0.serialize_entry(key, &$wrapper(value))
}
Expand All @@ -428,13 +424,9 @@ macro_rules! impl_serializer {
{
type Ok = S::Ok;
type Error = S::Error;
fn serialize_field<T: ?Sized>(
&mut self,
name: &'static str,
field: &T,
) -> Result<(), S::Error>
fn serialize_field<T>(&mut self, name: &'static str, field: &T) -> Result<(), S::Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
self.0.serialize_field(name, &$wrapper(field))
}
Expand All @@ -449,13 +441,9 @@ macro_rules! impl_serializer {
{
type Ok = S::Ok;
type Error = S::Error;
fn serialize_field<T: ?Sized>(
&mut self,
name: &'static str,
field: &T,
) -> Result<(), S::Error>
fn serialize_field<T>(&mut self, name: &'static str, field: &T) -> Result<(), S::Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
self.0.serialize_field(name, &$wrapper(field))
}
Expand Down
52 changes: 22 additions & 30 deletions src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,23 +188,23 @@ impl<'s, 'a> ser::Serializer for &'s mut Serializer<'a> {
Ok(())
}

fn serialize_newtype_struct<T: ?Sized>(self, name: &'static str, value: &T) -> Result<(), Error>
fn serialize_newtype_struct<T>(self, name: &'static str, value: &T) -> Result<(), Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
assert_next_token!(self, NewtypeStruct { name });
value.serialize(self)
}

fn serialize_newtype_variant<T: ?Sized>(
fn serialize_newtype_variant<T>(
self,
name: &'static str,
_variant_index: u32,
variant: &'static str,
value: &T,
) -> Result<(), Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
if self.tokens.first() == Some(&Token::Enum { name }) {
self.next_token();
Expand All @@ -220,9 +220,9 @@ impl<'s, 'a> ser::Serializer for &'s mut Serializer<'a> {
Ok(())
}

fn serialize_some<T: ?Sized>(self, value: &T) -> Result<(), Error>
fn serialize_some<T>(self, value: &T) -> Result<(), Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
assert_next_token!(self, Some);
value.serialize(self)
Expand Down Expand Up @@ -320,9 +320,9 @@ impl<'s, 'a> ser::SerializeSeq for &'s mut Serializer<'a> {
type Ok = ();
type Error = Error;

fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Error>
fn serialize_element<T>(&mut self, value: &T) -> Result<(), Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
value.serialize(&mut **self)
}
Expand All @@ -337,9 +337,9 @@ impl<'s, 'a> ser::SerializeTuple for &'s mut Serializer<'a> {
type Ok = ();
type Error = Error;

fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Error>
fn serialize_element<T>(&mut self, value: &T) -> Result<(), Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
value.serialize(&mut **self)
}
Expand All @@ -354,9 +354,9 @@ impl<'s, 'a> ser::SerializeTupleStruct for &'s mut Serializer<'a> {
type Ok = ();
type Error = Error;

fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Error>
fn serialize_field<T>(&mut self, value: &T) -> Result<(), Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
value.serialize(&mut **self)
}
Expand All @@ -371,9 +371,9 @@ impl<'s, 'a> ser::SerializeTupleVariant for Variant<'s, 'a> {
type Ok = ();
type Error = Error;

fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Error>
fn serialize_field<T>(&mut self, value: &T) -> Result<(), Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
value.serialize(&mut *self.ser)
}
Expand All @@ -392,16 +392,16 @@ impl<'s, 'a> ser::SerializeMap for &'s mut Serializer<'a> {
type Ok = ();
type Error = Error;

fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), Self::Error>
fn serialize_key<T>(&mut self, key: &T) -> Result<(), Self::Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
key.serialize(&mut **self)
}

fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
fn serialize_value<T>(&mut self, value: &T) -> Result<(), Self::Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
value.serialize(&mut **self)
}
Expand All @@ -416,13 +416,9 @@ impl<'s, 'a> ser::SerializeStruct for &'s mut Serializer<'a> {
type Ok = ();
type Error = Error;

fn serialize_field<T: ?Sized>(
&mut self,
key: &'static str,
value: &T,
) -> Result<(), Self::Error>
fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), Self::Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
key.serialize(&mut **self)?;
value.serialize(&mut **self)
Expand All @@ -438,13 +434,9 @@ impl<'s, 'a> ser::SerializeStructVariant for Variant<'s, 'a> {
type Ok = ();
type Error = Error;

fn serialize_field<T: ?Sized>(
&mut self,
key: &'static str,
value: &T,
) -> Result<(), Self::Error>
fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), Self::Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
key.serialize(&mut *self.ser)?;
value.serialize(&mut *self.ser)
Expand Down

0 comments on commit 0d64285

Please sign in to comment.