Skip to content

regression around trait bounds with associated types  #33586

Closed
@nikomatsakis

Description

@nikomatsakis

The following code works on stable, but not on the latest master. I believe it is valid.

trait ParallelIterator {
    type Item;
    fn drive_unindexed<C>(self, consumer: C) -> C::Result
        where C: Consumer<Self::Item>;
}

pub trait Consumer<ITEM> {
    type Result;
}

pub struct Enumerate<M> {
    base: M,
}

impl<M> ParallelIterator for Enumerate<M>
    where M: ParallelIterator,
{
    type Item = (usize, M::Item);

    fn drive_unindexed<C>(self, consumer: C) -> C::Result
        where C: Consumer<Self::Item>
    {
        panic!()
    }
}

fn main() { }

On master I get:

lunch-box. rustc ~/tmp/reduce.rs
/home/nmatsakis/tmp/reduce.rs:3:5: 4:39 error: the trait bound `C: Consumer<Self>` is not satisfied [E0277]
/home/nmatsakis/tmp/reduce.rs:3     fn drive_unindexed<C>(self, consumer: C) -> C::Result
                                    ^
/home/nmatsakis/tmp/reduce.rs:3:5: 4:39 help: run `rustc --explain E0277` to see a detailed explanation
/home/nmatsakis/tmp/reduce.rs:3:5: 4:39 help: consider adding a `where C: Consumer<Self>` bound
/home/nmatsakis/tmp/reduce.rs:20:5: 24:6 error: the trait bound `C: Consumer<Enumerate<M>>` is not satisfied [E0277]
/home/nmatsakis/tmp/reduce.rs:20     fn drive_unindexed<C>(self, consumer: C) -> C::Result
                                     ^
/home/nmatsakis/tmp/reduce.rs:20:5: 24:6 help: run `rustc --explain E0277` to see a detailed explanation
/home/nmatsakis/tmp/reduce.rs:20:5: 24:6 help: consider adding a `where C: Consumer<Enumerate<M>>` bound
error: aborting due to 2 previous errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions