Skip to content

rustc stack overflow: recursive associated types #23992

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
seanmonstar opened this issue Apr 3, 2015 · 3 comments
Closed

rustc stack overflow: recursive associated types #23992

seanmonstar opened this issue Apr 3, 2015 · 3 comments
Labels
A-associated-items Area: Associated items (types, constants & functions) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@seanmonstar
Copy link
Contributor

trait Foo {
    type Bar;
    fn foo(self) -> Self::Bar;
}

impl Foo for Box<Foo> {
    type Bar = <Self as Foo>::Bar;
    fn foo(self) -> <Self as Foo>::Bar {
        (*self).foo()
    }
}
@steveklabnik steveklabnik added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-associated-items Area: Associated items (types, constants & functions) labels Apr 3, 2015
@apoelstra
Copy link
Contributor

I've encountered a variant of this bug (or is it another bug? please advise if so and I will post it separately):

pub struct Outer<T: Trait>(T);
pub struct Inner<'a>(&'a bool);

pub trait Trait {
    type Error;
    fn ready(self) -> Self::Error;
}

impl<'a> Trait for Inner<'a> {
    type Error = Outer<Inner<'a>>;
    fn ready(mut self) -> Outer<Inner<'a>> {}
}

If I remove the lifetime, the stack overflow no longer occurs.

@nham
Copy link
Contributor

nham commented Jun 24, 2015

Seems to be a dupe of #21946

@arielb1
Copy link
Contributor

arielb1 commented Oct 24, 2015

@apoelstra's example was fixed in 1.4.

# for free to join this conversation on GitHub. Already have an account? # 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

No branches or pull requests

5 participants