ICE when #[track_caller]
is applied to a static
item #105594
Closed
Description
Code
#[track_caller]
static _B: () = ();
fn main() {}
Error output
error[E0739]: attribute should be applied to a function definition
error: internal compiler error: compiler/rustc_hir_analysis/src/collect.rs:1183: unexpected sort of node in fn_sig()
: Item(...)
Full output with backtrace
error[E0739]: attribute should be applied to a function definition
--> a.rs:1:1
|
1 | #[track_caller]
| ^^^^^^^^^^^^^^^
2 | static _B: () = ();
| ------------------- not a function definition
error: internal compiler error: compiler/rustc_hir_analysis/src/collect.rs:1183:13: unexpected sort of node in fn_sig(): Item(Item { ident: _B#0, owner_id: OwnerId { def_id: DefId(0:3 ~ a[36ea]::_B) }, kind: Static(Ty { hir_id: HirId { owner: OwnerId { def_id: DefId(0:3 ~ a[36ea]::_B) }, local_id: 1 }, kind: Tup([]), span: a.rs:2:12: 2:14 (#0) }, Not, BodyId { hir_id: HirId { owner: OwnerId { def_id: DefId(0:3 ~ a[36ea]::_B) }, local_id: 2 } }), span: a.rs:2:1: 2:20 (#0), vis_span: a.rs:2:1: 2:1 (#0) })
thread 'rustc' panicked at 'Box<dyn Any>', /rustc/bdb07a8ec8e77aa10fb84fae1d4ff71c21180bb4/compiler/rustc_errors/src/lib.rs:1576:9
stack backtrace:
0: 0x120338776 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd6dea84f06cc919a
1: 0x10fd0b15a - core::fmt::write::h91ecc43dcb5a87d3
2: 0x12033452c - std::io::Write::write_fmt::hc922635edee92051
3: 0x12033855a - std::sys_common::backtrace::print::h86bd5791976d67a9
4: 0x12033a8b3 - std::panicking::default_hook::{{closure}}::h32c4d35e1d887df2
5: 0x12033a616 - std::panicking::default_hook::hcd90b2b89f8c0e15
6: 0x11e3d488d - rustc_driver[f5ca9ba73eed523d]::DEFAULT_HOOK::{closure#0}::{closure#0}
7: 0x12033ac47 - std::panicking::rust_panic_with_hook::h9198f3fe823c744c
8: 0x11ef12a67 - std[e9f68177e3155681]::panicking::begin_panic::<rustc_errors[6e8b1009bf902fa9]::ExplicitBug>::{closure#0}
9: 0x11ef0d8e9 - std[e9f68177e3155681]::sys_common::backtrace::__rust_end_short_backtrace::<std[e9f68177e3155681]::panicking::begin_panic<rustc_errors[6e8b1009bf902fa9]::ExplicitBug>::{closure#0}, !>
10: 0x122983839 - std[e9f68177e3155681]::panicking::begin_panic::<rustc_errors[6e8b1009bf902fa9]::ExplicitBug>
11: 0x11ef0d8d9 - std[e9f68177e3155681]::panic::panic_any::<rustc_errors[6e8b1009bf902fa9]::ExplicitBug>
12: 0x11ef03ecd - <rustc_errors[6e8b1009bf902fa9]::HandlerInner>::bug::<&alloc[5adf0dd6a3785d39]::string::String>
13: 0x11ef03927 - <rustc_errors[6e8b1009bf902fa9]::Handler>::bug::<&alloc[5adf0dd6a3785d39]::string::String>
14: 0x11eecb5d3 - rustc_middle[81f54e6dd5330834]::ty::context::tls::with_context_opt::<rustc_middle[81f54e6dd5330834]::ty::context::tls::with_opt<rustc_middle[81f54e6dd5330834]::util::bug::opt_span_bug_fmt<rustc_span[e3bcd7e2de09f7c3]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
15: 0x11eecb651 - rustc_middle[81f54e6dd5330834]::util::bug::opt_span_bug_fmt::<rustc_span[e3bcd7e2de09f7c3]::span_encoding::Span>
16: 0x12297ff0e - rustc_middle[81f54e6dd5330834]::util::bug::bug_fmt
17: 0x11e6650fe - rustc_hir_analysis[7e82910673f8c84]::collect::fn_sig
18: 0x11f79b86c - rustc_query_system[179a71b5a36883c6]::query::plumbing::try_execute_query::<rustc_query_impl[964bc029a4576ad4]::plumbing::QueryCtxt, rustc_query_system[179a71b5a36883c6]::query::caches::DefaultCache<rustc_span[e3bcd7e2de09f7c3]::def_id::DefId, rustc_middle[81f54e6dd5330834]::ty::sty::Binder<rustc_middle[81f54e6dd5330834]::ty::sty::FnSig>>>
19: 0x11f8bfe52 - rustc_query_system[179a71b5a36883c6]::query::plumbing::get_query::<rustc_query_impl[964bc029a4576ad4]::queries::fn_sig, rustc_query_impl[964bc029a4576ad4]::plumbing::QueryCtxt>
20: 0x11f956075 - <rustc_query_impl[964bc029a4576ad4]::Queries as rustc_middle[81f54e6dd5330834]::ty::query::QueryEngine>::fn_sig
21: 0x11e65f479 - rustc_hir_analysis[7e82910673f8c84]::collect::codegen_fn_attrs
22: 0x11f7227a9 - rustc_query_system[179a71b5a36883c6]::query::plumbing::try_execute_query::<rustc_query_impl[964bc029a4576ad4]::plumbing::QueryCtxt, rustc_query_system[179a71b5a36883c6]::query::caches::ArenaCache<rustc_span[e3bcd7e2de09f7c3]::def_id::DefId, rustc_middle[81f54e6dd5330834]::middle::codegen_fn_attrs::CodegenFnAttrs>>
23: 0x11f8af1ee - rustc_query_system[179a71b5a36883c6]::query::plumbing::get_query::<rustc_query_impl[964bc029a4576ad4]::queries::codegen_fn_attrs, rustc_query_impl[964bc029a4576ad4]::plumbing::QueryCtxt>
24: 0x11f0014ca - <rustc_middle[81f54e6dd5330834]::ty::context::TyCtxt>::is_thread_local_static
25: 0x11e7790db - rustc_hir_analysis[7e82910673f8c84]::check::wfcheck::check_item_type
26: 0x11e76adb5 - rustc_hir_analysis[7e82910673f8c84]::check::wfcheck::check_well_formed
27: 0x11f82ef0b - rustc_query_system[179a71b5a36883c6]::query::plumbing::try_execute_query::<rustc_query_impl[964bc029a4576ad4]::plumbing::QueryCtxt, rustc_query_system[179a71b5a36883c6]::query::caches::VecCache<rustc_hir[310573c35d422959]::hir_id::OwnerId, ()>>
28: 0x11f8b1161 - rustc_query_system[179a71b5a36883c6]::query::plumbing::get_query::<rustc_query_impl[964bc029a4576ad4]::queries::check_well_formed, rustc_query_impl[964bc029a4576ad4]::plumbing::QueryCtxt>
29: 0x11e763fab - rustc_data_structures[69a6efa400d2eccf]::sync::par_for_each_in::<&[rustc_hir[310573c35d422959]::hir::ItemId], <rustc_middle[81f54e6dd5330834]::hir::ModuleItems>::par_items<rustc_hir_analysis[7e82910673f8c84]::check::wfcheck::check_mod_type_wf::{closure#0}>::{closure#0}>
30: 0x11e77c016 - rustc_hir_analysis[7e82910673f8c84]::check::wfcheck::check_mod_type_wf
31: 0x11f84600b - rustc_query_system[179a71b5a36883c6]::query::plumbing::try_execute_query::<rustc_query_impl[964bc029a4576ad4]::plumbing::QueryCtxt, rustc_query_system[179a71b5a36883c6]::query::caches::VecCache<rustc_span[e3bcd7e2de09f7c3]::def_id::LocalDefId, ()>>
32: 0x11f8b1041 - rustc_query_system[179a71b5a36883c6]::query::plumbing::get_query::<rustc_query_impl[964bc029a4576ad4]::queries::check_mod_type_wf, rustc_query_impl[964bc029a4576ad4]::plumbing::QueryCtxt>
33: 0x11e7640ab - rustc_data_structures[69a6efa400d2eccf]::sync::par_for_each_in::<&[rustc_hir[310573c35d422959]::hir_id::OwnerId], <rustc_middle[81f54e6dd5330834]::hir::map::Map>::par_for_each_module<rustc_hir_analysis[7e82910673f8c84]::check_crate::{closure#5}::{closure#0}::{closure#0}>::{closure#0}>
34: 0x11e691a7a - <rustc_session[78db928f84e94300]::session::Session>::track_errors::<rustc_hir_analysis[7e82910673f8c84]::check_crate::{closure#5}, ()>
35: 0x11e6dc109 - rustc_hir_analysis[7e82910673f8c84]::check_crate
36: 0x11ebffcb0 - rustc_interface[9fb4355f0ea261b0]::passes::analysis
37: 0x11f7fd482 - rustc_query_system[179a71b5a36883c6]::query::plumbing::try_execute_query::<rustc_query_impl[964bc029a4576ad4]::plumbing::QueryCtxt, rustc_query_system[179a71b5a36883c6]::query::caches::DefaultCache<(), core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>>>
38: 0x11f8c0521 - rustc_query_system[179a71b5a36883c6]::query::plumbing::get_query::<rustc_query_impl[964bc029a4576ad4]::queries::analysis, rustc_query_impl[964bc029a4576ad4]::plumbing::QueryCtxt>
39: 0x11e36260a - <rustc_interface[9fb4355f0ea261b0]::passes::QueryContext>::enter::<rustc_driver[f5ca9ba73eed523d]::run_compiler::{closure#1}::{closure#2}::{closure#2}, core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>>
40: 0x11e3aa9cb - rustc_span[e3bcd7e2de09f7c3]::with_source_map::<core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>, rustc_interface[9fb4355f0ea261b0]::interface::run_compiler<core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>, rustc_driver[f5ca9ba73eed523d]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
41: 0x11e39c8ee - <scoped_tls[10e5aad72c190240]::ScopedKey<rustc_span[e3bcd7e2de09f7c3]::SessionGlobals>>::set::<rustc_interface[9fb4355f0ea261b0]::interface::run_compiler<core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>, rustc_driver[f5ca9ba73eed523d]::run_compiler::{closure#1}>::{closure#0}, core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>>
42: 0x11e36b3b7 - std[e9f68177e3155681]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[9fb4355f0ea261b0]::util::run_in_thread_pool_with_globals<rustc_interface[9fb4355f0ea261b0]::interface::run_compiler<core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>, rustc_driver[f5ca9ba73eed523d]::run_compiler::{closure#1}>::{closure#0}, core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>>
43: 0x11e34ddb9 - <<std[e9f68177e3155681]::thread::Builder>::spawn_unchecked_<rustc_interface[9fb4355f0ea261b0]::util::run_in_thread_pool_with_globals<rustc_interface[9fb4355f0ea261b0]::interface::run_compiler<core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>, rustc_driver[f5ca9ba73eed523d]::run_compiler::{closure#1}>::{closure#0}, core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d953718cd3bcc963]::result::Result<(), rustc_errors[6e8b1009bf902fa9]::ErrorGuaranteed>>::{closure#1} as core[d953718cd3bcc963]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
44: 0x1203403a7 - std::sys::unix::thread::Thread::new::thread_start::h6bf891e61773eb8a
45: 0x7ff80c3874e1 - __pthread_start
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.68.0-nightly (bdb07a8ec 2022-12-11) running on x86_64-apple-darwin
query stack during panic:
#0 [fn_sig] computing function signature of `_B`
#1 [codegen_fn_attrs] computing codegen attributes of `_B`
#2 [check_well_formed] checking that `_B` is well-formed
#3 [check_mod_type_wf] checking that types are well-formed in top-level module
#4 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0739`.
Regression
Regression in nightly-2021-11-29, perhaps from #91251
Commits in range
found 6 bors merge commits in the specified range
commit[0] 2021-11-27UTC: Auto merge of #91288 - matthiaskrgr:rollup-yp5h41r, r=matthiaskrgr
commit[1] 2021-11-27UTC: Auto merge of #91241 - dtolnay:firstchunk, r=oli-obk
commit[2] 2021-11-28UTC: Auto merge of #91301 - scottmcm:stabilize-nonzero-ipot, r=nagisa
commit[3] 2021-11-28UTC: Auto merge of #91311 - matthiaskrgr:rollup-ju9xizl, r=matthiaskrgr
commit[4] 2021-11-28UTC: Auto merge of #91230 - eggyal:fallible-type-fold, r=jackh726
commit[5] 2021-11-28UTC: Auto merge of #91320 - matthiaskrgr:rollup-r209seq, r=matthiaskrgr
Version
rustc 1.68.0-nightly (bdb07a8ec 2022-12-11)
binary: rustc
commit-hash: bdb07a8ec8e77aa10fb84fae1d4ff71c21180bb4
commit-date: 2022-12-11
host: x86_64-apple-darwin
release: 1.68.0-nightly
LLVM version: 15.0.6