Skip to content

[ICE]: can't get the span of an arbitrary parsed attribute #155804

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

fn test()
where
    #[doc(alias = ":(")]
    ():,
{
}

original:

#![feature(where_clause_attrs)]
fn test()
where
    #[doc(alias = ":(")]
    (): {}

Version information

rustc 1.97.0-nightly (68ffae46b 2026-04-25)
binary: rustc
commit-hash: 68ffae46b581747074413e4242ab0c6ecc4db4a9
commit-date: 2026-04-25
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.2

Possibly related line of code:

match &self {
Attribute::Unparsed(u) => u.span,
// FIXME: should not be needed anymore when all attrs are parsed
Attribute::Parsed(AttributeKind::DocComment { span, .. }) => *span,
Attribute::Parsed(AttributeKind::Deprecated { span, .. }) => *span,
Attribute::Parsed(AttributeKind::CfgTrace(cfgs)) => cfgs[0].1,
a => panic!("can't get the span of an arbitrary parsed attribute: {a:?}"),
}
}
#[inline]
fn is_word(&self) -> bool {
match &self {

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

Program output

error[E0658]: attributes in `where` clause are unstable
 --> /tmp/icemaker_global_tempdir.ayTSYC5T6eHJ/rustc_testrunner_tmpdir_reporting.vpANhFq5WUiX/mvce.rs:3:5
  |
3 |     #[doc(alias = ":(")]
  |     ^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #115590 <https://github.com/rust-lang/rust/issues/115590> for more information
  = help: add `#![feature(where_clause_attrs)]` to the crate attributes to enable
  = note: this compiler was built on 2026-04-25; consider upgrading it if it is out of date


thread 'rustc' (366159) panicked at /rustc-dev/68ffae46b581747074413e4242ab0c6ecc4db4a9/compiler/rustc_hir/src/hir.rs:1390:18:
can't get the span of an arbitrary parsed attribute: Parsed(Doc(DocAttribute { aliases: {":(": /tmp/icemaker_global_tempdir.ayTSYC5T6eHJ/rustc_testrunner_tmpdir_reporting.vpANhFq5WUiX/mvce.rs:3:19: 3:23 (#0)}, hidden: None, inline: [], cfg: [], auto_cfg: [], auto_cfg_change: [], fake_variadic: None, keyword: None, attribute: None, masked: None, notable_trait: None, search_unbox: None, html_favicon_url: None, html_logo_url: None, html_playground_url: None, html_root_url: None, html_no_source: None, issue_tracker_base_url: None, rust_logo: None, test_attrs: [], no_crate_inject: None }))
stack backtrace:
   0:     0x7f2cbdf62edb - <<std[74a5d452ef4468e2]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[af918ca625322054]::fmt::Display>::fmt
   1:     0x7f2cbe62d948 - core[af918ca625322054]::fmt::write
   2:     0x7f2cbdf79b16 - <std[74a5d452ef4468e2]::sys::stdio::unix::Stderr as std[74a5d452ef4468e2]::io::Write>::write_fmt
   3:     0x7f2cbdf39158 - std[74a5d452ef4468e2]::panicking::default_hook::{closure#0}
   4:     0x7f2cbdf56543 - std[74a5d452ef4468e2]::panicking::default_hook
   5:     0x7f2cbcf2cb9c - std[74a5d452ef4468e2]::panicking::update_hook::<alloc[3c1e8b5c2310114c]::boxed::Box<rustc_driver_impl[65db170643483585]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f2cbdf56822 - std[74a5d452ef4468e2]::panicking::panic_with_hook
   7:     0x7f2cbdf39218 - std[74a5d452ef4468e2]::panicking::panic_handler::{closure#0}
   8:     0x7f2cbdf2d779 - std[74a5d452ef4468e2]::sys::backtrace::__rust_end_short_backtrace::<std[74a5d452ef4468e2]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f2cbdf3ac7d - __rustc[4d529550cd7027cf]::rust_begin_unwind
  10:     0x7f2cbab439fc - core[af918ca625322054]::panicking::panic_fmt
  11:     0x7f2cbca1d04d - <core[af918ca625322054]::iter::adapters::map::Map<core[af918ca625322054]::iter::adapters::filter::Filter<core[af918ca625322054]::iter::adapters::chain::Chain<core[af918ca625322054]::slice::iter::Iter<rustc_hir[3704b234a2d4cda3]::hir::Attribute>, core[af918ca625322054]::slice::iter::Iter<rustc_hir[3704b234a2d4cda3]::hir::Attribute>>, <rustc_attr_parsing[ee812df563a5c05e]::interface::AttributeParser>::check_invalid_where_predicate_attrs<core[af918ca625322054]::iter::adapters::chain::Chain<core[af918ca625322054]::slice::iter::Iter<rustc_hir[3704b234a2d4cda3]::hir::Attribute>, core[af918ca625322054]::slice::iter::Iter<rustc_hir[3704b234a2d4cda3]::hir::Attribute>>>::{closure#0}>, <rustc_attr_parsing[ee812df563a5c05e]::interface::AttributeParser>::check_invalid_where_predicate_attrs<core[af918ca625322054]::iter::adapters::chain::Chain<core[af918ca625322054]::slice::iter::Iter<rustc_hir[3704b234a2d4cda3]::hir::Attribute>, core[af918ca625322054]::slice::iter::Iter<rustc_hir[3704b234a2d4cda3]::hir::Attribute>>>::{closure#1}> as core[af918ca625322054]::iter::traits::iterator::Iterator>::next
  12:     0x7f2cbecf13dc - <rustc_ast_lowering[65b0b6d9972c4088]::LoweringContext>::lower_attrs_vec
  13:     0x7f2cbecec1e3 - <rustc_ast_lowering[65b0b6d9972c4088]::LoweringContext>::lower_attrs_with_extra
  14:     0x7f2cbecc743e - <rustc_ast_lowering[65b0b6d9972c4088]::LoweringContext>::lower_where_predicate
  15:     0x7f2cbece4151 - <rustc_ast_lowering[65b0b6d9972c4088]::LoweringContext>::lower_item_kind
  16:     0x7f2cbecfe286 - <rustc_ast_lowering[65b0b6d9972c4088]::item::ItemLowerer>::lower_node
  17:     0x7f2cbecfc890 - rustc_ast_lowering[65b0b6d9972c4088]::lower_to_hir
  18:     0x7f2cbf76726c - rustc_query_impl[2514449be8add55a]::query_impl::hir_crate::invoke_provider_fn::__rust_begin_short_backtrace
  19:     0x7f2cbf764c19 - rustc_query_impl[2514449be8add55a]::execution::try_execute_query::<rustc_middle[11ba238a743b416b]::query::caches::SingleCache<rustc_middle[11ba238a743b416b]::query::erase::ErasedData<[u8; 8usize]>>, false>
  20:     0x7f2cbf51abbf - rustc_query_impl[2514449be8add55a]::query_impl::hir_crate::execute_query_non_incr::__rust_end_short_backtrace
  21:     0x7f2cbf51ac1c - rustc_middle[11ba238a743b416b]::hir::map::hir_crate_items
  22:     0x7f2cbf767fa9 - rustc_query_impl[2514449be8add55a]::query_impl::hir_crate_items::invoke_provider_fn::__rust_begin_short_backtrace
  23:     0x7f2cbf764c19 - rustc_query_impl[2514449be8add55a]::execution::try_execute_query::<rustc_middle[11ba238a743b416b]::query::caches::SingleCache<rustc_middle[11ba238a743b416b]::query::erase::ErasedData<[u8; 8usize]>>, false>
  24:     0x7f2cbf5076b9 - rustc_query_impl[2514449be8add55a]::query_impl::hir_crate_items::execute_query_non_incr::__rust_end_short_backtrace
  25:     0x7f2cbf50801e - rustc_interface[78b66ebcbd67330e]::passes::analysis
  26:     0x7f2cbf7637c9 - rustc_query_impl[2514449be8add55a]::execution::try_execute_query::<rustc_middle[11ba238a743b416b]::query::caches::SingleCache<rustc_middle[11ba238a743b416b]::query::erase::ErasedData<[u8; 0usize]>>, false>
  27:     0x7f2cbf763429 - rustc_query_impl[2514449be8add55a]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  28:     0x7f2cbf72e779 - rustc_interface[78b66ebcbd67330e]::interface::run_compiler::<(), rustc_driver_impl[65db170643483585]::run_compiler::{closure#0}>::{closure#1}
  29:     0x7f2cbf754584 - std[74a5d452ef4468e2]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[78b66ebcbd67330e]::util::run_in_thread_with_globals<rustc_interface[78b66ebcbd67330e]::util::run_in_thread_pool_with_globals<rustc_interface[78b66ebcbd67330e]::interface::run_compiler<(), rustc_driver_impl[65db170643483585]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  30:     0x7f2cbf754c6d - <std[74a5d452ef4468e2]::thread::lifecycle::spawn_unchecked<rustc_interface[78b66ebcbd67330e]::util::run_in_thread_with_globals<rustc_interface[78b66ebcbd67330e]::util::run_in_thread_pool_with_globals<rustc_interface[78b66ebcbd67330e]::interface::run_compiler<(), rustc_driver_impl[65db170643483585]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[af918ca625322054]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  31:     0x7f2cbf755aec - <std[74a5d452ef4468e2]::sys::thread::unix::Thread>::new::thread_start
  32:     0x7f2cb92a597a - <unknown>
  33:     0x7f2cb93292bc - <unknown>
  34:                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.97.0-nightly (68ffae46b 2026-04-25) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [hir_crate] getting the crate HIR
#1 [hir_crate_items] getting HIR crate items
#2 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 1 previous error

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

@rustbot label +F-where_clause_attrs

Metadata

Metadata

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)C-bugCategory: This is a bug.F-where_clause_attrs`#![feature(where_clause_attrs)]`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
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions