Skip to content
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

ICE: refutable patterns should always have a place to inspect #138958

Closed
meithecatte opened this issue Mar 26, 2025 · 1 comment · Fixed by #138959
Closed

ICE: refutable patterns should always have a place to inspect #138958

meithecatte opened this issue Mar 26, 2025 · 1 comment · Fixed by #138959
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@meithecatte
Copy link
Contributor

meithecatte commented Mar 26, 2025

Code

pub fn match_const(x: (u32, u32)) {
    let _ = || {
        let ((0, a) | (a, _)) = x;
        a
    };
}

This compiles correctly on 1.86.0-beta.7, but ICE's on latest nightly.

Found this when working on fixing #137467, but it's a different ICE that regressed more recently.

Meta

rustc --version --verbose:

rustc 1.87.0-nightly (f8c27dfe1 2025-03-24)
binary: rustc
commit-hash: f8c27dfe1a2e7fb538fd91dad53de06992c7c967
commit-date: 2025-03-24
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.1

Error output

thread 'rustc' panicked at compiler/rustc_mir_build/src/builder/matches/match_pair.rs:324:30:
refutable patterns should always have a place to inspect
stack backtrace:
   0:     0x7e7ea845b103 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h28dee7d485be4565
   1:     0x7e7ea8c05b51 - core::fmt::write::hed49133ebafc512c
   2:     0x7e7eaa03eed1 - std::io::Write::write_fmt::h96c675eab0761829
   3:     0x7e7ea845af62 - std::sys::backtrace::BacktraceLock::print::hd150077b5b92907f
   4:     0x7e7ea845d81a - std::panicking::default_hook::{{closure}}::hc334eb150ecfad71
   5:     0x7e7ea845d39f - std::panicking::default_hook::hc8f52b0496dd1041
   6:     0x7e7ea74d1330 - std[7b5691ee7d4d07df]::panicking::update_hook::<alloc[2981cecefd3fc5a4]::boxed::Box<rustc_driver_impl[611c1addf2cce3f]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7e7ea845e093 - std::panicking::rust_panic_with_hook::hf6182f7da084b07a
   8:     0x7e7ea845dd8a - std::panicking::begin_panic_handler::{{closure}}::h426997ed379719db
   9:     0x7e7ea845b5d9 - std::sys::backtrace::__rust_end_short_backtrace::he32ae5677b462ba7
  10:     0x7e7ea845da4d - __rustc[561f529fb5ae8f23]::rust_begin_unwind
  11:     0x7e7ea4e86610 - core::panicking::panic_fmt::he1d506ecd9f48b46
  12:     0x7e7ea61912db - core::option::expect_failed::hf2ca6a55dab3586d
  13:     0x7e7ea94e30ff - <rustc_mir_build[af875f067a42dab4]::builder::matches::MatchPairTree>::for_pattern
  14:     0x7e7ea94eaf39 - <rustc_mir_build[af875f067a42dab4]::builder::Builder>::lower_match_tree
  15:     0x7e7ea94e77de - <rustc_mir_build[af875f067a42dab4]::builder::Builder>::place_into_pattern
  16:     0x7e7ea98f0c6c - <rustc_mir_build[af875f067a42dab4]::builder::Builder>::ast_block_stmts
  17:     0x7e7ea98ef3c5 - <rustc_mir_build[af875f067a42dab4]::builder::Builder>::ast_block
  18:     0x7e7ea8eee04d - <rustc_mir_build[af875f067a42dab4]::builder::Builder>::expr_into_dest
  19:     0x7e7ea8eefef9 - <rustc_mir_build[af875f067a42dab4]::builder::Builder>::expr_into_dest
  20:     0x7e7ea94eeb05 - rustc_mir_build[af875f067a42dab4]::builder::build_mir
  21:     0x7e7ea8c09cf5 - rustc_mir_transform[9fde636ca56913ae]::mir_built
  22:     0x7e7ea8c09cc7 - rustc_query_impl[5378ca482bd296bb]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5378ca482bd296bb]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7d28cec7e9fc3932]::query::erase::Erased<[u8; 8usize]>>
  23:     0x7e7ea8ff3a2c - rustc_query_system[a2be9dcacbe77f66]::query::plumbing::try_execute_query::<rustc_query_impl[5378ca482bd296bb]::DynamicConfig<rustc_data_structures[5ba4159916cb5ba7]::vec_cache::VecCache<rustc_span[a5c1eac4cdc714d]::def_id::LocalDefId, rustc_middle[7d28cec7e9fc3932]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[a2be9dcacbe77f66]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[5378ca482bd296bb]::plumbing::QueryCtxt, false>
  24:     0x7e7ea8ff354b - rustc_query_impl[5378ca482bd296bb]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7e7ea9756a4e - <rustc_mir_build[af875f067a42dab4]::check_unsafety::UnsafetyVisitor>::visit_inner_body
  26:     0x7e7ea9757caf - <rustc_mir_build[af875f067a42dab4]::check_unsafety::UnsafetyVisitor as rustc_middle[7d28cec7e9fc3932]::thir::visit::Visitor>::visit_expr
  27:     0x7e7ea975776c - <rustc_mir_build[af875f067a42dab4]::check_unsafety::UnsafetyVisitor as rustc_middle[7d28cec7e9fc3932]::thir::visit::Visitor>::visit_block
  28:     0x7e7ea9757caf - <rustc_mir_build[af875f067a42dab4]::check_unsafety::UnsafetyVisitor as rustc_middle[7d28cec7e9fc3932]::thir::visit::Visitor>::visit_expr
  29:     0x7e7ea9493e03 - rustc_mir_build[af875f067a42dab4]::check_unsafety::check_unsafety
  30:     0x7e7ea94938f3 - rustc_query_impl[5378ca482bd296bb]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5378ca482bd296bb]::query_impl::check_unsafety::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7d28cec7e9fc3932]::query::erase::Erased<[u8; 0usize]>>
  31:     0x7e7ea9493108 - rustc_query_system[a2be9dcacbe77f66]::query::plumbing::try_execute_query::<rustc_query_impl[5378ca482bd296bb]::DynamicConfig<rustc_data_structures[5ba4159916cb5ba7]::vec_cache::VecCache<rustc_span[a5c1eac4cdc714d]::def_id::LocalDefId, rustc_middle[7d28cec7e9fc3932]::query::erase::Erased<[u8; 0usize]>, rustc_query_system[a2be9dcacbe77f66]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[5378ca482bd296bb]::plumbing::QueryCtxt, false>
  32:     0x7e7ea9492dfe - rustc_query_impl[5378ca482bd296bb]::query_impl::check_unsafety::get_query_non_incr::__rust_end_short_backtrace
  33:     0x7e7ea948fe9b - rustc_interface[5c972e661207e7b9]::passes::run_required_analyses
  34:     0x7e7ea9ac14de - rustc_interface[5c972e661207e7b9]::passes::analysis
  35:     0x7e7ea9ac14b3 - rustc_query_impl[5378ca482bd296bb]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5378ca482bd296bb]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7d28cec7e9fc3932]::query::erase::Erased<[u8; 0usize]>>
  36:     0x7e7ea9d1b43a - rustc_query_system[a2be9dcacbe77f66]::query::plumbing::try_execute_query::<rustc_query_impl[5378ca482bd296bb]::DynamicConfig<rustc_query_system[a2be9dcacbe77f66]::query::caches::SingleCache<rustc_middle[7d28cec7e9fc3932]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[5378ca482bd296bb]::plumbing::QueryCtxt, false>
  37:     0x7e7ea9d1b138 - rustc_query_impl[5378ca482bd296bb]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  38:     0x7e7ea9ec607c - rustc_interface[5c972e661207e7b9]::passes::create_and_enter_global_ctxt::<core[56a6f027e174954b]::option::Option<rustc_interface[5c972e661207e7b9]::queries::Linker>, rustc_driver_impl[611c1addf2cce3f]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  39:     0x7e7ea9d0344f - rustc_interface[5c972e661207e7b9]::interface::run_compiler::<(), rustc_driver_impl[611c1addf2cce3f]::run_compiler::{closure#0}>::{closure#1}
  40:     0x7e7ea9b9f508 - std[7b5691ee7d4d07df]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[5c972e661207e7b9]::util::run_in_thread_with_globals<rustc_interface[5c972e661207e7b9]::util::run_in_thread_pool_with_globals<rustc_interface[5c972e661207e7b9]::interface::run_compiler<(), rustc_driver_impl[611c1addf2cce3f]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  41:     0x7e7ea9b9fdf4 - <<std[7b5691ee7d4d07df]::thread::Builder>::spawn_unchecked_<rustc_interface[5c972e661207e7b9]::util::run_in_thread_with_globals<rustc_interface[5c972e661207e7b9]::util::run_in_thread_pool_with_globals<rustc_interface[5c972e661207e7b9]::interface::run_compiler<(), rustc_driver_impl[611c1addf2cce3f]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[56a6f027e174954b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  42:     0x7e7ea9ba11f7 - std::sys::pal::unix::thread::Thread::new::thread_start::h1fb8fc19ce5c8a2a
  43:     0x7e7eab30ea94 - <unknown>
  44:     0x7e7eab39ba34 - clone
  45:                0x0 - <unknown>

@rustbot label regression-from-stable-to-nightly

@meithecatte meithecatte added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 26, 2025
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Mar 26, 2025
@meithecatte
Copy link
Contributor Author

Offending commit is e3e74bc, part of #137875.

cc @Zalathar

Root cause seems to be that the comment specifying the invariant that got used to justify this change was outdated – TestCase::Or nodes also don't need a place.

@bors bors closed this as completed in 33c9023 Mar 26, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 26, 2025
Rollup merge of rust-lang#138959 - meithecatte:matchpair-place-option, r=Zalathar

Revert "Make MatchPairTree::place non-optional"

Reverts a part of rust-lang#137875. Fixes rust-lang#138958.

cc `@Zalathar`
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 26, 2025
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Mar 27, 2025
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) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants