Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
matthiaskrgr opened this issue Feb 25, 2025 · 9 comments · Fixed by #137752
Closed

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

matthiaskrgr opened this issue Feb 25, 2025 · 9 comments · Fixed by #137752
Assignees
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-clippy Area: Clippy C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Feb 25, 2025

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

@matthiaskrgr matthiaskrgr added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-clippy Area: Clippy C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 25, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 25, 2025
@matthiaskrgr matthiaskrgr changed the title ICE: clippy: `can't get the span of an arbitrary parsed attribute ICE: clippy: can't get the span of an arbitrary parsed attribute Feb 25, 2025
@matthiaskrgr
Copy link
Member Author

cc @jdonszelmann proably :)

@jdonszelmann
Copy link
Contributor

@rustbot claim

@jdonszelmann
Copy link
Contributor

How in the world was there no test for this, this isn't even unusual usage lmao

@compiler-errors
Copy link
Member

Because it's a clippy ICE presumably.

@matthiaskrgr
Copy link
Member Author

there seems to be only a single test for that lint in clippy and perhaps it misses any of the "interesting" attributes.. if you run clippy on the rustc testsuite with this lint you will find this ICE several 100 times on all sorts of attrs though 🤷

@compiler-errors
Copy link
Member

Yeah, I'm just saying we definitely have a test for #[repr(transparent)] for rustc.

@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 25, 2025
@yhx-12243 yhx-12243 marked this as a duplicate of rust-lang/rust-clippy#14296 Feb 26, 2025
@jieyouxu jieyouxu marked this as a duplicate of #137664 Feb 26, 2025
taiki-e added a commit to taiki-e/atomic-maybe-uninit that referenced this issue Feb 26, 2025
taiki-e added a commit to taiki-e/atomic-maybe-uninit that referenced this issue Feb 26, 2025
taiki-e added a commit to taiki-e/atomic-memcpy that referenced this issue Feb 26, 2025
taiki-e added a commit to taiki-e/cargo-hack that referenced this issue Feb 26, 2025
taiki-e added a commit to taiki-e/cargo-llvm-cov that referenced this issue Feb 26, 2025
taiki-e added a commit to taiki-e/cargo-minimal-versions that referenced this issue Feb 26, 2025
taiki-e added a commit to taiki-e/cargo-no-dev-deps that referenced this issue Feb 26, 2025
taiki-e added a commit to taiki-e/test-helper that referenced this issue Feb 26, 2025
taiki-e added a commit to taiki-e/pin-project that referenced this issue Feb 26, 2025
@flip1995
Copy link
Member

Now Clippy CI is running into this issue after the sync https://github.com/rust-lang/rust-clippy/actions/runs/13551226005/job/37875046333?pr=14300 😅

@jdonszelmann Let me know if you need help fixing this on the Clippy side.

@jdonszelmann
Copy link
Contributor

I've as of now spent no time fixing clippy. Feel free to, if you'd like otherwise I'll look at it later. Rn I'm trying to fix fundamental issues, while in this case it's not the api that's wrong but just clippy having a lint that uses part of the new and part of the old api and prolly the lint itself needs to change. Unsure why we didn't notice it earlier but it's what its

@y21 y21 marked this as a duplicate of rust-lang/rust-clippy#14305 Feb 27, 2025
This was referenced Feb 27, 2025
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 28, 2025
…nishearth

Clippy subtree update

? `@Manishearth`

Cargo.lock change because of Clippy version bump and rustc_tool_utils new release.

Fixes rust-lang#137640

Would be nice, if we could this merged before nightly is being build, so that this ICE is fixed tomorrow.
dtolnay added a commit to dtolnay/cxx that referenced this issue Feb 28, 2025
@UditDey
Copy link

UditDey commented Feb 28, 2025

just throwing in that I have the same ICE on the same nightly version on a struct that uses a #[repr(align(0x200_000))] attribute

bors added a commit to rust-lang-ci/rust that referenced this issue Mar 1, 2025
…nishearth

Clippy subtree update

? `@Manishearth`

Cargo.lock change because of Clippy version bump and rustc_tool_utils new release.

Fixes rust-lang#137640

Would be nice, if we could this merged before nightly is being build, so that this ICE is fixed tomorrow.
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 1, 2025
…nishearth

Clippy subtree update

? `@Manishearth`

Cargo.lock change because of Clippy version bump and rustc_tool_utils new release.

Fixes rust-lang#137640

Would be nice, if we could this merged before nightly is being build, so that this ICE is fixed tomorrow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-clippy Area: Clippy C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants