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: exhaustiveness-non-exhaustive.rs with -Zinstrument-coverage: sumup_counter_operand should have a value #79569

Closed
matthiaskrgr opened this issue Nov 30, 2020 · 1 comment · Fixed by #79958
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) 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) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

code from ./src/test/ui/or-patterns/exhaustiveness-non-exhaustive.rs

#![feature(or_patterns)]
#![deny(unreachable_patterns)]

// We wrap patterns in a tuple because top-level or-patterns were special-cased.
fn main() {
    match (0u8, 0u8) {
        //~^ ERROR non-exhaustive patterns: `(2_u8..=u8::MAX, _)`
        (0 | 1, 2 | 3) => {}
    }
    match ((0u8,),) {
        //~^ ERROR non-exhaustive patterns: `((4_u8..=u8::MAX))`
        ((0 | 1,) | (2 | 3,),) => {}
    }
    match (Some(0u8),) {
        //~^ ERROR non-exhaustive patterns: `(Some(2_u8..=u8::MAX))`
        (None | Some(0 | 1),) => {}
    }
}

Meta

rustc --version --verbose:

rustc 1.50.0-nightly (b7ebc6b0c 2020-11-30)
binary: rustc
commit-hash: b7ebc6b0c1ba3c27ebb17c0b496ece778ef11e18
commit-date: 2020-11-30
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly

Error output

error[E0004]: non-exhaustive patterns: `(2_u8..=u8::MAX, _)` not covered
 --> ./src/test/ui/or-patterns/exhaustiveness-non-exhaustive.rs:6:11
  |
6 |     match (0u8, 0u8) {
  |           ^^^^^^^^^^ pattern `(2_u8..=u8::MAX, _)` not covered
  |
  = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
  = note: the matched value is of type `(u8, u8)`

error[E0004]: non-exhaustive patterns: `((4_u8..=u8::MAX))` not covered
  --> ./src/test/ui/or-patterns/exhaustiveness-non-exhaustive.rs:10:11
   |
10 |     match ((0u8,),) {
   |           ^^^^^^^^^ pattern `((4_u8..=u8::MAX))` not covered
   |
   = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
   = note: the matched value is of type `((u8,),)`

error[E0004]: non-exhaustive patterns: `(Some(2_u8..=u8::MAX))` not covered
  --> ./src/test/ui/or-patterns/exhaustiveness-non-exhaustive.rs:14:11
   |
14 |     match (Some(0u8),) {
   |           ^^^^^^^^^^^^ pattern `(Some(2_u8..=u8::MAX))` not covered
   |
   = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
   = note: the matched value is of type `(Option<u8>,)`

thread 'rustc' panicked at 'sumup_counter_operand should have a value', compiler/rustc_mir/src/transform/coverage/counters.rs:274:40
note: run with `RUST_BACKTRACE=1` environment variable to display a 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.50.0-nightly (b7ebc6b0c 2020-11-30) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z instrument-coverage

query stack during panic:
#0 [mir_promoted] processing `main`
#1 [mir_borrowck] borrow-checking `main`
end of query stack
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0004`.
Backtrace

thread 'rustc' panicked at 'sumup_counter_operand should have a value', compiler/rustc_mir/src/transform/coverage/counters.rs:274:40
stack backtrace:
   0:     0x7f4456b2ee00 - std::backtrace_rs::backtrace::libunwind::trace::h746c3e9529d524bc
                               at /rustc/b7ebc6b0c1ba3c27ebb17c0b496ece778ef11e18/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7f4456b2ee00 - std::backtrace_rs::backtrace::trace_unsynchronized::h86340908ff889faa
                               at /rustc/b7ebc6b0c1ba3c27ebb17c0b496ece778ef11e18/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f4456b2ee00 - std::sys_common::backtrace::_print_fmt::h43f85f9b18230404
                               at /rustc/b7ebc6b0c1ba3c27ebb17c0b496ece778ef11e18/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f4456b2ee00 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc132ae1a5b5aa7cd
                               at /rustc/b7ebc6b0c1ba3c27ebb17c0b496ece778ef11e18/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7f4456ba1b9c - core::fmt::write::hdf023a0036d2a25f
                               at /rustc/b7ebc6b0c1ba3c27ebb17c0b496ece778ef11e18/library/core/src/fmt/mod.rs:1078:17
   5:     0x7f4456b20972 - std::io::Write::write_fmt::h8580846154bcb66a
                               at /rustc/b7ebc6b0c1ba3c27ebb17c0b496ece778ef11e18/library/std/src/io/mod.rs:1519:15
   6:     0x7f4456b32a65 - std::sys_common::backtrace::_print::h7ee55fed88d107a3
                               at /rustc/b7ebc6b0c1ba3c27ebb17c0b496ece778ef11e18/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7f4456b32a65 - std::sys_common::backtrace::print::h54a7d3e52a524177
                               at /rustc/b7ebc6b0c1ba3c27ebb17c0b496ece778ef11e18/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7f4456b32a65 - std::panicking::default_hook::{{closure}}::h60921e857bf55a40
                               at /rustc/b7ebc6b0c1ba3c27ebb17c0b496ece778ef11e18/library/std/src/panicking.rs:208:50
   9:     0x7f4456b325ba - std::panicking::default_hook::hf0f9afb1017317fc
                               at /rustc/b7ebc6b0c1ba3c27ebb17c0b496ece778ef11e18/library/std/src/panicking.rs:225:9
  10:     0x7f44573c4428 - rustc_driver::report_ice::ha25ae86a5858acc3
  11:     0x7f4456b33366 - std::panicking::rust_panic_with_hook::h8d66bf42b407aaea
                               at /rustc/b7ebc6b0c1ba3c27ebb17c0b496ece778ef11e18/library/std/src/panicking.rs:595:17
  12:     0x7f4456b32e87 - std::panicking::begin_panic_handler::{{closure}}::hde71edcd925d0c5e
                               at /rustc/b7ebc6b0c1ba3c27ebb17c0b496ece778ef11e18/library/std/src/panicking.rs:497:13
  13:     0x7f4456b2f2bc - std::sys_common::backtrace::__rust_end_short_backtrace::h8a3c7d6cea578919
                               at /rustc/b7ebc6b0c1ba3c27ebb17c0b496ece778ef11e18/library/std/src/sys_common/backtrace.rs:141:18
  14:     0x7f4456b32de9 - rust_begin_unwind
                               at /rustc/b7ebc6b0c1ba3c27ebb17c0b496ece778ef11e18/library/std/src/panicking.rs:493:5
  15:     0x7f4456b9dfb1 - core::panicking::panic_fmt::h20225113c4a2f8fd
                               at /rustc/b7ebc6b0c1ba3c27ebb17c0b496ece778ef11e18/library/core/src/panicking.rs:92:14
  16:     0x7f4456b9db93 - core::option::expect_failed::h8be1ca96ca0d69ca
                               at /rustc/b7ebc6b0c1ba3c27ebb17c0b496ece778ef11e18/library/core/src/option.rs:1260:5
  17:     0x7f44589b0cc9 - rustc_mir::transform::coverage::counters::CoverageCounters::make_bcb_counters::h09189a1663c71aa0
  18:     0x7f4458cba418 - <rustc_mir::transform::coverage::InstrumentCoverage as rustc_mir::transform::MirPass>::run_pass::h63163fe939ee6941
  19:     0x7f4458c221ad - rustc_mir::transform::run_passes::hde85252c218e451d
  20:     0x7f4458c22ff9 - rustc_mir::transform::mir_promoted::hbf030df47a64ef91
  21:     0x7f4458c739b1 - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_promoted>::compute::hd22b0a9058b7bb65
  22:     0x7f4458aa1b53 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::hff3904454383c89e
  23:     0x7f4458b487c8 - rustc_data_structures::stack::ensure_sufficient_stack::he581a4f69947db11
  24:     0x7f4458883be1 - rustc_query_system::query::plumbing::get_query_impl::h20d9617555a285f4
  25:     0x7f4458ca9024 - rustc_mir::borrow_check::mir_borrowck::h8fcfde9d3bc3965f
  26:     0x7f4458c7b845 - core::ops::function::FnOnce::call_once::hda8d7f4d3e0163df
  27:     0x7f445761192e - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_borrowck>::compute::hd320f4ca41a47c0c
  28:     0x7f44575d08e0 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::hbff93ce2cea26122
  29:     0x7f4457614bfb - rustc_data_structures::stack::ensure_sufficient_stack::he17b7629a75337fd
  30:     0x7f44575ad5a4 - rustc_query_system::query::plumbing::get_query_impl::hc38aca5d51d5691a
  31:     0x7f44575b5719 - rustc_query_system::query::plumbing::ensure_query_impl::h474c3afdd9b59c6e
  32:     0x7f44575ee999 - rustc_session::utils::<impl rustc_session::session::Session>::time::hd10f52cc7be7a8fd
  33:     0x7f4457622542 - rustc_interface::passes::analysis::h342855b4d8ce9897
  34:     0x7f4457380f2b - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute::h95ff81a8a73eaff3
  35:     0x7f4457411c06 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_eval_always_task::h71fd6f4f43205659
  36:     0x7f4457420ee6 - rustc_data_structures::stack::ensure_sufficient_stack::h426420634e295fa0
  37:     0x7f44573aeb44 - rustc_query_system::query::plumbing::get_query_impl::h59cb47161047ab66
  38:     0x7f44573835fb - rustc_interface::passes::QueryContext::enter::heace2ac35bf577de
  39:     0x7f445741ea65 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::hcfd2504bb4e8d292
  40:     0x7f44573ecd37 - rustc_span::with_source_map::hdf17fa3a4d8fe35b
  41:     0x7f445741ae8c - scoped_tls::ScopedKey<T>::set::h5dca480b178bbfab
  42:     0x7f4457421fa5 - std::sys_common::backtrace::__rust_begin_short_backtrace::ha4cbf96baa7e4912
  43:     0x7f445738ab4a - core::ops::function::FnOnce::call_once{{vtable.shim}}::he2d69591c700ddc8
  44:     0x7f4456b4262a - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hea1090dbdcecbf5a
                               at /rustc/b7ebc6b0c1ba3c27ebb17c0b496ece778ef11e18/library/alloc/src/boxed.rs:1327:9
  45:     0x7f4456b4262a - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8d5723d3912bd325
                               at /rustc/b7ebc6b0c1ba3c27ebb17c0b496ece778ef11e18/library/alloc/src/boxed.rs:1327:9
  46:     0x7f4456b4262a - std::sys::unix::thread::Thread::new::thread_start::hc17a425ca2995724
                               at /rustc/b7ebc6b0c1ba3c27ebb17c0b496ece778ef11e18/library/std/src/sys/unix/thread.rs:71:17
  47:     0x7f4456a383e9 - start_thread
  48:     0x7f4456955293 - __GI___clone
  49:                0x0 - <unknown>

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.50.0-nightly (b7ebc6b0c 2020-11-30) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z instrument-coverage

query stack during panic:
#0 [mir_promoted] processing `main`
#1 [mir_borrowck] borrow-checking `main`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0004`.

@matthiaskrgr matthiaskrgr 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 Nov 30, 2020
@matthiaskrgr
Copy link
Member Author

@rustbot label: +A-code-coverage +requires-nightly

@rustbot rustbot added A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) requires-nightly This issue requires a nightly compiler in some way. labels Nov 30, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Dec 12, 2020
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Dec 15, 2020
…2.0, r=tmandry

Fixes reported bugs in Rust Coverage

Fixes: rust-lang#79569

Fixes: rust-lang#79566
Fixes: rust-lang#79565

For the first issue (rust-lang#79569), I got hit a `debug_assert!()` before
encountering the reported error message (because I have `debug = true`
enabled in my config.toml).

The assertion showed me that some `SwitchInt`s can have more than one
target pointing to the same `BasicBlock`.

I had thought that was invalid, but since it seems to be possible, I'm
allowing this now.

I added a new test for this.

----

In the last two cases above, both tests (intentionally) fail to compile,
but the `InstrumentCoverage` pass is invoked anyway.

The MIR starts with an `Unreachable` `BasicBlock`, which I hadn't
encountered before. (I had assumed the `InstrumentCoverage` pass
would only be invoked with MIRs from successful compilations.)

I don't have test infrastructure set up to test coverage on files that
fail to compile, so I didn't add a new test.

r? `@tmandry`
FYI: `@wesleywiser`
@bors bors closed this as completed in eb963ff Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) 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) ❄️ requires-nightly This issue requires a nightly compiler in some way. 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