Skip to content

ICE: cannot relate bound region if using Self #24308

Closed
@alexcrichton

Description

@alexcrichton

This code generates an ICE:

pub trait Foo {
    fn method1() {}
    fn method2();
}

struct Slice<'a, T: 'a>(&'a [T]);

impl <'a, T: 'a> Foo for Slice<'a, T> {
    fn method2() {
        <Self as Foo>::method1();
    }
}
wut.rs:10:9: 10:32 error: internal compiler error: cannot relate bound region: '_#0r <= ReEarlyBound(33, TypeSpace, 0, 'a)
wut.rs:10         <Self as Foo>::method1();
                  ^~~~~~~~~~~~~~~~~~~~~~~
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace

Interestingly enough, if Self as Foo is changed to Slice<'a, T> as Foo then it compiles just fine!

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions