Skip to content

Associated type check for trait objects fires incorrectly on supertrait/Self bounds #34603

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

Closed
aturon opened this issue Jul 1, 2016 · 5 comments
Labels
A-associated-items Area: Associated items (types, constants & functions) A-trait-system Area: Trait system

Comments

@aturon
Copy link
Member

aturon commented Jul 1, 2016

Here's an example (reproducible on Rust 1.9+):

trait FutureInternals {
    type Item;
    type Error;

    fn poll(&mut self);
}

trait Future<T, E> where Self: FutureInternals<Item=T, Error=E> {
    fn boxed(self) -> Box<Future<T, E>> {
        Box::new(self)
    }
}

impl<T: FutureInternals> Future<T::Item, T::Error> for T {}

This code produces the error:

error: the value of the associated type `Error` (from the trait `FutureInternals`) must be specified [--explain E0191]
 --> <anon>:9:27
  |>
9 |>     fn boxed(self) -> Box<Future<T, E>> {
  |>                           ^^^^^^^^^^^^

error: the value of the associated type `Item` (from the trait `FutureInternals`) must be specified [--explain E0191]
 --> <anon>:9:27
  |>
9 |>     fn boxed(self) -> Box<Future<T, E>> {
  |>                           ^^^^^^^^^^^^

despite the fact that the associated types are fully constrained.

@aturon aturon added the A-trait-system Area: Trait system label Jul 1, 2016
@aturon
Copy link
Member Author

aturon commented Jul 1, 2016

cc @eddyb @arielb1 @nikomatsakis

@aturon
Copy link
Member Author

aturon commented Jul 1, 2016

Note: the same error occurs if you use a supertrait bound instead.

@nikomatsakis nikomatsakis added the A-associated-items Area: Associated items (types, constants & functions) label Jul 22, 2016
@nikomatsakis
Copy link
Contributor

Dup of #23856 I believe ... this probably isn't too hard to fix. Just something we never got around to.

@nikomatsakis
Copy link
Contributor

Closing in favor of #23856

@nikomatsakis
Copy link
Contributor

Note that:

trait Future<T, E> where Self: FutureInternals<Item=T, Error=E> {

is a super-trait bound.

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-trait-system Area: Trait system
Projects
None yet
Development

No branches or pull requests

2 participants