Skip to content

[ICE]: can't get span of parsed attr #154801

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

fn main() {
    let _x = 30;
    #[cfg_attr(, (cc))]
    _x
}

original:

#[cold = true]
//~^ ERROR `#[debugger_visualizer]` attribute cannot be used on functions
fn main() {
        let _x = 30;
        #[cfg_attr(unix, rustc_dummy(cc))] _x
    }

Version information

rustc 1.96.0-nightly (2972b5e59 2026-04-03)
binary: rustc
commit-hash: 2972b5e59f1c5529b6ba770437812fd83ab4ebd4
commit-date: 2026-04-03
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.2

Possibly related line of code:

let span = match self {
Attribute::Unparsed(attr) => attr.span,
Attribute::Parsed(AttributeKind::Deprecated { span, .. }) => *span,
Attribute::Parsed(AttributeKind::LintAttributes(sub_attrs)) => {
return sub_attrs.iter().any(|attr| attr.attr_span.desugaring_kind().is_none());
}
Attribute::Parsed(attr) => panic!("can't get span of parsed attr: {:?}", attr),
};
span.desugaring_kind().is_none()
}
}

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

Program output

error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `,`
 --> /tmp/icemaker_global_tempdir.AS8iEHKl4RbH/rustc_testrunner_tmpdir_reporting.yEo5zhKBQFBQ/mvce.rs:3:16
  |
3 |     #[cfg_attr(, (cc))]
  |     -----------^------- help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]`
  |
  = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>


thread 'rustc' (3121492) panicked at /rustc-dev/2972b5e59f1c5529b6ba770437812fd83ab4ebd4/compiler/rustc_hir/src/hir.rs:1315:40:
can't get span of parsed attr: CfgAttrTrace
stack backtrace:
   0:     0x7f38bd1c0abb - <<std[de416e893de1faf9]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[9f8d6771964fc20c]::fmt::Display>::fmt
   1:     0x7f38bd81e1c8 - core[9f8d6771964fc20c]::fmt::write
   2:     0x7f38bd1d7ac6 - <std[de416e893de1faf9]::sys::stdio::unix::Stderr as std[de416e893de1faf9]::io::Write>::write_fmt
   3:     0x7f38bd196ac8 - std[de416e893de1faf9]::panicking::default_hook::{closure#0}
   4:     0x7f38bd1b3ec3 - std[de416e893de1faf9]::panicking::default_hook
   5:     0x7f38bc1c2e4c - std[de416e893de1faf9]::panicking::update_hook::<alloc[57804382fb016052]::boxed::Box<rustc_driver_impl[7a9a631d48bc4eca]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f38bd1b41a2 - std[de416e893de1faf9]::panicking::panic_with_hook
   7:     0x7f38bd196b88 - std[de416e893de1faf9]::panicking::panic_handler::{closure#0}
   8:     0x7f38bd18d8b9 - std[de416e893de1faf9]::sys::backtrace::__rust_end_short_backtrace::<std[de416e893de1faf9]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f38bd1985ed - __rustc[5b7e1576be862841]::rust_begin_unwind
  10:     0x7f38b9ca4dfc - core[9f8d6771964fc20c]::panicking::panic_fmt
  11:     0x7f38bc288a8b - <rustc_hir[82b4db74f24c7276]::hir::Attribute>::has_span_without_desugaring_kind
  12:     0x7f38bf4d5326 - <rustc_hir_typeck[a5a09d266657c249]::fn_ctxt::FnCtxt>::precedence::{closure#0}.llvm.1794478017940416111.cold
  13:     0x7f38be972f67 - <rustc_hir[82b4db74f24c7276]::hir::Expr>::precedence
  14:     0x7f38bc4ac99e - <rustc_hir_typeck[a5a09d266657c249]::fn_ctxt::FnCtxt>::suggest_deref_ref_or_into
  15:     0x7f38bc49c32a - <rustc_hir_typeck[a5a09d266657c249]::fn_ctxt::FnCtxt>::emit_type_mismatch_suggestions
  16:     0x7f38bc497874 - <rustc_hir_typeck[a5a09d266657c249]::fn_ctxt::FnCtxt>::emit_coerce_suggestions
  17:     0x7f38bdb3888c - <rustc_hir_typeck[a5a09d266657c249]::fn_ctxt::FnCtxt>::check_expr_block
  18:     0x7f38bdb3b5aa - <rustc_hir_typeck[a5a09d266657c249]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  19:     0x7f38be0fec80 - rustc_hir_typeck[a5a09d266657c249]::check::check_fn
  20:     0x7f38bea384b4 - rustc_hir_typeck[a5a09d266657c249]::typeck_with_inspect::{closure#0}
  21:     0x7f38bea36eb0 - rustc_query_impl[fdd9a9cd73aeb4]::query_impl::typeck_root::invoke_provider_fn::__rust_begin_short_backtrace
  22:     0x7f38bd8bb866 - rustc_query_impl[fdd9a9cd73aeb4]::execution::try_execute_query::<rustc_data_structures[3e48709548f32bc4]::vec_cache::VecCache<rustc_span[ae25d23050d7877d]::def_id::LocalDefId, rustc_middle[4d5ddcd23ba200cb]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[4d5ddcd23ba200cb]::dep_graph::graph::DepNodeIndex>, false>
  23:     0x7f38bd8bb143 - rustc_query_impl[fdd9a9cd73aeb4]::query_impl::typeck_root::execute_query_non_incr::__rust_end_short_backtrace
  24:     0x7f38be1075e6 - <rustc_middle[4d5ddcd23ba200cb]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[ffc1d045f4785174]::check_crate::{closure#1}>::{closure#0}
  25:     0x7f38be106fdf - rustc_hir_analysis[ffc1d045f4785174]::check_crate
  26:     0x7f38bd8b7f61 - rustc_interface[e1d24a92004beaf7]::passes::analysis
  27:     0x7f38bea05049 - rustc_query_impl[fdd9a9cd73aeb4]::execution::try_execute_query::<rustc_middle[4d5ddcd23ba200cb]::query::caches::SingleCache<rustc_middle[4d5ddcd23ba200cb]::query::erase::ErasedData<[u8; 0usize]>>, false>
  28:     0x7f38bea04cb5 - rustc_query_impl[fdd9a9cd73aeb4]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  29:     0x7f38be9b1990 - rustc_interface[e1d24a92004beaf7]::interface::run_compiler::<(), rustc_driver_impl[7a9a631d48bc4eca]::run_compiler::{closure#0}>::{closure#1}
  30:     0x7f38be9e3c3e - std[de416e893de1faf9]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[e1d24a92004beaf7]::util::run_in_thread_with_globals<rustc_interface[e1d24a92004beaf7]::util::run_in_thread_pool_with_globals<rustc_interface[e1d24a92004beaf7]::interface::run_compiler<(), rustc_driver_impl[7a9a631d48bc4eca]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  31:     0x7f38be9e44e0 - <std[de416e893de1faf9]::thread::lifecycle::spawn_unchecked<rustc_interface[e1d24a92004beaf7]::util::run_in_thread_with_globals<rustc_interface[e1d24a92004beaf7]::util::run_in_thread_pool_with_globals<rustc_interface[e1d24a92004beaf7]::interface::run_compiler<(), rustc_driver_impl[7a9a631d48bc4eca]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[9f8d6771964fc20c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:     0x7f38be9e53ec - <std[de416e893de1faf9]::sys::thread::unix::Thread>::new::thread_start
  33:     0x7f38b84a597a - <unknown>
  34:     0x7f38b85292bc - <unknown>
  35:                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.96.0-nightly (2972b5e59 2026-04-03) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck_root] type-checking `main`
#1 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 1 previous error


Metadata

Metadata

Assignees

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
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