Skip to content

Type inference issue with IntoDeserializer #1967

@ehuss

Description

@ehuss

With the release of 1.122, IntoDeserializer seems to have type inference problems with strings. For example:

use serde::de::IntoDeserializer;

fn f<'a, T: IntoDeserializer<'a>>(t: T) {
    t.into_deserializer();
}

fn main() {
    let s = String::new();
    f(s.as_ref());  // ERROR: type annotation needed
}

The real-world example is in Cargo as illustrated here: rust-lang/cargo#9101

This seems to be caused by #1898. cc @Mingun

I'm fine if this is closed as WontFix (I can easily add a type annotation), I just wanted to check if this was intended or ok.

EDIT: Updated code to avoid issue in rust-lang/cargo#9102

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions