Skip to content

ICE: builtin attribute "should_panic" not handled by CheckAttrVisitor #128622

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

struct S {
    #[should_panic::skip]
    field: u8,
}

original:

// Non-builtin attributes do not mess with field visibility resolution (issue #67006).

mod internal {
    struct S {
        #[rustfmt::skip]
        pub(in crate::internal) field: u32 // OK
    }

    struct Z(
        #[rustfmt::skip]
        pub(in crate::internal) u8 // OK
    );
}

struct S {
    #[should_panic::skip]
    pub(in nonexistent) field: u8 //~ ERROR failed to resolve
}

struct TokenStream(
    #[rustfmt::skip]
    pub(in nonexistent) u8 //~ ERROR failed to resolve
);

fn main() {}

Version information

rustc 1.82.0-nightly (64ebd39da 2024-08-03)
binary: rustc
commit-hash: 64ebd39da5ec28caa3bd7cbb3f22f5949432fe2b
commit-date: 2024-08-03
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0433]: failed to resolve: use of undeclared crate or module `should_panic`
 --> /tmp/icemaker_global_tempdir.YjHCgx05egvK/rustc_testrunner_tmpdir_reporting.sPNqKpdsgpau/mvce.rs:2:7
  |
2 |     #[should_panic::skip]
  |       ^^^^^^^^^^^^ use of undeclared crate or module `should_panic`

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.YjHCgx05egvK/rustc_testrunner_tmpdir_reporting.sPNqKpdsgpau/mvce.rs:4:2
  |
4 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.YjHCgx05egvK/rustc_testrunner_tmpdir_reporting.sPNqKpdsgpau/mvce.rs`

error: internal compiler error: compiler/rustc_passes/src/check_attr.rs:285:33: builtin attribute "should_panic" not handled by `CheckAttrVisitor`
 --> /tmp/icemaker_global_tempdir.YjHCgx05egvK/rustc_testrunner_tmpdir_reporting.sPNqKpdsgpau/mvce.rs:2:5
  |
2 |     #[should_panic::skip]
  |     ^^^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at compiler/rustc_passes/src/check_attr.rs:285:33:
Box<dyn Any>
stack backtrace:
   0:     0x73cd3257515d - std::backtrace_rs::backtrace::libunwind::trace::h470c7ae87ba4025c
                               at /rustc/64ebd39da5ec28caa3bd7cbb3f22f5949432fe2b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x73cd3257515d - std::backtrace_rs::backtrace::trace_unsynchronized::h59a012957645db86
                               at /rustc/64ebd39da5ec28caa3bd7cbb3f22f5949432fe2b/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x73cd3257515d - std::sys::backtrace::_print_fmt::he6eec48dee0520cd
                               at /rustc/64ebd39da5ec28caa3bd7cbb3f22f5949432fe2b/library/std/src/sys/backtrace.rs:66:9
   3:     0x73cd3257515d - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hfdd25df09ce1fcfa
                               at /rustc/64ebd39da5ec28caa3bd7cbb3f22f5949432fe2b/library/std/src/sys/backtrace.rs:39:26
   4:     0x73cd325c569b - core::fmt::rt::Argument::fmt::hb463cdd1073c5435
                               at /rustc/64ebd39da5ec28caa3bd7cbb3f22f5949432fe2b/library/core/src/fmt/rt.rs:173:76
   5:     0x73cd325c569b - core::fmt::write::hd7c3b9720108f6ed
                               at /rustc/64ebd39da5ec28caa3bd7cbb3f22f5949432fe2b/library/core/src/fmt/mod.rs:1178:21
   6:     0x73cd32568ec3 - std::io::Write::write_fmt::ha2df104fcce421c5
                               at /rustc/64ebd39da5ec28caa3bd7cbb3f22f5949432fe2b/library/std/src/io/mod.rs:1823:15
   7:     0x73cd32577952 - std::sys::backtrace::BacktraceLock::print::hf06cfc93c67871f0
                               at /rustc/64ebd39da5ec28caa3bd7cbb3f22f5949432fe2b/library/std/src/sys/backtrace.rs:42:9
   8:     0x73cd32577952 - std::panicking::default_hook::{{closure}}::hbb4ed713e2c9c643
                               at /rustc/64ebd39da5ec28caa3bd7cbb3f22f5949432fe2b/library/std/src/panicking.rs:266:22
   9:     0x73cd325775be - std::panicking::default_hook::h7690590dddb77129
                               at /rustc/64ebd39da5ec28caa3bd7cbb3f22f5949432fe2b/library/std/src/panicking.rs:293:9
  10:     0x73cd2eaa6d47 - std[5d818de65be8229c]::panicking::update_hook::<alloc[9a5ee3285ce50e9f]::boxed::Box<rustc_driver_impl[a2f6f36da10355a2]::install_ice_hook::{closure#0}>>::{closure#0}
  11:     0x73cd32578342 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h79d7cc46a296b25c
                               at /rustc/64ebd39da5ec28caa3bd7cbb3f22f5949432fe2b/library/alloc/src/boxed.rs:2164:9
  12:     0x73cd32578342 - std::panicking::rust_panic_with_hook::hbd0f660a3f2612ad
                               at /rustc/64ebd39da5ec28caa3bd7cbb3f22f5949432fe2b/library/std/src/panicking.rs:805:13
  13:     0x73cd2eae2211 - std[5d818de65be8229c]::panicking::begin_panic::<rustc_errors[30d9fa35dd7a2581]::ExplicitBug>::{closure#0}
  14:     0x73cd2ead4f26 - std[5d818de65be8229c]::sys::backtrace::__rust_end_short_backtrace::<std[5d818de65be8229c]::panicking::begin_panic<rustc_errors[30d9fa35dd7a2581]::ExplicitBug>::{closure#0}, !>
  15:     0x73cd2ead0006 - std[5d818de65be8229c]::panicking::begin_panic::<rustc_errors[30d9fa35dd7a2581]::ExplicitBug>
  16:     0x73cd2eaeb481 - <rustc_errors[30d9fa35dd7a2581]::diagnostic::BugAbort as rustc_errors[30d9fa35dd7a2581]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  17:     0x73cd2f335e7d - <rustc_errors[30d9fa35dd7a2581]::DiagCtxtHandle>::span_bug::<rustc_span[e78ddc703a44fb87]::span_encoding::Span, alloc[9a5ee3285ce50e9f]::string::String>
  18:     0x73cd2f352818 - rustc_middle[60b1eb66b763f760]::util::bug::opt_span_bug_fmt::<rustc_span[e78ddc703a44fb87]::span_encoding::Span>::{closure#0}
  19:     0x73cd2f35284a - rustc_middle[60b1eb66b763f760]::ty::context::tls::with_opt::<rustc_middle[60b1eb66b763f760]::util::bug::opt_span_bug_fmt<rustc_span[e78ddc703a44fb87]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  20:     0x73cd2f34598b - rustc_middle[60b1eb66b763f760]::ty::context::tls::with_context_opt::<rustc_middle[60b1eb66b763f760]::ty::context::tls::with_opt<rustc_middle[60b1eb66b763f760]::util::bug::opt_span_bug_fmt<rustc_span[e78ddc703a44fb87]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  21:     0x73cd2f343b37 - rustc_middle[60b1eb66b763f760]::util::bug::span_bug_fmt::<rustc_span[e78ddc703a44fb87]::span_encoding::Span>
  22:     0x73cd302219d7 - <rustc_passes[82698ad2f6a923fe]::check_attr::CheckAttrVisitor>::check_attributes
  23:     0x73cd3021d944 - <rustc_passes[82698ad2f6a923fe]::check_attr::CheckAttrVisitor as rustc_hir[ea3fcf664761130]::intravisit::Visitor>::visit_item
  24:     0x73cd3021cdc0 - rustc_passes[82698ad2f6a923fe]::check_attr::check_mod_attrs
  25:     0x73cd3021cd3b - rustc_query_impl[952a2029dfc6d38d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[952a2029dfc6d38d]::query_impl::check_mod_attrs::dynamic_query::{closure#2}::{closure#0}, rustc_middle[60b1eb66b763f760]::query::erase::Erased<[u8; 0usize]>>
  26:     0x73cd30c13176 - rustc_query_system[def1941f6afd59f1]::query::plumbing::try_execute_query::<rustc_query_impl[952a2029dfc6d38d]::DynamicConfig<rustc_query_system[def1941f6afd59f1]::query::caches::DefaultCache<rustc_span[e78ddc703a44fb87]::def_id::LocalModDefId, rustc_middle[60b1eb66b763f760]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[952a2029dfc6d38d]::plumbing::QueryCtxt, false>
  27:     0x73cd30c12e99 - rustc_query_impl[952a2029dfc6d38d]::query_impl::check_mod_attrs::get_query_non_incr::__rust_end_short_backtrace
  28:     0x73cd30c12931 - <rustc_middle[60b1eb66b763f760]::hir::map::Map>::par_for_each_module::<rustc_interface[a7671a33eb98c4b3]::passes::run_required_analyses::{closure#0}::{closure#0}::{closure#1}::{closure#0}>::{closure#0}
  29:     0x73cd3059aefc - rustc_interface[a7671a33eb98c4b3]::passes::analysis
  30:     0x73cd3059abdb - rustc_query_impl[952a2029dfc6d38d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[952a2029dfc6d38d]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[60b1eb66b763f760]::query::erase::Erased<[u8; 1usize]>>
  31:     0x73cd30f7ac6e - rustc_query_system[def1941f6afd59f1]::query::plumbing::try_execute_query::<rustc_query_impl[952a2029dfc6d38d]::DynamicConfig<rustc_query_system[def1941f6afd59f1]::query::caches::SingleCache<rustc_middle[60b1eb66b763f760]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[952a2029dfc6d38d]::plumbing::QueryCtxt, false>
  32:     0x73cd30f7a9cf - rustc_query_impl[952a2029dfc6d38d]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  33:     0x73cd30e89be3 - rustc_interface[a7671a33eb98c4b3]::interface::run_compiler::<core[dc2153a232c405cb]::result::Result<(), rustc_span[e78ddc703a44fb87]::ErrorGuaranteed>, rustc_driver_impl[a2f6f36da10355a2]::run_compiler::{closure#0}>::{closure#1}
  34:     0x73cd30e27889 - std[5d818de65be8229c]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[a7671a33eb98c4b3]::util::run_in_thread_with_globals<rustc_interface[a7671a33eb98c4b3]::util::run_in_thread_pool_with_globals<rustc_interface[a7671a33eb98c4b3]::interface::run_compiler<core[dc2153a232c405cb]::result::Result<(), rustc_span[e78ddc703a44fb87]::ErrorGuaranteed>, rustc_driver_impl[a2f6f36da10355a2]::run_compiler::{closure#0}>::{closure#1}, core[dc2153a232c405cb]::result::Result<(), rustc_span[e78ddc703a44fb87]::ErrorGuaranteed>>::{closure#0}, core[dc2153a232c405cb]::result::Result<(), rustc_span[e78ddc703a44fb87]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dc2153a232c405cb]::result::Result<(), rustc_span[e78ddc703a44fb87]::ErrorGuaranteed>>
  35:     0x73cd30e27632 - <<std[5d818de65be8229c]::thread::Builder>::spawn_unchecked_<rustc_interface[a7671a33eb98c4b3]::util::run_in_thread_with_globals<rustc_interface[a7671a33eb98c4b3]::util::run_in_thread_pool_with_globals<rustc_interface[a7671a33eb98c4b3]::interface::run_compiler<core[dc2153a232c405cb]::result::Result<(), rustc_span[e78ddc703a44fb87]::ErrorGuaranteed>, rustc_driver_impl[a2f6f36da10355a2]::run_compiler::{closure#0}>::{closure#1}, core[dc2153a232c405cb]::result::Result<(), rustc_span[e78ddc703a44fb87]::ErrorGuaranteed>>::{closure#0}, core[dc2153a232c405cb]::result::Result<(), rustc_span[e78ddc703a44fb87]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[dc2153a232c405cb]::result::Result<(), rustc_span[e78ddc703a44fb87]::ErrorGuaranteed>>::{closure#1} as core[dc2153a232c405cb]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  36:     0x73cd3258205b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4329d9c9b4cecba8
                               at /rustc/64ebd39da5ec28caa3bd7cbb3f22f5949432fe2b/library/alloc/src/boxed.rs:2150:9
  37:     0x73cd3258205b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2a2d295295b3a578
                               at /rustc/64ebd39da5ec28caa3bd7cbb3f22f5949432fe2b/library/alloc/src/boxed.rs:2150:9
  38:     0x73cd3258205b - std::sys::pal::unix::thread::Thread::new::thread_start::hc3031069669580a0
                               at /rustc/64ebd39da5ec28caa3bd7cbb3f22f5949432fe2b/library/std/src/sys/pal/unix/thread.rs:105:17
  39:     0x73cd2b4a6ded - <unknown>
  40:     0x73cd2b52a0dc - <unknown>
  41:                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.82.0-nightly (64ebd39da 2024-08-03) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_mod_attrs] checking attributes in top-level module
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0433, E0601.
For more information about an error, try `rustc --explain E0433`.

Metadata

Metadata

Assignees

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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