Skip to content

ICE: clippy: can't get the span of an arbitrary parsed attribute #137640

Closed
@matthiaskrgr

Description

@matthiaskrgr

Code

#[repr(transparent)]
struct A {}

pub fn main() {}

Meta

rustc --version --verbose:

rustc 1.87.0-nightly (c51b9b6d5 2025-02-25)
binary: rustc
commit-hash: c51b9b6d5234aa8e50c3b87784113a1af1af47cb
commit-date: 2025-02-25
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Error output

clippy-driver -Wclippy::macro-use-imports c.rs

<output>
Backtrace

warning: struct `A` is never constructed
 --> c.rs:2:8
  |
2 | struct A {}
  |        ^
  |
  = note: `#[warn(dead_code)]` on by default


thread 'rustc' panicked at /rustc/c51b9b6d5234aa8e50c3b87784113a1af1af47cb/compiler/rustc_hir/src/hir.rs:1165:18:
can't get the span of an arbitrary parsed attribute: Parsed(Repr([(ReprTransparent, c.rs:1:8: 1:19 (#0))]))
stack backtrace:
   0:     0x73f4a3bb3154 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hd06da08124325462
   1:     0x73f4a44162ac - core::fmt::write::h5fe6bba1eaab6647
   2:     0x73f4a5801151 - std::io::Write::write_fmt::h242a4f537225acc3
   3:     0x73f4a3bb2fb2 - std::sys::backtrace::BacktraceLock::print::h6a8116cf43719085
   4:     0x73f4a3bb57be - std::panicking::default_hook::{{closure}}::h652ae1d376c040d0
   5:     0x73f4a3bb5394 - std::panicking::default_hook::hbc2b632e19019d80
   6:     0x73f4a2d1b357 - std[6a1ba5bc780b2c8f]::panicking::update_hook::<alloc[5fd245c89892bd9b]::boxed::Box<rustc_driver_impl[649a70f0d2c42925]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x73f4a3bb6033 - std::panicking::rust_panic_with_hook::hffde79d7fa242fa5
   8:     0x73f4a3bb5d2a - std::panicking::begin_panic_handler::{{closure}}::h99aec328caa75649
   9:     0x73f4a3bb3629 - std::sys::backtrace::__rust_end_short_backtrace::h31d90f8821e58391
  10:     0x73f4a3bb59ed - rust_begin_unwind
  11:     0x73f4a0857bf0 - core::panicking::panic_fmt::h6a861cb8601d52bb
  12:     0x6388dc6f1699 - <clippy_lints[3723b494d07e8d9d]::macro_use::MacroUseImports as rustc_lint[79e1a5435a49d07e]::passes::LateLintPass>::check_attribute
  13:     0x73f4a3202bd6 - <rustc_lint[79e1a5435a49d07e]::late::LateContextAndPass<rustc_lint[79e1a5435a49d07e]::late::RuntimeCombinedLateLintPass> as rustc_hir[648c3f7bd406ed47]::intravisit::Visitor>::visit_nested_item
  14:     0x73f4a548f70b - rustc_lint[79e1a5435a49d07e]::late::check_crate::{closure#0}
  15:     0x73f4a548f9eb - rustc_lint[79e1a5435a49d07e]::late::check_crate
  16:     0x73f4a5493372 - rustc_interface[e155d187b9eb7529]::passes::analysis
  17:     0x73f4a5493159 - rustc_query_impl[4704ba61dfd2faf2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[4704ba61dfd2faf2]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1a9c318206b2ce53]::query::erase::Erased<[u8; 0usize]>>
  18:     0x73f4a54ead8b - rustc_query_system[1d7c70f14e56b077]::query::plumbing::try_execute_query::<rustc_query_impl[4704ba61dfd2faf2]::DynamicConfig<rustc_query_system[1d7c70f14e56b077]::query::caches::SingleCache<rustc_middle[1a9c318206b2ce53]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[4704ba61dfd2faf2]::plumbing::QueryCtxt, false>
  19:     0x73f4a54eaa79 - rustc_query_impl[4704ba61dfd2faf2]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  20:     0x73f4a55a16bc - rustc_interface[e155d187b9eb7529]::passes::create_and_enter_global_ctxt::<core[475c0f0b1069090a]::option::Option<rustc_interface[e155d187b9eb7529]::queries::Linker>, rustc_driver_impl[649a70f0d2c42925]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  21:     0x73f4a54fc860 - rustc_interface[e155d187b9eb7529]::interface::run_compiler::<(), rustc_driver_impl[649a70f0d2c42925]::run_compiler::{closure#0}>::{closure#1}
  22:     0x73f4a546b6c8 - std[6a1ba5bc780b2c8f]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[e155d187b9eb7529]::util::run_in_thread_with_globals<rustc_interface[e155d187b9eb7529]::util::run_in_thread_pool_with_globals<rustc_interface[e155d187b9eb7529]::interface::run_compiler<(), rustc_driver_impl[649a70f0d2c42925]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  23:     0x73f4a546baf4 - <<std[6a1ba5bc780b2c8f]::thread::Builder>::spawn_unchecked_<rustc_interface[e155d187b9eb7529]::util::run_in_thread_with_globals<rustc_interface[e155d187b9eb7529]::util::run_in_thread_pool_with_globals<rustc_interface[e155d187b9eb7529]::interface::run_compiler<(), rustc_driver_impl[649a70f0d2c42925]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[475c0f0b1069090a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  24:     0x73f4a546cfef - std::sys::pal::unix::thread::Thread::new::thread_start::h202e3aa98fcfe0ad
  25:     0x73f49f3ab70a - <unknown>
  26:     0x73f49f42faac - <unknown>
  27:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new?template=ice.yml

note: please make sure that you have updated to the latest nightly

note: please attach the file at `/tmp/im/rip/rustc-ice-2025-02-25T21_13_13-3335937.txt` to your bug report

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
note: Clippy version: clippy 0.1.86 (c51b9b6d52 2025-02-25)

warning: 1 warning emitted

Metadata

Metadata

Assignees

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)A-clippyArea: ClippyC-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