Skip to content

ICE: unexpected value of coverage attribute #127880

Closed

Description

auto-reduced (treereduce-rust):

#[coverage]

fn main() {}
original code

original:

#![feature(coverage_attribute)]
//@ edition: 2021

// Demonstrates the diagnostics produced when using the syntax `#[coverage]`,
// which should not be allowed.
//
// The syntax is tested both in places that can have a coverage attribute,
// and in places that cannot have a coverage attribute, to demonstrate the
// interaction between multiple errors.

#[coverage]
//~^ ERROR malformed `coverage` attribute input
mod my_mod {}

mod my_mod_inner {
    #![coverage]
    //~^ ERROR malformed `coverage` attribute input
}

#[coverage]
//~^ ERROR malformed `coverage` attribute input
//~| ERROR attribute should be applied to a function definition or closure
struct MyStruct;

#[coverage]
//~^ ERROR malformed `coverage` attribute input
impl MyStruct {
    #[coverage]
    //~^ ERROR malformed `coverage` attribute input
    //~| ERROR attribute should be applied to a function definition or closure
    const X: u32 = 7;
}

#[coverage]
//~^ ERROR malformed `coverage` attribute input
//~| ERROR attribute should be applied to a function definition or closure
trait MyTrait {
    #[coverage]
    //~^ ERROR malformed `coverage` attribute input
    //~| ERROR attribute should be applied to a function definition or closure
    const X: u32;

    #[coverage]
    //~^ ERROR malformed `coverage` attribute input
    //~| ERROR attribute should be applied to a function definition or closure
    type T;
}

#[coverage]
//~^ ERROR malformed `coverage` attribute input
impl MyTrait for MyStruct {
    #[coverage]
    //~^ ERROR malformed `coverage` attribute input
    //~| ERROR attribute should be applied to a function definition or closure
    const X: u32 = 8;

    #[coverage]
    //~^ ERROR malformed `coverage` attribute input
    //~| ERROR attribute should be applied to a function definition or closure
    type T = ();
}

#[coverage]
//~^ ERROR malformed `coverage` attribute input
fn main() {}

Version information

rustc 1.81.0-nightly (fcc325f1b 2024-07-17)
binary: rustc
commit-hash: fcc325f1bc477975e2ce5ba534fe4c77ff8a8536
commit-date: 2024-07-17
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Cinstrument-coverage

Program output

error: malformed `coverage` attribute input
 --> /tmp/icemaker_global_tempdir.4O1Z9G3tMNfo/rustc_testrunner_tmpdir_reporting.c2V17EKwJr3h/mvce.rs:3:1
  |
3 | #[coverage]
  | ^^^^^^^^^^^
  |
help: the following are the possible correct uses
  |
3 | #[coverage(off)]
  |
3 | #[coverage(on)]
  |

error[E0658]: the `#[coverage]` attribute is an experimental feature
 --> /tmp/icemaker_global_tempdir.4O1Z9G3tMNfo/rustc_testrunner_tmpdir_reporting.c2V17EKwJr3h/mvce.rs:3:1
  |
3 | #[coverage]
  | ^^^^^^^^^^^
  |
  = note: see issue #84605 <https://github.com/rust-lang/rust/issues/84605> for more information
  = help: add `#![feature(coverage_attribute)]` to the crate attributes to enable
  = note: this compiler was built on 2024-07-17; consider upgrading it if it is out of date

error: internal compiler error: unexpected value of coverage attribute
 --> /tmp/icemaker_global_tempdir.4O1Z9G3tMNfo/rustc_testrunner_tmpdir_reporting.c2V17EKwJr3h/mvce.rs:3:1
  |
3 | #[coverage]
  | ^^^^^^^^^^^

thread 'rustc' panicked at compiler/rustc_mir_transform/src/coverage/query.rs:65:27:
Box<dyn Any>
stack backtrace:
   0:     0x73b8a97783e5 - std::backtrace_rs::backtrace::libunwind::trace::h7d42dda8f80cfb99
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x73b8a97783e5 - std::backtrace_rs::backtrace::trace_unsynchronized::hd585f8afb233c9ee
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x73b8a97783e5 - std::sys::backtrace::_print_fmt::h224c15dbafc899ab
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/std/src/sys/backtrace.rs:65:5
   3:     0x73b8a97783e5 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hca750ad87bb2f1d4
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/std/src/sys/backtrace.rs:40:26
   4:     0x73b8a97c7e3b - core::fmt::rt::Argument::fmt::hf85ec79e8cf86c67
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/core/src/fmt/rt.rs:173:76
   5:     0x73b8a97c7e3b - core::fmt::write::h133a0eb20f0a6a5d
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/core/src/fmt/mod.rs:1182:21
   6:     0x73b8a976ce9f - std::io::Write::write_fmt::h0b1c7497ddea4e96
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/std/src/io/mod.rs:1827:15
   7:     0x73b8a977abd1 - std::sys::backtrace::BacktraceLock::print::h7ea149d21a641076
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/std/src/sys/backtrace.rs:43:9
   8:     0x73b8a977abd1 - std::panicking::default_hook::{{closure}}::h7dd45b5804215332
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/std/src/panicking.rs:269:22
   9:     0x73b8a977a8ac - std::panicking::default_hook::haed8ee3169af9669
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/std/src/panicking.rs:296:9
  10:     0x73b8a5bf5aa9 - std[a568119b01f6acf9]::panicking::update_hook::<alloc[bb4b795e710d07dc]::boxed::Box<rustc_driver_impl[8e1afaf50ebeb9ae]::install_ice_hook::{closure#0}>>::{closure#0}
  11:     0x73b8a977b59f - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h28c95c685643affe
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/alloc/src/boxed.rs:2084:9
  12:     0x73b8a977b59f - std::panicking::rust_panic_with_hook::h4bf66cb658082ab2
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/std/src/panicking.rs:808:13
  13:     0x73b8a5c30361 - std[a568119b01f6acf9]::panicking::begin_panic::<rustc_errors[3a77a9bae9c6f06]::ExplicitBug>::{closure#0}
  14:     0x73b8a5c23166 - std[a568119b01f6acf9]::sys::backtrace::__rust_end_short_backtrace::<std[a568119b01f6acf9]::panicking::begin_panic<rustc_errors[3a77a9bae9c6f06]::ExplicitBug>::{closure#0}, !>
  15:     0x73b8a5c23116 - std[a568119b01f6acf9]::panicking::begin_panic::<rustc_errors[3a77a9bae9c6f06]::ExplicitBug>
  16:     0x73b8a5c397e1 - <rustc_errors[3a77a9bae9c6f06]::diagnostic::BugAbort as rustc_errors[3a77a9bae9c6f06]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  17:     0x73b8a6346c45 - <rustc_errors[3a77a9bae9c6f06]::DiagCtxtHandle>::span_bug::<rustc_span[38ccacee260ae995]::span_encoding::Span, &str>
  18:     0x73b8a63cea53 - rustc_mir_transform[c43e2c3dc4f9025]::coverage::query::coverage_attr_on
  19:     0x73b8a6611be7 - rustc_query_impl[3b609057f07f1dcd]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3b609057f07f1dcd]::query_impl::coverage_attr_on::dynamic_query::{closure#2}::{closure#0}, rustc_middle[755ee31b8896a314]::query::erase::Erased<[u8; 1usize]>>
  20:     0x73b8a77014a4 - rustc_query_system[f2631fe58e40596f]::query::plumbing::try_execute_query::<rustc_query_impl[3b609057f07f1dcd]::DynamicConfig<rustc_query_system[f2631fe58e40596f]::query::caches::VecCache<rustc_span[38ccacee260ae995]::def_id::LocalDefId, rustc_middle[755ee31b8896a314]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[3b609057f07f1dcd]::plumbing::QueryCtxt, false>
  21:     0x73b8a6616ec1 - rustc_query_impl[3b609057f07f1dcd]::query_impl::coverage_attr_on::get_query_non_incr::__rust_end_short_backtrace
  22:     0x73b8a635e95c - rustc_middle[755ee31b8896a314]::query::plumbing::query_get_at::<rustc_query_system[f2631fe58e40596f]::query::caches::VecCache<rustc_span[38ccacee260ae995]::def_id::LocalDefId, rustc_middle[755ee31b8896a314]::query::erase::Erased<[u8; 1usize]>>>
  23:     0x73b8a63ce902 - rustc_mir_transform[c43e2c3dc4f9025]::coverage::query::is_eligible_for_coverage
  24:     0x73b8a77190a7 - <rustc_mir_build[896911fd54276e87]::build::Builder>::new
  25:     0x73b8a770ce7b - rustc_mir_build[896911fd54276e87]::build::mir_build
  26:     0x73b8a770bc92 - rustc_query_impl[3b609057f07f1dcd]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3b609057f07f1dcd]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[755ee31b8896a314]::query::erase::Erased<[u8; 8usize]>>
  27:     0x73b8a74e5773 - rustc_query_system[f2631fe58e40596f]::query::plumbing::try_execute_query::<rustc_query_impl[3b609057f07f1dcd]::DynamicConfig<rustc_query_system[f2631fe58e40596f]::query::caches::VecCache<rustc_span[38ccacee260ae995]::def_id::LocalDefId, rustc_middle[755ee31b8896a314]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[3b609057f07f1dcd]::plumbing::QueryCtxt, false>
  28:     0x73b8a74e528d - rustc_query_impl[3b609057f07f1dcd]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
  29:     0x73b8a7675ebe - rustc_mir_build[896911fd54276e87]::check_unsafety::check_unsafety
  30:     0x73b8a7675c5d - rustc_query_impl[3b609057f07f1dcd]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3b609057f07f1dcd]::query_impl::check_unsafety::dynamic_query::{closure#2}::{closure#0}, rustc_middle[755ee31b8896a314]::query::erase::Erased<[u8; 0usize]>>
  31:     0x73b8a7674e17 - rustc_query_system[f2631fe58e40596f]::query::plumbing::try_execute_query::<rustc_query_impl[3b609057f07f1dcd]::DynamicConfig<rustc_query_system[f2631fe58e40596f]::query::caches::VecCache<rustc_span[38ccacee260ae995]::def_id::LocalDefId, rustc_middle[755ee31b8896a314]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[3b609057f07f1dcd]::plumbing::QueryCtxt, false>
  32:     0x73b8a7674a5b - rustc_query_impl[3b609057f07f1dcd]::query_impl::check_unsafety::get_query_non_incr::__rust_end_short_backtrace
  33:     0x73b8a76799b8 - rustc_interface[a03dee3aea9b1fd5]::passes::analysis
  34:     0x73b8a7678b07 - rustc_query_impl[3b609057f07f1dcd]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3b609057f07f1dcd]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[755ee31b8896a314]::query::erase::Erased<[u8; 1usize]>>
  35:     0x73b8a80f1965 - rustc_query_system[f2631fe58e40596f]::query::plumbing::try_execute_query::<rustc_query_impl[3b609057f07f1dcd]::DynamicConfig<rustc_query_system[f2631fe58e40596f]::query::caches::SingleCache<rustc_middle[755ee31b8896a314]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[3b609057f07f1dcd]::plumbing::QueryCtxt, false>
  36:     0x73b8a80f16cf - rustc_query_impl[3b609057f07f1dcd]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  37:     0x73b8a7fc1285 - rustc_interface[a03dee3aea9b1fd5]::interface::run_compiler::<core[da8eb5c0cc453d3]::result::Result<(), rustc_span[38ccacee260ae995]::ErrorGuaranteed>, rustc_driver_impl[8e1afaf50ebeb9ae]::run_compiler::{closure#0}>::{closure#1}
  38:     0x73b8a7f97b49 - std[a568119b01f6acf9]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[a03dee3aea9b1fd5]::util::run_in_thread_with_globals<rustc_interface[a03dee3aea9b1fd5]::util::run_in_thread_pool_with_globals<rustc_interface[a03dee3aea9b1fd5]::interface::run_compiler<core[da8eb5c0cc453d3]::result::Result<(), rustc_span[38ccacee260ae995]::ErrorGuaranteed>, rustc_driver_impl[8e1afaf50ebeb9ae]::run_compiler::{closure#0}>::{closure#1}, core[da8eb5c0cc453d3]::result::Result<(), rustc_span[38ccacee260ae995]::ErrorGuaranteed>>::{closure#0}, core[da8eb5c0cc453d3]::result::Result<(), rustc_span[38ccacee260ae995]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[da8eb5c0cc453d3]::result::Result<(), rustc_span[38ccacee260ae995]::ErrorGuaranteed>>
  39:     0x73b8a7f978fa - <<std[a568119b01f6acf9]::thread::Builder>::spawn_unchecked_<rustc_interface[a03dee3aea9b1fd5]::util::run_in_thread_with_globals<rustc_interface[a03dee3aea9b1fd5]::util::run_in_thread_pool_with_globals<rustc_interface[a03dee3aea9b1fd5]::interface::run_compiler<core[da8eb5c0cc453d3]::result::Result<(), rustc_span[38ccacee260ae995]::ErrorGuaranteed>, rustc_driver_impl[8e1afaf50ebeb9ae]::run_compiler::{closure#0}>::{closure#1}, core[da8eb5c0cc453d3]::result::Result<(), rustc_span[38ccacee260ae995]::ErrorGuaranteed>>::{closure#0}, core[da8eb5c0cc453d3]::result::Result<(), rustc_span[38ccacee260ae995]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[da8eb5c0cc453d3]::result::Result<(), rustc_span[38ccacee260ae995]::ErrorGuaranteed>>::{closure#2} as core[da8eb5c0cc453d3]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  40:     0x73b8a97855fb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hcba9444f62f4d2cf
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/alloc/src/boxed.rs:2070:9
  41:     0x73b8a97855fb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h370ba06625738899
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/alloc/src/boxed.rs:2070:9
  42:     0x73b8a97855fb - std::sys::pal::unix::thread::Thread::new::thread_start::he74bac229ff12ca4
                               at /rustc/fcc325f1bc477975e2ce5ba534fe4c77ff8a8536/library/std/src/sys/pal/unix/thread.rs:108:17
  43:     0x73b8a26a6ded - <unknown>
  44:     0x73b8a272a0dc - <unknown>
  45:                0x0 - <unknown>

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: please make sure that you have updated to the latest nightly

note: rustc 1.81.0-nightly (fcc325f1b 2024-07-17) running on x86_64-unknown-linux-gnu

note: compiler flags: -C instrument-coverage -Z dump-mir-dir=dir

query stack during panic:
#0 [coverage_attr_on] checking for `#[coverage(..)]` on `main`
#1 [mir_built] building MIR for `main`
end of query stack
error: aborting due to 3 previous errors

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

@rustbot label +F-coverage_attribute

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-code-coverageArea: Source-based code coverage (-Cinstrument-coverage)C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions