Skip to content

Bounds on associated types still ignored #21636

Closed
@bgamari

Description

@bgamari

It seems #20890 may not be entirely resolved. Take this example,

pub trait BitIter {
    type Iter: Iterator<Item=bool>;
    fn bit_iter(self) -> <Self as BitIter>::Iter;
}

fn hi<T>(arg: T) where 
    T: BitIter,
    //<T as BitIter>::Iter: Iterator<Item=bool>
{
    for i in arg.bit_iter() {}
}

rustc 1.0.0-dev (2a51ca0a4 2015-01-25 10:42:41 -0500) fails to compile this with,

hi.rs:9:18: 9:28 error: type mismatch resolving `<<T as BitIter>::Iter as core::iter::Iterator>::Item == bool`:
 expected associated type,
    found bool [E0271]
hi.rs:9     for i in arg.bit_iter() {}
                         ^~~~~~~~~~

Unless, of course, I add the bound.

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