Skip to content

ICE involving match and never type with never type as fallback enabled #120600

Closed

Description

@matthiaskrgr

snippet:

#![feature(never_type)]
#![feature(never_type_fallback)]

#[derive(Ord, Eq, PartialOrd, PartialEq)]
enum E {
    Foo,
    Bar(!, i32, i32),
}

fn main() {}

Version information

rustc 1.77.0-nightly (bf3c6c5be 2024-02-01)
binary: rustc
commit-hash: bf3c6c5bed498f41ad815641319a1ad9bcecb8e8
commit-date: 2024-02-01
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

warning: unreachable expression
 --> /tmp/icemaker_global_tempdir.NY1Bi1E4YUo0/rustc_testrunner_tmpdir_reporting.8YbPtnxsZhHF/mvce.rs:7:9
  |
4 | #[derive(Ord, Eq, PartialOrd, PartialEq)]
  |                               --------- in this derive macro expansion
...
7 |     Bar(!, i32, i32),
  |         ^
  |         |
  |         unreachable expression
  |         any code following this expression is unreachable
  |
  = note: `#[warn(unreachable_code)]` on by default
  = note: this warning originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: variants `Foo` and `Bar` are never constructed
 --> /tmp/icemaker_global_tempdir.NY1Bi1E4YUo0/rustc_testrunner_tmpdir_reporting.8YbPtnxsZhHF/mvce.rs:6:5
  |
5 | enum E {
  |      - variants in this enum
6 |     Foo,
  |     ^^^
7 |     Bar(!, i32, i32),
  |     ^^^
  |
  = note: `#[warn(dead_code)]` on by default

note: no errors encountered even though `span_delayed_bug` issued

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: broken MIR in DefId(0:20 ~ mvce[954a]::{impl#4}::eq) (Terminator { source_info: SourceInfo { span: /tmp/icemaker_global_tempdir.NY1Bi1E4YUo0/rustc_testrunner_tmpdir_reporting.8YbPtnxsZhHF/mvce.rs:7:9: 7:10 (#7), scope: scope[3] }, kind: _21 = <! as PartialEq>::eq(move _22, move _23) -> [return: bb9, unwind: bb18] }): bad arg #0 (&'?38 ! <- !): NoSolution
 --> /tmp/icemaker_global_tempdir.NY1Bi1E4YUo0/rustc_testrunner_tmpdir_reporting.8YbPtnxsZhHF/mvce.rs:7:9
  |
4 | #[derive(Ord, Eq, PartialOrd, PartialEq)]
  |                               --------- in this derive macro expansion
...
7 |     Bar(!, i32, i32),
  |         ^
  |
note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:1678:17
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxt>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_borrowck::type_check::TypeChecker>::typeck_mir
         4: rustc_borrowck::type_check::type_check
         5: rustc_borrowck::nll::compute_regions
         6: rustc_borrowck::do_mir_borrowck
         7: rustc_borrowck::mir_borrowck
         8: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
         9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        10: rustc_query_impl::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
        11: rustc_interface::passes::analysis
        12: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
        13: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        14: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
        15: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
        16: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
        17: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        18: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/alloc/src/boxed.rs:2015:9
        19: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/alloc/src/boxed.rs:2015:9
        20: std::sys::pal::unix::thread::Thread::new::thread_start
                   at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/sys/pal/unix/thread.rs:108:17
        21: <unknown>
        22: <unknown>
 --> /tmp/icemaker_global_tempdir.NY1Bi1E4YUo0/rustc_testrunner_tmpdir_reporting.8YbPtnxsZhHF/mvce.rs:7:9
  |
4 | #[derive(Ord, Eq, PartialOrd, PartialEq)]
  |                               --------- in this derive macro expansion
...
7 |     Bar(!, i32, i32),
  |         ^
  = note: this error: internal compiler error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.77.0-nightly (bf3c6c5be 2024-02-01) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to 1 previous error; 2 warnings emitted


Activity

  1. 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.
    C-bugCategory: This is a bug.
    F-never_type`#![feature(never_type)]`
    on Feb 3, 2024
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Feb 3, 2024
  3. matthiaskrgr commented on Feb 3, 2024

    @matthiaskrgr
    MemberAuthor

    Regression in nightly-2023-05-23
    commit[0] 2023-05-21: Auto merge of #111731 - MU001999:fix/issue-111727, r=cjgillot
    commit[1] 2023-05-21: Auto merge of #111808 - Zoxc:query-structs-trim, r=cjgillot
    commit[2] 2023-05-22: Auto merge of #111824 - lukas-code:strike, r=notriddle
    commit[3] 2023-05-22: Auto merge of #111781 - the8472:filter-map-chunk, r=thomcc
    commit[4] 2023-05-22: Auto merge of #111835 - matthiaskrgr:rollup-qd4b2vu, r=matthiaskrgr
    commit[5] 2023-05-22: Auto merge of #111711 - Jules-Bertholet:document-pin-layout, r=thomcc
    commit[6] 2023-05-22: Auto merge of #111775 - compiler-errors:triple-check, r=Nilstrieb
    commit[7] 2023-05-22: Auto merge of #111634 - marc0246:arc-new-uninit-bloat, r=thomcc
    commit[8] 2023-05-22: Auto merge of #111754 - lcnr:recursion-depth, r=matthewjasper
    commit[9] 2023-05-22: Auto merge of #111848 - Dylan-DPC:rollup-7jqydzg, r=Dylan-DPC
    ERROR: no CI builds available between 9d871b0 and 8b4b208 within last 167 days

    cc @Nadrieril

  4. fmease commented on Feb 3, 2024

    @fmease
    Member

    Minimized:

    #![feature(never_type, never_type_fallback)]
    
    enum E { Bar(!) }
    
    fn f(a: &E, b: &E) {
        match (a, b) {
            (E::Bar(a), E::Bar(b)) => { *a == *b; }
            _ => {}
        }
    }
  5. added
    S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Feb 3, 2024
  6. changed the title [-]ICE: deriving PartialEq for ! [/-] [+]ICE involving match and never type with never type as fallback enabled[/+] on Feb 3, 2024
  7. WaffleLapkin commented on Apr 6, 2024

    @WaffleLapkin
    Member

    Minimized even more:

    #![feature(never_type)]
    #![feature(never_type_fallback)]
    
    fn ice(a: !) {
        a == a;
    }
    
    fn main() {}

    (I independently found the same bug while running crater with the fallback being !)

  8. added
    S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.
    on Apr 15, 2024
  9. added 2 commits that reference this issue on Apr 18, 2024
    1beaaac
    47f839e
  10. added a commit that references this issue on Apr 18, 2024
    b7201be
  11. added 2 commits that reference this issue on Apr 19, 2024
    43852d0
    6c4657c
  12. added a commit that references this issue on Apr 19, 2024
    be01b79
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.F-never_type`#![feature(never_type)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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