Skip to content

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

Closed
@matthiaskrgr

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


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