Skip to content

ICE - trait lifetime polymorphism + associated type #35570

Closed
@idupree

Description

@idupree
trait Trait1<T> {}
trait Trait2<'a> {
  type Ty;
}
fn ice(param: Box<for <'a> Trait1<<() as Trait2<'a>>::Ty>>) {}
fn main() {}

stable: error: internal compiler error: ../src/librustc_trans/debuginfo/metadata.rs:306: get_unique_type_id_of_type() - unexpected type: <() as Trait2<'static>>::Ty

nightly: thread 'rustc' panicked at 'assertion failed: ty.is_normalized_for_trans()', ../src/librustc_trans/collector.rs:534

The stable version's ICE error message also appears in nightly if I write a transmute inside ice():

use std::mem;
fn ice(param: Box<for <'a> Trait1<<() as Trait2<'a>>::Ty>>) {
  let e: (usize, usize) = unsafe{mem::transmute(param)};
}

(This came up while trying to find ways to convince Rust that two complicated type expressions are the same type. I got this ICE, simplified here.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions