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 - trait lifetime polymorphism + associated type #35570

Closed
idupree opened this issue Aug 10, 2016 · 3 comments
Closed

ICE - trait lifetime polymorphism + associated type #35570

idupree opened this issue Aug 10, 2016 · 3 comments
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@idupree
Copy link
Contributor

idupree commented Aug 10, 2016

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.)

@TimNN
Copy link
Contributor

TimNN commented Sep 11, 2016

cc #36381

@TimNN TimNN added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Sep 15, 2016
@pnkfelix pnkfelix added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Sep 15, 2016
@talchas
Copy link

talchas commented Oct 5, 2016

A related one that fails with get_unique_type_id_of_type in both cases:

trait Lifetime<'a> {
    type Out;
}
impl<'a> Lifetime<'a> for () {
    type Out = &'a ();
}
fn foo<'a>(x: &'a ()) -> <() as Lifetime<'a>>::Out {
    x
}

fn takes_lifetime(f: for<'a> fn(&'a ()) -> <() as Lifetime<'a>>::Out) {
}
fn main() {
    takes_lifetime(foo);
}

Replacing the explicit fn() with a desired F: for<'a> FnOnce... gives the problematic errors reported in #34430 (at least it doesn't ICE in that case!).

Also apparently this is a regression somewhat, as it doesn't crash on 1.10 (and https://is.gd/NOhNNU doesn't error, etc) (this was incorrect, I was testing the wrong variant of the code)

@Mark-Simulacrum
Copy link
Member

Neither example ICEs today. E-needstest.

@Mark-Simulacrum Mark-Simulacrum added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label May 15, 2017
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jun 22, 2017
Add tests for a few issues.

Fixes rust-lang#41998
Fixes rust-lang#38381
Fixes rust-lang#37515
Fixes rust-lang#37510
Fixes rust-lang#37508
Fixes rust-lang#37366
Fixes rust-lang#37323
Fixes rust-lang#37051
Fixes rust-lang#36839
Fixes rust-lang#35570
Fixes rust-lang#34373
Fixes rust-lang#34222

Certainly not all of the E-needstest issues right now, but I started to get bored.
bors added a commit that referenced this issue Jun 24, 2017
Add tests for a few issues.

Fixes #41998
Fixes #38381
Fixes #37515
Fixes #37510
Fixes #37366
Fixes #37323
Fixes #37051
Fixes #36839
Fixes #35570
Fixes #34373
Fixes #34222

Certainly not all of the E-needstest issues right now, but I started to get bored.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants