Skip to content

Multiple associated type bindings cause problems #20651

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
nikomatsakis opened this issue Jan 6, 2015 · 2 comments · Fixed by #20655
Closed

Multiple associated type bindings cause problems #20651

nikomatsakis opened this issue Jan 6, 2015 · 2 comments · Fixed by #20655
Labels
A-associated-items Area: Associated items (types, constants & functions) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@nikomatsakis
Copy link
Contributor

This test doesn't pass:

// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(associated_types)]

trait Foo {
    type X;
    type Y;
}

fn foo<T:Foo<X=int,Y=int>>(t: &T)
{
    bar(t);
    baz(t);
}
fn bar<T:Foo<X=int>>(t: &T) { }
fn baz<T:Foo<Y=int>>(t: &T) { }

fn main() { }
@nikomatsakis
Copy link
Contributor Author

Can also manifest as an ICE:

// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(associated_types)]

trait Foo {
    type X;
    type Y;
}

fn foo<T:Foo<X=int>>(t: &T)
{
    baz(t);
}
fn baz<T:Foo<Y=int>>(t: &T) { }

fn main() { }

reports:

thread 'rustc' panicked at 'assertion failed: `(left == right) && (right == left)` (left: `"X"(62)`,
right: `"Y"(63)`)', /home/nmatsakis/versioned/rust-3/src/librustc/middle/traits/project.rs:599

@apasel422
Copy link
Contributor

Is #20521 at all related to this?

@kmcallister kmcallister added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-associated-items Area: Associated items (types, constants & functions) labels Jan 6, 2015
nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Jan 7, 2015
bors added a commit that referenced this issue Jan 7, 2015
Remember to check the name of the associated type being projected when searching the environment. Fixes #20651.
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) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants