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

Matching unbound reference to string in tuple causes ICE #78604

Closed
tversteeg opened this issue Oct 31, 2020 · 4 comments
Closed

Matching unbound reference to string in tuple causes ICE #78604

tversteeg opened this issue Oct 31, 2020 · 4 comments
Labels
A-exhaustiveness-checking Relating to exhaustiveness / usefulness checking of patterns 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

@tversteeg
Copy link
Contributor

tversteeg commented Oct 31, 2020

Code

fn main() {
	match ("", ()) {
		(&_, _) => (),
	}
}

Meta

rustc --version --verbose:

rustc 1.49.0-nightly (ffe52882e 2020-10-30)
binary: rustc
commit-hash: ffe52882ed79be67344dd6085559e308241e7f60
commit-date: 2020-10-30
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly

Error output

thread 'rustc' panicked at 'assertion failed: rows.iter().all(|r| r.len() == v.len())', compiler/rustc_mir_build/src/thir/pattern/_match.rs:2069:5
Backtrace

     Running `sccache rustc --crate-name compiler_test --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=621a9c4c255209bb -C extra-filename=-621a9c4c255209bb --out-dir /home/thomas/r/test/target/debug/deps -C incremental=/home/thomas/r/test/target/debug/incremental -L dependency=/home/thomas/r/test/target/debug/deps --extern clap=/home/thomas/r/test/target/debug/deps/libclap-1c36037ddec5517c.rlib`
thread 'rustc' panicked at 'assertion failed: rows.iter().all(|r| r.len() == v.len())', compiler/rustc_mir_build/src/thir/pattern/_match.rs:2069:5
stack backtrace:
   0: std::panicking::begin_panic
   1: rustc_mir_build::thir::pattern::_match::is_useful
   2: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold
   3: rustc_mir_build::thir::pattern::_match::is_useful
   4: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold
   5: rustc_mir_build::thir::pattern::_match::is_useful
   6: rustc_mir_build::thir::pattern::check_match::check_not_useful
   7: <rustc_mir_build::thir::pattern::check_match::MatchVisitor as rustc_hir::intravisit::Visitor>::visit_expr
   8: <rustc_mir_build::thir::pattern::check_match::MatchVisitor as rustc_hir::intravisit::Visitor>::visit_expr
   9: rustc_mir_build::thir::pattern::check_match::check_match
  10: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::check_match>::compute
  11: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  12: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  13: rustc_data_structures::stack::ensure_sufficient_stack
  14: rustc_query_system::query::plumbing::get_query_impl
  15: rustc_query_system::query::plumbing::ensure_query_impl
  16: rustc_interface::passes::analysis
  17: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  18: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  19: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  20: rustc_data_structures::stack::ensure_sufficient_stack
  21: rustc_query_system::query::plumbing::get_query_impl
  22: rustc_interface::passes::QueryContext::enter
  23: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  24: rustc_span::with_source_map
  25: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

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.49.0-nightly (ffe52882e 2020-10-30) running on x86_64-unknown-linux-gnu

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

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
error: could not compile `compiler_test`

Caused by:
  process didn't exit successfully: `sccache rustc --crate-name compiler_test --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=621a9c4c255209bb -C extra-filename=-621a9c4c255209bb --out-dir /home/thomas/r/test/target/debug/deps -C incremental=/home/thomas/r/test/target/debug/incremental -L dependency=/home/thomas/r/test/target/debug/deps --extern clap=/home/thomas/r/test/target/debug/deps/libclap-1c36037ddec5517c.rlib` (exit code: 101)

@tversteeg tversteeg 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 Oct 31, 2020
@tversteeg tversteeg changed the title Matching unbound reference to string in tuple crashes compiler Matching unbound reference to string in tuple causes ICE Oct 31, 2020
@SNCPlay42
Copy link
Contributor

Different panic message/backtrace but the code looks similar to #78549

@rustbot modify labels: +regression-from-stable-to-nightly

@rustbot rustbot added 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 Oct 31, 2020
@jyn514
Copy link
Member

jyn514 commented Oct 31, 2020

cc @Nadrieril

@jyn514 jyn514 added the A-exhaustiveness-checking Relating to exhaustiveness / usefulness checking of patterns label Oct 31, 2020
@jyn514
Copy link
Member

jyn514 commented Oct 31, 2020

You can workaround it by removing the &:

fn main() {
	match ("", ()) {
		(_, _) => (),
	}
}

@jyn514
Copy link
Member

jyn514 commented Oct 31, 2020

This has a test case in #78553, so I'm going to close this as a duplicate of #78549.

@jyn514 jyn514 closed this as completed Oct 31, 2020
@jyn514 jyn514 removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Oct 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-exhaustiveness-checking Relating to exhaustiveness / usefulness checking of patterns 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

No branches or pull requests

4 participants