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

clippy: rustc panicked at hir.rs:1165, can't get the span of an arbitrary parsed attribute #14305

Closed
proski opened this issue Feb 26, 2025 · 2 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@proski
Copy link

proski commented Feb 26, 2025

Summary

The crash only happens with clippy. The build, test and fmt targets are not affected.

The issue happens in a proprietary crate that I cannot share. I cannot promise to provide a minimal example. I'll take a look.

Version

$ rustc +nightly -vV
rustc 1.87.0-nightly (85abb2763 2025-02-25)
binary: rustc
commit-hash: 85abb276361c424d64743c0965242dd0e7b866d1
commit-date: 2025-02-25
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Error output

Backtrace

$ RUST_BACKTRACE=1 cargo +nightly clippy
  Checking telemetry-encoder v0.1.0 (/home/proskin/src/telemetry-encoder)

thread 'rustc' panicked at /rustc/85abb276361c424d64743c0965242dd0e7b866d1/compiler/rustc_hir/src/hir.rs:1165:18:
can't get the span of an arbitrary parsed attribute: Parsed(Repr([(ReprTransparent, /home/proskin/.cargo/registry/src/artifactory.relspace.net-84375e99cd472db6/bitflags-2.8.0/src/internal.rs:19:16: 19:27 (#216))]))
stack backtrace:
 0: rust_begin_unwind
 1: core::panicking::panic_fmt
 2: <clippy_lints::macro_use::MacroUseImports as rustc_lint::passes::LateLintPass>::check_attribute
 3: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_nested_item
 4: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_block
 5: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_expr::{closure#0}::{closure#0}
 6: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_expr
 7: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_nested_body
 8: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_nested_item
 9: <rustc_lint::late::LateContextAndPass<rustc_lint::late::RuntimeCombinedLateLintPass> as rustc_hir::intravisit::Visitor>::visit_nested_item
10: rustc_lint::late::check_crate::{closure#0}
11: rustc_lint::late::check_crate
12: rustc_interface::passes::analysis
    [... omitted 1 frame ...]
13: 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}
14: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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 `/home/proskin/src/telemetry-encoder/rustc-ice-2025-02-26T23_14_30-16829.txt` to your bug report

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

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

error: could not compile `telemetry-encoder` (bin "telemetry-encoder")

Caused by:
process didn't exit successfully: `/home/proskin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/clippy-driver /home/proskin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name telemetry_encoder --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=313 --crate-type bin --emit=dep-info,metadata -C embed-bitcode=no -C debuginfo=2 '--deny=clippy::suspicious' '--deny=clippy::style' '--deny=clippy::perf' '--deny=clippy::pedantic' '--deny=clippy::correctness' '--deny=clippy::complexity' '--deny=clippy::cargo' '--deny=clippy::all' '--allow=clippy::multiple_crate_versions' '--deny=clippy::missing_docs_in_private_items' --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=9ce66c15df96ff0d -C extra-filename=-be111676247cc676 --out-dir /home/proskin/src/telemetry-encoder/target/debug/deps -C incremental=/home/proskin/src/telemetry-encoder/target/debug/incremental -L dependency=/home/proskin/src/telemetry-encoder/target/debug/deps --extern bitflags=/home/proskin/src/telemetry-encoder/target/debug/deps/libbitflags-733f557f618b1cd4.rmeta --extern cai_golay=/home/proskin/src/telemetry-encoder/target/debug/deps/libcai_golay-b8882adde89e51e9.rmeta --extern clap=/home/proskin/src/telemetry-encoder/target/debug/deps/libclap-a3c72b3304a60018.rmeta --extern crossbeam_channel=/home/proskin/src/telemetry-encoder/target/debug/deps/libcrossbeam_channel-f98f2242efe5e83d.rmeta --extern flatbuffers=/home/proskin/src/telemetry-encoder/target/debug/deps/libflatbuffers-d96c12a6fe5ac50a.rmeta --extern rs_network_interface=/home/proskin/src/telemetry-encoder/target/debug/deps/librs_network_interface-189b4f49348cbc88.rmeta --extern serde=/home/proskin/src/telemetry-encoder/target/debug/deps/libserde-d694fe2040850058.rmeta --extern serde_json=/home/proskin/src/telemetry-encoder/target/debug/deps/libserde_json-cabd6208b70e811b.rmeta --extern socket2=/home/proskin/src/telemetry-encoder/target/debug/deps/libsocket2-56dae2d294931035.rmeta --extern thiserror=/home/proskin/src/telemetry-encoder/target/debug/deps/libthiserror-1fbc8606ddaa7b86.rmeta --extern tokio=/home/proskin/src/telemetry-encoder/target/debug/deps/libtokio-f64b21f6c7b6e281.rmeta --extern tracing=/home/proskin/src/telemetry-encoder/target/debug/deps/libtracing-f035d4a807c12b0f.rmeta --extern tracing_subscriber=/home/proskin/src/telemetry-encoder/target/debug/deps/libtracing_subscriber-ae6e1214c51111d0.rmeta --extern typify=/home/proskin/src/telemetry-encoder/target/debug/deps/libtypify-d258e32ffd7ba59e.rmeta` (exit status: 101)

@proski proski added C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ labels Feb 26, 2025
@proski
Copy link
Author

proski commented Feb 27, 2025

I was able to reduce the issue to a simple example.

Cargo.toml:

[package]
name = "issue-demo"
version = "0.1.0"
edition = "2024"

[lints.clippy]
pedantic.level = "deny"

[dependencies]
bitflags = { version = "=2.8.0" }

src/lib.rs:

bitflags::bitflags! {
    struct Bits: u32 {
    }
}

@y21
Copy link
Member

y21 commented Feb 27, 2025

#[repr(transparent)] struct Foo; is enough to trigger this. See the pinned issue #14303 (and rust-lang/rust#137640 which the pinned issue is also a duplicate of).

@y21 y21 closed this as completed Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants