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

fix: ambiguous associated item in forward_to_deserialize_any! #2732

Merged
merged 1 commit into from Apr 27, 2024

Conversation

aatifsyed
Copy link
Contributor

Hit in serde-save, the following code fails to compile:

enum Value {
    Error,
}

impl<'de> serde::Deserializer<'de> for Value {
    type Error = serde::de::value::Error;
    fn deserialize_any<V>(self, _: V) -> Result<V::Value, serde::de::value::Error>
    where
        V: serde::de::Visitor<'de>,
    {
        todo!()
    }
    serde::forward_to_deserialize_any! {
        bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string
        bytes byte_buf option unit unit_struct newtype_struct seq tuple
        tuple_struct map struct enum identifier ignored_any
    }
}
error: ambiguous associated item
   --> src/lib.rs:16:5
    |
16  | /     serde::forward_to_deserialize_any! {
17  | |         bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string
18  | |         bytes byte_buf option unit unit_struct newtype_struct seq tuple
19  | |         tuple_struct map struct enum identifier ignored_any
20  | |     }
    | |_____^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #57644 <https://github.com/rust-lang/rust/issues/57644>
note: `Error` could refer to the variant defined here
   --> src/lib.rs:5:5
    |
5   |     Error,
    |     ^^^^^
note: `Error` could also refer to the associated type defined here
   --> /playground/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.197/src/de/mod.rs:911:5
    |
911 |     type Error: Error;
    |     ^^^^^^^^^^^^^^^^^
    = note: `#[deny(ambiguous_associated_items)]` on by default
    = note: this error originates in the macro `forward_to_deserialize_any_method` which comes from the expansion of the macro `serde::forward_to_deserialize_any` (in Nightly builds, run with -Z macro-backtrace for more info)

playground link

@aatifsyed aatifsyed changed the title fix: ambiguous associated type in forward_to_deserialize_any! fix: ambiguous associated item in forward_to_deserialize_any! Apr 26, 2024
Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dtolnay dtolnay merged commit 789740b into serde-rs:master Apr 27, 2024
15 checks passed
@dtolnay
Copy link
Member

dtolnay commented Apr 27, 2024

Published in serde 1.0.199.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants