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

Type mismatch with type alias and associated types #34738

Closed
arcnmx opened this issue Jul 9, 2016 · 3 comments
Closed

Type mismatch with type alias and associated types #34738

arcnmx opened this issue Jul 9, 2016 · 3 comments

Comments

@arcnmx
Copy link
Contributor

arcnmx commented Jul 9, 2016

Type aliases using associated types / as to resolve to a concrete type do not work as expected:

trait Tr {
    type Ty;
    fn f(self) -> Self::Ty;
}

impl Tr for () {
    type Ty = f32;

    fn f(self) -> Self::Ty { 0.5 }
}

type TrTy<T> = <T as Tr>::Ty;

fn main() {
    let _: <() as Tr>::Ty = Tr::f(()); // works
    let _: TrTy<()> = Tr::f(()); // error
}
error: mismatched types [--explain E0308]
  --> <anon>:16:23
16 |>     let _: TrTy<()> = Tr::f(()); // error
   |>                       ^^^^^^^^^ expected associated type, found f32
note: expected type `<() as Tr>::Ty`
note:    found type `f32`

playpen repro

@TimNN
Copy link
Contributor

TimNN commented Jul 9, 2016

At the very least related to, but probably a dupe of #28828.

@sorpaas
Copy link

sorpaas commented Sep 8, 2016

Any workaround for this issue?

@Mark-Simulacrum
Copy link
Member

Example given compiles today. Tests were added in fix for #28828 which seem to cover this, closing.

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

No branches or pull requests

4 participants