Skip to content

ICE on min_exhaustive_patterns pointer dereference #129009

Closed
@ShoyuVanilla

Description

@ShoyuVanilla

Rust Playground with 1.82.0-nightly(2024-08-11 41dd149)

#![feature(never_type)]

fn main() {}

fn panique(ptr: *const Result<i32, !>) {
    unsafe {
        let Ok(_x) = *ptr;
    }
}

yeets

Compiling playground v0.0.1 (/playground)
thread 'rustc' panicked at compiler/rustc_mir_build/src/thir/pattern/check_match.rs:707:13:
assertion failed: inhabited.apply(self.tcx, cx.param_env, cx.module)
stack backtrace:
   0:     0x7ff4a76afead - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h17d06336c5e3b1ba
   1:     0x7ff4a7edd7ef - core::fmt::write::ha36b31577d300920
   2:     0x7ff4a8e5f451 - std::io::Write::write_fmt::h87580c3a702d3643
   3:     0x7ff4a76b257b - std::panicking::default_hook::{{closure}}::hf5abd452e6300672
   4:     0x7ff4a76b21ee - std::panicking::default_hook::h17d581bf85c3535e
   5:     0x7ff4a682d618 - std[f5c760e4f6201609]::panicking::update_hook::<alloc[fc5d5d75bd142d1a]::boxed::Box<rustc_driver_impl[5153b23ca80fb7ed]::install_ice_hook::{closure#0}>>::{closure#0}
   6:     0x7ff4a76b2e97 - std::panicking::rust_panic_with_hook::h7c1411cde88a7f7f
   7:     0x7ff4a76b2b23 - std::panicking::begin_panic_handler::{{closure}}::ha913deac649d6768
   8:     0x7ff4a76b0369 - std::sys::backtrace::__rust_end_short_backtrace::hf5c0fd0c12c83077
   9:     0x7ff4a76b2824 - rust_begin_unwind
  10:     0x7ff4a485ea03 - core::panicking::panic_fmt::h0ffd474c249f012b
  11:     0x7ff4a476844c - core::panicking::panic::h663a3891a256607c
  12:     0x7ff4a8721596 - <rustc_mir_build[3fa758602a6f6eb0]::thir::pattern::check_match::MatchVisitor>::check_binding_is_irrefutable
  13:     0x7ff4a4f99cc4 - <rustc_mir_build[3fa758602a6f6eb0]::thir::pattern::check_match::MatchVisitor as rustc_middle[82a8b21925effaa0]::thir::visit::Visitor>::visit_expr
  14:     0x7ff4a4f98e4d - <rustc_mir_build[3fa758602a6f6eb0]::thir::pattern::check_match::MatchVisitor as rustc_middle[82a8b21925effaa0]::thir::visit::Visitor>::visit_expr
  15:     0x7ff4a4f99a5c - <rustc_mir_build[3fa758602a6f6eb0]::thir::pattern::check_match::MatchVisitor as rustc_middle[82a8b21925effaa0]::thir::visit::Visitor>::visit_expr
  16:     0x7ff4a4f98e4d - <rustc_mir_build[3fa758602a6f6eb0]::thir::pattern::check_match::MatchVisitor as rustc_middle[82a8b21925effaa0]::thir::visit::Visitor>::visit_expr
  17:     0x7ff4a871e197 - rustc_mir_build[3fa758602a6f6eb0]::thir::pattern::check_match::check_match
  18:     0x7ff4a871ddb3 - rustc_query_impl[3b91f71dedc7f6af]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3b91f71dedc7f6af]::query_impl::check_match::dynamic_query::{closure#2}::{closure#0}, rustc_middle[82a8b21925effaa0]::query::erase::Erased<[u8; 1usize]>>
  19:     0x7ff4a871d5e6 - rustc_query_system[10e08ee6835a9bbf]::query::plumbing::try_execute_query::<rustc_query_impl[3b91f71dedc7f6af]::DynamicConfig<rustc_query_system[10e08ee6835a9bbf]::query::caches::VecCache<rustc_span[70e7603d74aa2ff6]::def_id::LocalDefId, rustc_middle[82a8b21925effaa0]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[3b91f71dedc7f6af]::plumbing::QueryCtxt, false>
  20:     0x7ff4a871d25d - rustc_query_impl[3b91f71dedc7f6af]::query_impl::check_match::get_query_non_incr::__rust_end_short_backtrace
  21:     0x7ff4a872a74e - rustc_mir_build[3fa758602a6f6eb0]::build::mir_build
  22:     0x7ff4a8729e12 - rustc_query_impl[3b91f71dedc7f6af]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3b91f71dedc7f6af]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[82a8b21925effaa0]::query::erase::Erased<[u8; 8usize]>>
  23:     0x7ff4a824ecf9 - rustc_query_system[10e08ee6835a9bbf]::query::plumbing::try_execute_query::<rustc_query_impl[3b91f71dedc7f6af]::DynamicConfig<rustc_query_system[10e08ee6835a9bbf]::query::caches::VecCache<rustc_span[70e7603d74aa2ff6]::def_id::LocalDefId, rustc_middle[82a8b21925effaa0]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[3b91f71dedc7f6af]::plumbing::QueryCtxt, false>
  24:     0x7ff4a824e80d - rustc_query_impl[3b91f71dedc7f6af]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7ff4a4599093 - rustc_mir_build[3fa758602a6f6eb0]::check_unsafety::check_unsafety
  26:     0x7ff4a8288f0b - rustc_query_impl[3b91f71dedc7f6af]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3b91f71dedc7f6af]::query_impl::check_unsafety::dynamic_query::{closure#2}::{closure#0}, rustc_middle[82a8b21925effaa0]::query::erase::Erased<[u8; 0usize]>>
  27:     0x7ff4a82886ff - rustc_query_system[10e08ee6835a9bbf]::query::plumbing::try_execute_query::<rustc_query_impl[3b91f71dedc7f6af]::DynamicConfig<rustc_query_system[10e08ee6835a9bbf]::query::caches::VecCache<rustc_span[70e7603d74aa2ff6]::def_id::LocalDefId, rustc_middle[82a8b21925effaa0]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[3b91f71dedc7f6af]::plumbing::QueryCtxt, false>
  28:     0x7ff4a82883c1 - rustc_query_impl[3b91f71dedc7f6af]::query_impl::check_unsafety::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7ff4a824400c - rustc_interface[adec5331f4e06f9b]::passes::run_required_analyses
  30:     0x7ff4a8bfff9e - rustc_interface[adec5331f4e06f9b]::passes::analysis
  31:     0x7ff4a8bfff71 - rustc_query_impl[3b91f71dedc7f6af]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3b91f71dedc7f6af]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[82a8b21925effaa0]::query::erase::Erased<[u8; 1usize]>>
  32:     0x7ff4a8e6286e - rustc_query_system[10e08ee6835a9bbf]::query::plumbing::try_execute_query::<rustc_query_impl[3b91f71dedc7f6af]::DynamicConfig<rustc_query_system[10e08ee6835a9bbf]::query::caches::SingleCache<rustc_middle[82a8b21925effaa0]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[3b91f71dedc7f6af]::plumbing::QueryCtxt, false>
  33:     0x7ff4a8e625cf - rustc_query_impl[3b91f71dedc7f6af]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7ff4a8d05dab - rustc_interface[adec5331f4e06f9b]::interface::run_compiler::<core[c9e7e1236848907c]::result::Result<(), rustc_span[70e7603d74aa2ff6]::ErrorGuaranteed>, rustc_driver_impl[5153b23ca80fb7ed]::run_compiler::{closure#0}>::{closure#1}
  35:     0x7ff4a90bee44 - std[f5c760e4f6201609]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[adec5331f4e06f9b]::util::run_in_thread_with_globals<rustc_interface[adec5331f4e06f9b]::util::run_in_thread_pool_with_globals<rustc_interface[adec5331f4e06f9b]::interface::run_compiler<core[c9e7e1236848907c]::result::Result<(), rustc_span[70e7603d74aa2ff6]::ErrorGuaranteed>, rustc_driver_impl[5153b23ca80fb7ed]::run_compiler::{closure#0}>::{closure#1}, core[c9e7e1236848907c]::result::Result<(), rustc_span[70e7603d74aa2ff6]::ErrorGuaranteed>>::{closure#0}, core[c9e7e1236848907c]::result::Result<(), rustc_span[70e7603d74aa2ff6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c9e7e1236848907c]::result::Result<(), rustc_span[70e7603d74aa2ff6]::ErrorGuaranteed>>
  36:     0x7ff4a8d8f8f4 - <<std[f5c760e4f6201609]::thread::Builder>::spawn_unchecked_<rustc_interface[adec5331f4e06f9b]::util::run_in_thread_with_globals<rustc_interface[adec5331f4e06f9b]::util::run_in_thread_pool_with_globals<rustc_interface[adec5331f4e06f9b]::interface::run_compiler<core[c9e7e1236848907c]::result::Result<(), rustc_span[70e7603d74aa2ff6]::ErrorGuaranteed>, rustc_driver_impl[5153b23ca80fb7ed]::run_compiler::{closure#0}>::{closure#1}, core[c9e7e1236848907c]::result::Result<(), rustc_span[70e7603d74aa2ff6]::ErrorGuaranteed>>::{closure#0}, core[c9e7e1236848907c]::result::Result<(), rustc_span[70e7603d74aa2ff6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c9e7e1236848907c]::result::Result<(), rustc_span[70e7603d74aa2ff6]::ErrorGuaranteed>>::{closure#1} as core[c9e7e1236848907c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  37:     0x7ff4a8d8fdeb - std::sys::pal::unix::thread::Thread::new::thread_start::hd745a5b068b8240f
  38:     0x7ff4a32a9609 - start_thread
  39:     0x7ff4a31ce353 - clone
  40:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

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: please make sure that you have updated to the latest nightly

note: please attach the file at `/playground/rustc-ice-2024-08-12T15_12_57-23.txt` to your bug report

note: compiler flags: --crate-type bin -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [check_match] match-checking `panique`
#1 [mir_built] building MIR for `panique`
end of query stack
error: could not compile `playground` (bin "playground")

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-min_exhaustive_patterns`#![feature(min_exhaustive_patterns)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️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