Skip to content
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

ICE when a supertrait bound contains a binding for a type defined in the supertrait #20825

Closed
nikomatsakis opened this issue Jan 9, 2015 · 5 comments · Fixed by #27118
Closed
Labels
A-associated-items Area: Associated items (types, constants & functions) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@nikomatsakis
Copy link
Contributor

Example (reduced by @sfackler from something reported on IRC):

pub trait Subscriber {
    type Input;
}

pub trait Processor : Subscriber<Input=Self::Input> {
    type Input;
}

fn main() {}
@nikomatsakis nikomatsakis added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-associated-items Area: Associated items (types, constants & functions) labels Jan 9, 2015
@tomprogrammer
Copy link
Contributor

Is that allowed syntax? As RFC 195 states "[…] associated types/lifetimes are not in scope for the optional where clause on the trait header.".

I tried to express something like trait Example: Iterator<Item=Option<Self::AssocType>> { type AssocType; } but thought I have to wait until where clauses on associated type definitions land.

@tomprogrammer
Copy link
Contributor

Nevermind, got it. Only AssocType is not in scope for the trait header, but Self::AssocType is a path to it, so it is valid syntax.

Keep up your excellent work :)

@apasel422
Copy link
Contributor

The code snippet above now causes the following error:

foo.rs:5:40: 5:51 error: associated type `Input` not found for type parameter `Self` [E0220]
foo.rs:5 pub trait Processor : Subscriber<Input=Self::Input> {

Changing the Processor trait to:

pub trait Processor : Subscriber<Input=<Self as Processor>::Input> {
    type Input;
}

yields

foo.rs:5:40: 5:66 error: illegal recursive type; insert an enum or struct in the cycle, if this is desired [E0246]
foo.rs:5 pub trait Processor : Subscriber<Input=<Self as Processor>::Input> {

@Gankra Gankra removed the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Feb 26, 2015
@Gankra
Copy link
Contributor

Gankra commented Feb 26, 2015

I'd like to nominate this, I don't think we can remove old_impl_check without it.

@arielb1
Copy link
Contributor

arielb1 commented Jul 7, 2015

This currently reports error: unsupported cyclic reference between types/traits detected [E0391]. The cycle can be broken by explicit UFCS notation:

pub trait Subscriber {
    type Input;
}

pub trait Processor : Subscriber<Input=<Self as Processor>::Input> {
    type Input;
}

fn main() {}

@arielb1 arielb1 added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jul 7, 2015
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) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants