Skip to content

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

Closed
@aturon

Description

@aturon

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions