Skip to content

Associated types may not all be normalized #20604

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
alexcrichton opened this issue Jan 6, 2015 · 0 comments
Closed

Associated types may not all be normalized #20604

alexcrichton opened this issue Jan 6, 2015 · 0 comments
Labels
A-associated-items Area: Associated items (types, constants & functions)

Comments

@alexcrichton
Copy link
Member

(or so niko told me)

I believe this code should compile, but it does not compile. Trawling through some logs made Niko think that something wasn't normalized one way or the other, so opening an issue!

#![feature(associated_types)]

trait Hasher {
    type Output;
    fn finish(&self) -> Self::Output;
}

trait Hash<H: Hasher> {
    fn hash(&self, h: &mut H);
}

trait HashState {
    type Hasher: Hasher;
    fn hasher(&self) -> Self::Hasher;
}

struct SipHasher;
impl Hasher for SipHasher {
    type Output = u64;
    fn finish(&self) -> u64 { 4 }
}

impl Hash<SipHasher> for int {
    fn hash(&self, h: &mut SipHasher) {}
}

struct SipState;
impl HashState for SipState {
    type Hasher = SipHasher;
    fn hasher(&self) -> SipHasher { SipHasher }
}

struct Map<S> {
    s: S,
}

impl<S> Map<S>
    where S: HashState,
          <S as HashState>::Hasher: Hasher<Output=u64>,
{
    fn foo<K>(&self) where K: Hash< <S as HashState>::Hasher> {}
}

fn foo<K: Hash<SipHasher>>(map: &Map<SipState>) {
    map.foo();
}

fn main() {}
foo.rs:45:9: 45:14 error: type `&Map<SipState>` does not implement any method in scope named `foo`
foo.rs:45     map.foo();
                  ^~~~~
error: aborting due to previous error

cc @nikomatsakis
cc #17307

@alexcrichton alexcrichton added the A-associated-items Area: Associated items (types, constants & functions) label Jan 6, 2015
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-associated-items Area: Associated items (types, constants & functions)
Projects
None yet
Development

No branches or pull requests

1 participant