Skip to content

Rust 1.20.0-nightly ICE with never_type: Broken MIR #43061

Description

@ngc0202

The following error results from dereferencing a *const ! as in this code: https://is.gd/SsSDiG

rustc 1.20.0-nightly (734c83642 2017-07-03)
error: internal compiler error: broken MIR (_3 = ()): bad assignment (! = ()): Sorts(ExpectedFound { expected: !, found: () })
 --> <anon>:4:5
  |
4 | /     unsafe {
5 | |         *x;
6 | |     }
  | |_____^

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.20.0-nightly (734c83642 2017-07-03) running on x86_64-unknown-linux-gnu

thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:426:8

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    on Jul 5, 2017
  2. SimonSapin commented on Nov 26, 2017

    @SimonSapin
    Contributor

    What’s the correct fix? Compiler error with a nice error message?

  3. arielb1 commented on Nov 26, 2017

    @arielb1
    Contributor

    @SimonSapin

    I think this should compile and UB, but a lint against this is probably a good idea.

  4. varkor commented on Dec 31, 2017

    @varkor
    Contributor

    Reduced test case:

    // error: internal compiler error: broken MIR in NodeId(4) (_2 = ()):
    //     bad assignment (! = ()): Sorts(ExpectedFound { expected: !, found: () })
    #![crate_type = "lib"]
    #![feature(never_type)]
    
    fn blah(x: !) {
        x;
        // () // Uncommenting this explicit unit return avoids the ICE
    }
  5. varkor commented on Jan 9, 2018

    @varkor
    Contributor

    I'm working on a fix for this. Progress on this branch. The idea is to avoid the typing issues entirely by terminating the blocks with unreachable as soon as a !-value is constructed. Currently the examples given here are fixed, but some more convoluted examples still crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions