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 when compiling a program involving a pattern match on a tuple of strings #14927

Closed
mrwright opened this issue Jun 16, 2014 · 2 comments
Closed
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@mrwright
Copy link

The following program causes an ICE:

fn main() {
    match ("", "") {
        (a, "") => a,
        ("", b) => b,
    };
}

The compiler output, with backtraces enabled, is:

$ RUST_BACKTRACE=1 rustc test.rs
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'index out of bounds: the len is 0 but the index is 0', /home/matt/code/apps/rust/rust/src/librustc/middle/check_match.rs:250

stack backtrace:
   1:     0x7fa0afc51af0 - rt::backtrace::imp::write::h58498fa079570ea6AGp::v0.11.0.pre
   2:     0x7fa0afc59220 - failure::on_fail::ha6379e4c4ae5dc18N1p::v0.11.0.pre
   3:     0x7fa0b03ef870 - unwind::begin_unwind_inner::hd80eddaab5a23324QRd::v0.11.0.pre
   4:     0x7fa0b03ef300 - unwind::begin_unwind_fmt::h9099725093fae462jPd::v0.11.0.pre
   5:     0x7fa0b03ef2c0 - rust_begin_unwind
   6:     0x7fa0b043e110 - failure::begin_unwind::h6da20b95db835a9a23v::v0.11.0.pre
   7:     0x7fa0b0441f00 - failure::fail_bounds_check::h4924096447067a67e2v::v0.11.0.pre
   8:     0x7fa0b0f1e880 - middle::check_match::is_useful::h86038b3c4ff660f459A::v0.11.0.pre
   9:     0x7fa0b0f1e880 - middle::check_match::is_useful::h86038b3c4ff660f459A::v0.11.0.pre
  10:     0x7fa0b0f242c0 - middle::check_match::is_useful_specialized::h8c30afeb07f47663nhB::v0.11.0.pre
  11:     0x7fa0b0f1e880 - middle::check_match::is_useful::h86038b3c4ff660f459A::v0.11.0.pre
  12:     0x7fa0b0f242c0 - middle::check_match::is_useful_specialized::h8c30afeb07f47663nhB::v0.11.0.pre
  13:     0x7fa0b0f1e880 - middle::check_match::is_useful::h86038b3c4ff660f459A::v0.11.0.pre
  14:     0x7fa0b0f18f90 - middle::check_match::check_expr::hf9af3ea0df0373f5BRA::v0.11.0.pre
  15:     0x7fa0b0f1dca0 - visit::Visitor::visit_block::h9833201876906112987::v0.11.0.pre
  16:     0x7fa0b0f1ba90 - middle::check_match::check_fn::hbc4df80e3ee3042bBQB::v0.11.0.pre
  17:     0x7fa0b0f1c9d0 - visit::walk_item::h15784207179804928906::v0.11.0.pre
  18:     0x7fa0b0f1bf40 - middle::check_match::check_crate::hf2b699455d6a2b2b7QA::v0.11.0.pre
  19:     0x7fa0b13c0bf0 - driver::driver::phase_3_run_analysis_passes::h26bdb20640374ad81mv::v0.11.0.pre
  20:     0x7fa0b13b9160 - driver::driver::compile_input::h71908766a89db12fgbv::v0.11.0.pre
  21:     0x7fa0b1483c10 - driver::run_compiler::h75dfd515de0d47cfOSx::v0.11.0.pre
  22:     0x7fa0b1483b20 - driver::main_args::closure.98525
  23:     0x7fa0b149f680 - driver::monitor::closure.99615
  24:     0x7fa0b149a5c0 - task::TaskBuilder::try::closure.99378
  25:     0x7fa0b33bfc60 - task::spawn_opts::closure.7148
  26:     0x7fa0b03ec420 - task::Task::run::closure.5303
  27:     0x7fa0b0457960 - rust_try
  28:     0x7fa0b03eee60 - unwind::try::ha9ea19d69d80ec42fGd::v0.11.0.pre
  29:     0x7fa0b03ec2a0 - task::Task::run::h0268eeb27ce86be2VVc::v0.11.0.pre
  30:     0x7fa0b33bfa00 - task::spawn_opts::closure.7121
  31:     0x7fa0b03ee430 - thread::thread_start::hf5e1787e63284712kdd::v0.11.0.pre
  32:     0x7fa0af6cd000 - start_thread
  33:     0x7fa0b00c4fc9 - __clone
  34:                0x0 - <unknown>

Rust version:

$ rustc -v     
rustc 0.11.0-pre (6d8342f 2014-06-14 17:51:49 +0000)
host: x86_64-unknown-linux-gnu

running on Debian unstable.

@huonw huonw added the I-ICE label Jun 16, 2014
@ghost
Copy link

ghost commented Jun 16, 2014

Duplicate of #14393.

@alexcrichton
Copy link
Member

Indeed, thanks @jakub-!

bors added a commit to rust-lang-ci/rust that referenced this issue Jun 5, 2023
…le-struct, r=Veykril

Fix edits for `convert_named_struct_to_tuple_struct`

Two fixes:
- When replacing syntax nodes, macro files weren't taken into account. Edits were simply made for `node.syntax().text_range()`, which would be wrong range when `node` is inside a macro file.
- We do ancestor node traversal for every struct name reference to find record expressions/patterns to edit, but we didn't verify that expressions/patterns do actually refer to the struct we're operating on.

Best reviewed one commit at a time.

Fixes rust-lang#13780
Fixes rust-lang#14927
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants