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

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

Closed
aldanor opened this issue Feb 6, 2015 · 2 comments
Closed

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

aldanor opened this issue Feb 6, 2015 · 2 comments
Labels
A-associated-items Area: Associated items (types, constants & functions) A-type-system Area: Type system

Comments

@aldanor
Copy link

aldanor commented Feb 6, 2015

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>
@kmcallister kmcallister added A-type-system Area: Type system A-associated-items Area: Associated items (types, constants & functions) labels Feb 7, 2015
@edwardw
Copy link
Contributor

edwardw commented Feb 7, 2015

Right now one has to write:

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

It is a known issue being actively worked on. See #20300. So this issue probably could be closed.

@apasel422
Copy link
Contributor

This is fixed. I don't know if we need to add a run-pass test for it, but:

trait Decoder {
    type Error;
}

trait Decodable {}

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

fn main() {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) A-type-system Area: Type system
Projects
None yet
Development

No branches or pull requests

5 participants