Skip to content

error: internal compiler error: /checkout/src/librustc_typeck/check/mod.rs:4419: impossible case reached #43431

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

Closed
mwchase opened this issue Jul 23, 2017 · 4 comments
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@mwchase
Copy link

mwchase commented Jul 23, 2017

Encountered doing ill-advised type manipulations in the playground. By (mis)using some combination of universal function call syntax, the Fn trait, and other language features, I got an internal compiler error. I then simplified it to the point where it wouldn't make sense even if it didn't hit the error.

Code to reproduce the error:

trait CallSingle<A, B> {
    fn call(&self, a: A) -> B where Self: Fn(A) -> B;
}

impl<A, B, F: Fn(A) -> B> CallSingle<A, B> for F {
    fn call(&self, a: A) -> B {
        <Self as Fn(A) -> B>::call
    }
}

I'm not sure there should be any error it emits beyond what it already does, but this does panic the compiler: error: internal compiler error: /checkout/src/librustc_typeck/check/mod.rs:4419: impossible case reached

@Mark-Simulacrum Mark-Simulacrum added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jul 23, 2017
@estebank
Copy link
Contributor

This match arm is reached.

@petrochenkov petrochenkov self-assigned this Jul 26, 2017
@petrochenkov
Copy link
Contributor

I have a fix in progress (accidentally), will submit this weekend.

@petrochenkov
Copy link
Contributor

petrochenkov commented Jul 28, 2017

#43532 fixes the ICE, but the code still doesn't compile.
For some reason associated type bindings are prohibited in traits in UFCS-style paths

<Type as Trait<T = u8 /* <-- can't do this */>>::AssocItem

and B in Fn(A) -> B is exactly an associated type binding

<Self as Fn(A) -> B>::call
// Desugars to
<Self as Fn<(A,), Output = B>>::call

bors added a commit that referenced this issue Aug 24, 2017
Desugar parenthesized generic arguments in HIR

Fixes ICE in #43431 and maybe some other similar issues.

r? @eddyb
@petrochenkov
Copy link
Contributor

Current output:

#![feature(fn_traits)]

trait CallSingle<A, B> {
    fn call(&self, a: A) -> B where Self: Fn(A) -> B;
}

impl<A, B, F: Fn(A) -> B> CallSingle<A, B> for F {
    fn call(&self, a: A) -> B {
        <Self as Fn(A) -> B>::call(self, (a,))
    }
}

fn main() {}

---

   Compiling playground v0.0.1 (file:///playground)
error[E0229]: associated type bindings are not allowed here
 --> src/main.rs:9:27
  |
9 |         <Self as Fn(A) -> B>::call(self, (a,))
  |                           ^ associated type not allowed here

error: aborting due to previous error

I'm closing this because the ICE is fixed and supporting type bindings in value paths (let x = Trait<AssocTy = u8>::method();) is a separate problem, please open a new lang-team issue if you are interested in supporting it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants