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: deconstructing a pattern with multiple variable bindings of OR'ed strings. #97898

Closed
StephanvanSchaik opened this issue Jun 8, 2022 · 1 comment · Fixed by #98200
Closed
Assignees
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. 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.

Comments

@StephanvanSchaik
Copy link

StephanvanSchaik commented Jun 8, 2022

Code

This ICE triggers for the following code, in which the pattern involves two variable bindings, each for two strings OR'ed together:

fn main() {
    let x = "foo";
    
    match x {
        x @ ("foo" | "bar") |
        x @ ("red" | "blue") => {
        }
        _ => (),
    }
}

If you put them all on a single line as follows, then the code compiles fine:

        x @ ("foo" | "bar" | "red" | "blue") => {

In addition, without the variable bindings, the code also compiles fine:

        "foo" | "bar" |
        "red" | "blue" => {

Meta

rustc --version --verbose:

rustc 1.61.0 (fe5b13d68 2022-05-18)
binary: rustc
commit-hash: fe5b13d681f25ee6474be29d748c65adcd91f69e
commit-date: 2022-05-18
host: x86_64-unknown-linux-gnu
release: 1.61.0
LLVM version: 14.0.0

rustc --nightly --version --verbose:

rustc 1.63.0-nightly (5435ed691 2022-06-07)
binary: rustc
commit-hash: 5435ed6916a59e8d5acba2149316a841c3905cbd
commit-date: 2022-06-07
host: x86_64-unknown-linux-gnu
release: 1.63.0-nightly
LLVM version: 14.0.5

Error output

error: internal compiler error: compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs:869:18: trying to compare incompatible constructors Single and Or
 --> src/main.rs:8:9
  |
8 |         _ => (),
  |

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/compiler/rustc_errors/src/lib.rs:1223:9
stack backtrace:
   0:     0x7fb7750841cd - std::backtrace_rs::backtrace::libunwind::trace::h22893a5306c091b4
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fb7750841cd - std::backtrace_rs::backtrace::trace_unsynchronized::h29c3bc6f9e91819d
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fb7750841cd - std::sys_common::backtrace::_print_fmt::he497d8a0ec903793
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7fb7750841cd - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9c2a9d2774d81873
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7fb7750de01c - core::fmt::write::hba4337c43d992f49
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/fmt/mod.rs:1194:17
   5:     0x7fb7750757c1 - std::io::Write::write_fmt::heb73de6e02cfabed
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/io/mod.rs:1655:15
   6:     0x7fb7750872b5 - std::sys_common::backtrace::_print::h63c8b24acdd8e8ce
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7fb7750872b5 - std::sys_common::backtrace::print::h426700d6240cdcc2
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7fb7750872b5 - std::panicking::default_hook::{{closure}}::hc9a76eed0b18f82b
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:295:22
   9:     0x7fb775086f69 - std::panicking::default_hook::h2e88d02087fae196
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:314:9
  10:     0x7fb7758041d1 - rustc_driver[413d55b6344850e3]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fb775087a00 - std::panicking::rust_panic_with_hook::habfdcc2e90f9fd4c
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:702:17
  12:     0x7fb775d12201 - std[3b302b3c9093c22]::panicking::begin_panic::<rustc_errors[a7dbbf867eaca825]::ExplicitBug>::{closure#0}
  13:     0x7fb775d11c86 - std[3b302b3c9093c22]::sys_common::backtrace::__rust_end_short_backtrace::<std[3b302b3c9093c22]::panicking::begin_panic<rustc_errors[a7dbbf867eaca825]::ExplicitBug>::{closure#0}, !>
  14:     0x7fb775d1de06 - std[3b302b3c9093c22]::panicking::begin_panic::<rustc_errors[a7dbbf867eaca825]::ExplicitBug>
  15:     0x7fb775d3824d - std[3b302b3c9093c22]::panic::panic_any::<rustc_errors[a7dbbf867eaca825]::ExplicitBug>
  16:     0x7fb775d37199 - <rustc_errors[a7dbbf867eaca825]::HandlerInner>::span_bug::<rustc_span[7238ca7210ca999e]::span_encoding::Span>
  17:     0x7fb775d37060 - <rustc_errors[a7dbbf867eaca825]::Handler>::span_bug::<rustc_span[7238ca7210ca999e]::span_encoding::Span>
  18:     0x7fb775d2ff92 - rustc_middle[9ca07169fec39ed9]::ty::context::tls::with_opt::<rustc_middle[9ca07169fec39ed9]::util::bug::opt_span_bug_fmt<rustc_span[7238ca7210ca999e]::span_encoding::Span>::{closure#0}, ()>
  19:     0x7fb775d2fe06 - rustc_middle[9ca07169fec39ed9]::util::bug::opt_span_bug_fmt::<rustc_span[7238ca7210ca999e]::span_encoding::Span>
  20:     0x7fb775d2fdc4 - rustc_middle[9ca07169fec39ed9]::util::bug::span_bug_fmt::<rustc_span[7238ca7210ca999e]::span_encoding::Span>
  21:     0x7fb776ed244b - rustc_mir_build[8ab184d73af5ecd6]::thir::pattern::usefulness::is_useful
  22:     0x7fb776ecfab8 - rustc_mir_build[8ab184d73af5ecd6]::thir::pattern::usefulness::compute_match_usefulness
  23:     0x7fb776ec51b4 - <rustc_mir_build[8ab184d73af5ecd6]::thir::pattern::check_match::MatchVisitor as rustc_hir[39b6c6275f771301]::intravisit::Visitor>::visit_expr
  24:     0x7fb776ec4e09 - <rustc_mir_build[8ab184d73af5ecd6]::thir::pattern::check_match::MatchVisitor as rustc_hir[39b6c6275f771301]::intravisit::Visitor>::visit_expr
  25:     0x7fb776ec47a3 - rustc_mir_build[8ab184d73af5ecd6]::thir::pattern::check_match::check_match
  26:     0x7fb777c7f819 - <rustc_query_system[ac245aac4c1950a0]::dep_graph::graph::DepGraph<rustc_middle[9ca07169fec39ed9]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[9ca07169fec39ed9]::ty::context::TyCtxt, rustc_span[7238ca7210ca999e]::def_id::DefId, ()>
  27:     0x7fb7771496f9 - rustc_query_system[ac245aac4c1950a0]::query::plumbing::try_execute_query::<rustc_query_impl[b0f4194b24b225ee]::plumbing::QueryCtxt, rustc_query_system[ac245aac4c1950a0]::query::caches::DefaultCache<rustc_span[7238ca7210ca999e]::def_id::DefId, ()>>
  28:     0x7fb777211c80 - <rustc_query_impl[b0f4194b24b225ee]::Queries as rustc_middle[9ca07169fec39ed9]::ty::query::QueryEngine>::check_match
  29:     0x7fb776a31421 - <rustc_session[8df92abe178df33c]::session::Session>::time::<(), rustc_interface[550884b2b179878f]::passes::analysis::{closure#1}::{closure#0}::{closure#0}>
  30:     0x7fb7777136c4 - <rustc_session[8df92abe178df33c]::session::Session>::time::<(), rustc_interface[550884b2b179878f]::passes::analysis::{closure#1}>
  31:     0x7fb777706b2e - rustc_interface[550884b2b179878f]::passes::analysis
  32:     0x7fb777c8a185 - <rustc_query_system[ac245aac4c1950a0]::dep_graph::graph::DepGraph<rustc_middle[9ca07169fec39ed9]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[9ca07169fec39ed9]::ty::context::TyCtxt, (), core[a3420257622cd381]::result::Result<(), rustc_errors[a7dbbf867eaca825]::ErrorGuaranteed>>
  33:     0x7fb777bcd062 - rustc_query_system[ac245aac4c1950a0]::query::plumbing::try_execute_query::<rustc_query_impl[b0f4194b24b225ee]::plumbing::QueryCtxt, rustc_query_system[ac245aac4c1950a0]::query::caches::DefaultCache<(), core[a3420257622cd381]::result::Result<(), rustc_errors[a7dbbf867eaca825]::ErrorGuaranteed>>>
  34:     0x7fb777c0fdfe - rustc_query_system[ac245aac4c1950a0]::query::plumbing::get_query::<rustc_query_impl[b0f4194b24b225ee]::queries::analysis, rustc_query_impl[b0f4194b24b225ee]::plumbing::QueryCtxt>
  35:     0x7fb7776cc881 - <rustc_interface[550884b2b179878f]::passes::QueryContext>::enter::<rustc_driver[413d55b6344850e3]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[a3420257622cd381]::result::Result<(), rustc_errors[a7dbbf867eaca825]::ErrorGuaranteed>>
  36:     0x7fb7776e6a58 - <rustc_interface[550884b2b179878f]::interface::Compiler>::enter::<rustc_driver[413d55b6344850e3]::run_compiler::{closure#1}::{closure#2}, core[a3420257622cd381]::result::Result<core[a3420257622cd381]::option::Option<rustc_interface[550884b2b179878f]::queries::Linker>, rustc_errors[a7dbbf867eaca825]::ErrorGuaranteed>>
  37:     0x7fb7776cc03f - rustc_span[7238ca7210ca999e]::with_source_map::<core[a3420257622cd381]::result::Result<(), rustc_errors[a7dbbf867eaca825]::ErrorGuaranteed>, rustc_interface[550884b2b179878f]::interface::create_compiler_and_run<core[a3420257622cd381]::result::Result<(), rustc_errors[a7dbbf867eaca825]::ErrorGuaranteed>, rustc_driver[413d55b6344850e3]::run_compiler::{closure#1}>::{closure#1}>
  38:     0x7fb7776e80a4 - rustc_interface[550884b2b179878f]::interface::create_compiler_and_run::<core[a3420257622cd381]::result::Result<(), rustc_errors[a7dbbf867eaca825]::ErrorGuaranteed>, rustc_driver[413d55b6344850e3]::run_compiler::{closure#1}>
  39:     0x7fb7776ca7c2 - <scoped_tls[7ed3ce20ede545d8]::ScopedKey<rustc_span[7238ca7210ca999e]::SessionGlobals>>::set::<rustc_interface[550884b2b179878f]::interface::run_compiler<core[a3420257622cd381]::result::Result<(), rustc_errors[a7dbbf867eaca825]::ErrorGuaranteed>, rustc_driver[413d55b6344850e3]::run_compiler::{closure#1}>::{closure#0}, core[a3420257622cd381]::result::Result<(), rustc_errors[a7dbbf867eaca825]::ErrorGuaranteed>>
  40:     0x7fb7776e038f - std[3b302b3c9093c22]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[550884b2b179878f]::util::run_in_thread_pool_with_globals<rustc_interface[550884b2b179878f]::interface::run_compiler<core[a3420257622cd381]::result::Result<(), rustc_errors[a7dbbf867eaca825]::ErrorGuaranteed>, rustc_driver[413d55b6344850e3]::run_compiler::{closure#1}>::{closure#0}, core[a3420257622cd381]::result::Result<(), rustc_errors[a7dbbf867eaca825]::ErrorGuaranteed>>::{closure#0}, core[a3420257622cd381]::result::Result<(), rustc_errors[a7dbbf867eaca825]::ErrorGuaranteed>>
  41:     0x7fb7776cbaf9 - <<std[3b302b3c9093c22]::thread::Builder>::spawn_unchecked_<rustc_interface[550884b2b179878f]::util::run_in_thread_pool_with_globals<rustc_interface[550884b2b179878f]::interface::run_compiler<core[a3420257622cd381]::result::Result<(), rustc_errors[a7dbbf867eaca825]::ErrorGuaranteed>, rustc_driver[413d55b6344850e3]::run_compiler::{closure#1}>::{closure#0}, core[a3420257622cd381]::result::Result<(), rustc_errors[a7dbbf867eaca825]::ErrorGuaranteed>>::{closure#0}, core[a3420257622cd381]::result::Result<(), rustc_errors[a7dbbf867eaca825]::ErrorGuaranteed>>::{closure#1} as core[a3420257622cd381]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  42:     0x7fb775091bf3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha99802c2c52ada61
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/alloc/src/boxed.rs:1861:9
  43:     0x7fb775091bf3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha39aea1c57e28a15
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/alloc/src/boxed.rs:1861:9
  44:     0x7fb775091bf3 - std::sys::unix::thread::Thread::new::thread_start::h9f8e3d72b1f7662f
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys/unix/thread.rs:108:17
  45:     0x7fb774e31d47 - start_thread
  46:     0x7fb774eb45cc - clone3
  47:                0x0 - <unknown>

note: 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: rustc 1.61.0 (fe5b13d68 2022-05-18) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental

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

query stack during panic:
#0 [check_match] match-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
Backtrace

error: internal compiler error: compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs:869:18: trying to compare incompatible constructors Single and Or
  --> src/main.rs:8:9
   |
11 |         _ => (),
   |

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/5435ed6916a59e8d5acba2149316a841c3905cbd/compiler/rustc_errors/src/lib.rs:1274:9
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: std::panic::panic_any::<rustc_errors::ExplicitBug>
   2: <rustc_errors::HandlerInner>::span_bug::<rustc_span::span_encoding::Span, &alloc::string::String>
   3: <rustc_errors::Handler>::span_bug::<rustc_span::span_encoding::Span, &alloc::string::String>
   4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, ()>
   5: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>
   6: rustc_middle::util::bug::span_bug_fmt::<rustc_span::span_encoding::Span>
   7: rustc_mir_build::thir::pattern::usefulness::is_useful
   8: rustc_mir_build::thir::pattern::usefulness::compute_match_usefulness
   9: <rustc_mir_build::thir::pattern::check_match::MatchVisitor as rustc_hir::intravisit::Visitor>::visit_expr
  10: <rustc_mir_build::thir::pattern::check_match::MatchVisitor as rustc_hir::intravisit::Visitor>::visit_expr
  11: rustc_mir_build::thir::pattern::check_match::check_match
  12: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId, ()>
  13: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, ()>>
  14: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_match
  15: <rustc_middle::hir::map::Map>::par_body_owners::<rustc_interface::passes::analysis::{closure#1}::{closure#0}::{closure#0}::{closure#0}>
  16: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#1}::{closure#0}::{closure#0}>
  17: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#1}>
  18: rustc_interface::passes::analysis
  19: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  20: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorGuaranteed>>>
  21: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  22: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  23: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorGuaranteed>>
  24: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
  25: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: 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: rustc 1.63.0-nightly (5435ed691 2022-06-07) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental

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

query stack during panic:
#0 [check_match] match-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack

@StephanvanSchaik StephanvanSchaik 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 Jun 8, 2022
matthiaskrgr added a commit to matthiaskrgr/glacier that referenced this issue Jun 9, 2022
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jun 9, 2022
@ouz-a
Copy link
Contributor

ouz-a commented Jun 17, 2022

@rustbot claim

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. glacier ICE tracked in rust-lang/glacier. 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants