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 types aren't normalized with impl cycles #31593

Closed
strega-nil opened this issue Feb 12, 2016 · 4 comments
Closed

Associated types aren't normalized with impl cycles #31593

strega-nil opened this issue Feb 12, 2016 · 4 comments
Labels
A-associated-items Area: Associated items (types, constants & functions) C-bug Category: This is a bug.

Comments

@strega-nil
Copy link
Contributor

trait Doop {
    type Shaboom;
    fn badoowop(self) -> Self::Shaboom;
}
trait BaDoop: Doop { }

impl<T: BaDoop> Doop for T {
    type Shaboom = T;
    fn badoowop(self) -> Self {
        self
    }
}

fn main() { }

errors with

error: method `badoowop` has an incompatible type for trait: 
 expected associated type,
 found type parameter

playground

A similar issue happens when you now return Self::Shaboom:

error: mismatched types: expected `<T as Doop>::Shaboom`,
    found `T`

playground

@strega-nil strega-nil changed the title Associated types aren't lowered with looped impls Associated types aren't normalized with looped impls Feb 12, 2016
@strega-nil strega-nil changed the title Associated types aren't normalized with looped impls Associated types aren't normalized with impl cycles Feb 12, 2016
@strega-nil
Copy link
Contributor Author

Honestly, it probably just needs a better error message.

@eddyb
Copy link
Member

eddyb commented Feb 12, 2016

This seems related to #29859, but not... actually working?
AFAICT, <T as Doop> in the impl<T: Doop> of Doop for T cannot refer to the same impl.

cc @nikomatsakis

@strega-nil
Copy link
Contributor Author

@eddyb looks like the forest may have fixed this? #30533

@steveklabnik steveklabnik added the A-associated-items Area: Associated items (types, constants & functions) label Feb 15, 2016
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 24, 2017
@oli-obk
Copy link
Contributor

oli-obk commented Jan 25, 2020

The error message seems reasonable to me now as we get

error[E0053]: method `badoowop` has an incompatible type for trait
 --> src/main.rs:9:26
  |
3 |     fn badoowop(self) -> Self::Shaboom;
  |                          ------------- type in trait
...
9 |     fn badoowop(self) -> Self {
  |                          ^^^^ expected associated type, found type parameter
  |
  = note: expected type `fn(T) -> <T as Doop>::Shaboom`
             found type `fn(T) -> T`
  = note: you might be missing a type parameter or trait bound

Please reopen if you disagree

@oli-obk oli-obk closed this as completed Jan 25, 2020
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) C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

5 participants