Skip to content

Associated type not found for type parameter when using where keyword #22022

@aldanor

Description

@aldanor

This compiles fine (Decoder is serialize::Decoder trait):

fn read_field<D: Decoder, T>(d: &mut D, field: &str) -> Result<T, D::Error> 
where T: Decodable

while this doesn't:

fn read_field<D, T>(d: &mut D, field: &str) -> Result<T, D::Error> 
where D: Decoder, T: Decodable

yielding the following error:

src/main.rs:149:58: 149:66 error: associated type `Error` not found for type parameter `D` [E0220]
src/main.rs:149 fn read_field<D, T>(d: &mut D, field: &str) -> Result<T, D::Error>

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-type-systemArea: Type system

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions