Skip to content

ICE: can't get the span of an arbitrary parsed attribute: Parsed(Cold  #143094

@matthiaskrgr

Description

@matthiaskrgr

snippet:

fn main() {
    #[cold]
    5
}

Version information

rustc 1.90.0-nightly (d51b6f971 2025-06-27)
binary: rustc
commit-hash: d51b6f97122671c5de27cfc08cded235357e0d97
commit-date: 2025-06-27
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.7

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

Program output

warning: attribute should be applied to a function definition
 --> /tmp/icemaker_global_tempdir.E7eKMRzU4Hi9/rustc_testrunner_tmpdir_reporting.FLqPWoufnRyw/mvce.rs:2:5
  |
2 |     #[cold]
  |     ^^^^^^^
3 |     5
  |     - not a function definition
  |
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
  = note: `#[warn(unused_attributes)]` on by default


thread 'rustc' panicked at /rustc-dev/d51b6f97122671c5de27cfc08cded235357e0d97/compiler/rustc_hir/src/hir.rs:1306:18:
can't get the span of an arbitrary parsed attribute: Parsed(Cold(/tmp/icemaker_global_tempdir.E7eKMRzU4Hi9/rustc_testrunner_tmpdir_reporting.FLqPWoufnRyw/mvce.rs:2:5: 2:12 (#0)))
stack backtrace:
   0:     0x77caa6f06d93 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h172786a053088a80
   1:     0x77caa7602c3f - core::fmt::write::h7e8ea7c2bf766230
   2:     0x77caa6efc9c3 - std::io::Write::write_fmt::h8aef4545d51610bc
   3:     0x77caa6f06bf2 - std::sys::backtrace::BacktraceLock::print::hcaf1ccd6afbf2e1d
   4:     0x77caa6f0a6ea - std::panicking::default_hook::{{closure}}::h4ce4779ce8a3e31a
   5:     0x77caa6f0a26f - std::panicking::default_hook::hafe5dcd1475f74c9
   6:     0x77caa5fe51f3 - std[ac406385963d06ba]::panicking::update_hook::<alloc[762d5bb616333adc]::boxed::Box<rustc_driver_impl[2409353bb348a1fe]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x77caa6f0af3b - std::panicking::rust_panic_with_hook::h2b643051b0ee54bd
   8:     0x77caa6f0ac3a - std::panicking::begin_panic_handler::{{closure}}::h2f43df37d8ec1fc9
   9:     0x77caa6f07269 - std::sys::backtrace::__rust_end_short_backtrace::hdd0bf39addaa3bbd
  10:     0x77caa6f0a91d - __rustc[ec5114c7948ebf25]::rust_begin_unwind
  11:     0x77caa36999c0 - core::panicking::panic_fmt::h7cdf2f61e2255620
  12:     0x77caa91f14cd - <rustc_hir_typeck[d1b4da71dd966fd5]::fn_ctxt::FnCtxt>::precedence::{closure#0}.llvm.1929938728858289850.cold
  13:     0x77caa8543865 - <rustc_hir[3d24d229c323ac03]::hir::Expr>::precedence
  14:     0x77caa62eb7a9 - <rustc_hir_typeck[d1b4da71dd966fd5]::fn_ctxt::FnCtxt>::suggest_deref_ref_or_into
  15:     0x77caa62a6b06 - <rustc_hir_typeck[d1b4da71dd966fd5]::fn_ctxt::FnCtxt>::emit_type_mismatch_suggestions
  16:     0x77caa62ac0b0 - <rustc_hir_typeck[d1b4da71dd966fd5]::fn_ctxt::FnCtxt>::emit_coerce_suggestions
  17:     0x77caa808487d - <rustc_hir_typeck[d1b4da71dd966fd5]::fn_ctxt::FnCtxt>::check_expr_block
  18:     0x77caa80b2ee0 - <rustc_hir_typeck[d1b4da71dd966fd5]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  19:     0x77caa808c197 - rustc_hir_typeck[d1b4da71dd966fd5]::check::check_fn
  20:     0x77caa87f6e8f - rustc_hir_typeck[d1b4da71dd966fd5]::typeck_with_inspect::{closure#0}
  21:     0x77caa87e39b0 - rustc_query_impl[cdda87a48a29190a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[cdda87a48a29190a]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[85d0084cd8285b0d]::query::erase::Erased<[u8; 8usize]>>
  22:     0x77caa786ee6e - rustc_query_system[c91322fa492962f5]::query::plumbing::try_execute_query::<rustc_query_impl[cdda87a48a29190a]::DynamicConfig<rustc_data_structures[deb77fa27d028d21]::vec_cache::VecCache<rustc_span[d438a3ce0d69ef07]::def_id::LocalDefId, rustc_middle[85d0084cd8285b0d]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[c91322fa492962f5]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[cdda87a48a29190a]::plumbing::QueryCtxt, false>
  23:     0x77caa786e809 - rustc_query_impl[cdda87a48a29190a]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  24:     0x77caa78668ad - rustc_hir_analysis[a2924986fcd3aa06]::check_crate
  25:     0x77caa786a927 - rustc_interface[e31b222a2d1d97f1]::passes::analysis
  26:     0x77caa786a54b - rustc_query_impl[cdda87a48a29190a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[cdda87a48a29190a]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[85d0084cd8285b0d]::query::erase::Erased<[u8; 0usize]>>
  27:     0x77caa868ba7c - rustc_query_system[c91322fa492962f5]::query::plumbing::try_execute_query::<rustc_query_impl[cdda87a48a29190a]::DynamicConfig<rustc_query_system[c91322fa492962f5]::query::caches::SingleCache<rustc_middle[85d0084cd8285b0d]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[cdda87a48a29190a]::plumbing::QueryCtxt, false>
  28:     0x77caa868b752 - rustc_query_impl[cdda87a48a29190a]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  29:     0x77caa8855dd6 - rustc_interface[e31b222a2d1d97f1]::passes::create_and_enter_global_ctxt::<core[1aae05a66286d11a]::option::Option<rustc_interface[e31b222a2d1d97f1]::queries::Linker>, rustc_driver_impl[2409353bb348a1fe]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  30:     0x77caa88474af - rustc_interface[e31b222a2d1d97f1]::interface::run_compiler::<(), rustc_driver_impl[2409353bb348a1fe]::run_compiler::{closure#0}>::{closure#1}
  31:     0x77caa88714f8 - std[ac406385963d06ba]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[e31b222a2d1d97f1]::util::run_in_thread_with_globals<rustc_interface[e31b222a2d1d97f1]::util::run_in_thread_pool_with_globals<rustc_interface[e31b222a2d1d97f1]::interface::run_compiler<(), rustc_driver_impl[2409353bb348a1fe]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  32:     0x77caa88711d6 - <<std[ac406385963d06ba]::thread::Builder>::spawn_unchecked_<rustc_interface[e31b222a2d1d97f1]::util::run_in_thread_with_globals<rustc_interface[e31b222a2d1d97f1]::util::run_in_thread_pool_with_globals<rustc_interface[e31b222a2d1d97f1]::interface::run_compiler<(), rustc_driver_impl[2409353bb348a1fe]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[1aae05a66286d11a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x77caa886f7fd - std::sys::pal::unix::thread::Thread::new::thread_start::hf9e92a00dfd64138
  34:     0x77caa22a57eb - <unknown>
  35:     0x77caa232918c - <unknown>
  36:                0x0 - <unknown>

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

note: rustc 1.90.0-nightly (d51b6f971 2025-06-27) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
warning: 1 warning emitted

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: coercion error but no error emitted
 --> /tmp/icemaker_global_tempdir.E7eKMRzU4Hi9/rustc_testrunner_tmpdir_reporting.FLqPWoufnRyw/mvce.rs:3:5
  |
3 |     5
  |     ^
  |
note: delayed at compiler/rustc_hir_typeck/src/coercion.rs:1642:31
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, &str>
         4: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
         5: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
         6: rustc_hir_typeck::check::check_fn
         7: rustc_hir_typeck::typeck_with_inspect::{closure#0}
         8: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
         9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        10: rustc_query_impl::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
        11: rustc_hir_analysis::check_crate
        12: rustc_interface::passes::analysis
        13: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
        14: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        15: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
        16: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
        17: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        18: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
        19: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        20: std::sys::pal::unix::thread::Thread::new::thread_start
        21: <unknown>
        22: <unknown>
 --> /tmp/icemaker_global_tempdir.E7eKMRzU4Hi9/rustc_testrunner_tmpdir_reporting.FLqPWoufnRyw/mvce.rs:3:5
  |
3 |     5
  |     ^

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.90.0-nightly (d51b6f971 2025-06-27) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

Metadata

Metadata

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️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