Skip to content

ICE from associated const in field type of lifetime-parametric struct #68875

Closed
@mortonsc

Description

@mortonsc

Attempting to build this code generates an ICE (play):

struct DataWrapper<'a> {
    data: &'a [u8; Self::SIZE],
}

impl DataWrapper<'_> {
    const SIZE: usize = 14;
}

The error message, on my machine:

$ rustc src/main.rs --verbose
error: internal compiler error: src/librustc_mir/borrow_check/universal_regions.rs:762: cannot convert `ReEarlyBound(0, 'a)` to a region vid

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:905:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

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: rustc 1.41.0 running on x86_64-unknown-linux-gnu

error: aborting due to previous error

Looks like it's related to #56445, but the construction that triggers it is different enough that it seems worth posting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-borrow-checkerArea: The borrow checkerC-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions