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

macro_use_imports ICE: can't get the span of an arbitrary parsed attribute: ... #14303

Closed
DaniPopes opened this issue Feb 26, 2025 · 5 comments · Fixed by #14317
Closed

macro_use_imports ICE: can't get the span of an arbitrary parsed attribute: ... #14303

DaniPopes opened this issue Feb 26, 2025 · 5 comments · Fixed by #14317
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@DaniPopes
Copy link
Contributor

DaniPopes commented Feb 26, 2025

Summary

Found in CI here

Playground

#![warn(clippy::macro_use_imports)]

#[repr(transparent)]
pub struct X(());

Version

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

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, src/lib.rs:5:8: 5:19 (#0))]))
stack backtrace:
 0:     0x7cd70e9b4864 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hfbcadcb664e1e745
 1:     0x7cd70f21622c - core::fmt::write::h96d3ad630dab013b
 2:     0x7cd7102683d1 - std::io::Write::write_fmt::h3607b096b8efb3ee
 3:     0x7cd70e9b46c2 - std::sys::backtrace::BacktraceLock::print::h5c5089ef3846b40c
 4:     0x7cd70e9b6ece - std::panicking::default_hook::{{closure}}::ha2f1ea5200a78a69
 5:     0x7cd70e9b6aa4 - std::panicking::default_hook::he72a4c09abcc8836
 6:     0x7cd70db1c4a7 - std[fe011135ce22c601]::panicking::update_hook::<alloc[d9798e16cf59ec93]::boxed::Box<rustc_driver_impl[685633a5d1c26086]::install_ice_hook::{closure#1}>>::{closure#0}
 7:     0x7cd70e9b7743 - std::panicking::rust_panic_with_hook::h9c6e02ac63684bb2
 8:     0x7cd70e9b743a - std::panicking::begin_panic_handler::{{closure}}::h408c429dfb442e49
 9:     0x7cd70e9b4d39 - std::sys::backtrace::__rust_end_short_backtrace::h7f67e94cbe910959
10:     0x7cd70e9b70fd - rust_begin_unwind
11:     0x7cd70b658430 - core::panicking::panic_fmt::h66d01c76cbf68b4b
12:     0x5de305c93609 - <clippy_lints[5cffcd3e2f791c9d]::macro_use::MacroUseImports as rustc_lint[b946cbde2b0541cb]::passes::LateLintPass>::check_attribute
13:     0x7cd70e005b46 - <rustc_lint[b946cbde2b0541cb]::late::LateContextAndPass<rustc_lint[b946cbde2b0541cb]::late::RuntimeCombinedLateLintPass> as rustc_hir[8d893940beefe6b3]::intravisit::Visitor>::visit_nested_item
14:     0x7cd71026090b - rustc_lint[b946cbde2b0541cb]::late::check_crate::{closure#0}
15:     0x7cd710260beb - rustc_lint[b946cbde2b0541cb]::late::check_crate
16:     0x7cd710264572 - rustc_interface[6c13097cf9f19f86]::passes::analysis
17:     0x7cd710264359 - rustc_query_impl[34908cfd77543239]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[34908cfd77543239]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5ffae1726b14730a]::query::erase::Erased<[u8; 0usize]>>
18:     0x7cd710309d4b - rustc_query_system[fc2137a045893525]::query::plumbing::try_execute_query::<rustc_query_impl[34908cfd77543239]::DynamicConfig<rustc_query_system[fc2137a045893525]::query::caches::SingleCache<rustc_middle[5ffae1726b14730a]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[34908cfd77543239]::plumbing::QueryCtxt, false>
19:     0x7cd710309a39 - rustc_query_impl[34908cfd77543239]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
20:     0x7cd7102df0fc - rustc_interface[6c13097cf9f19f86]::passes::create_and_enter_global_ctxt::<core[5ec1fcc0a718fbac]::option::Option<rustc_interface[6c13097cf9f19f86]::queries::Linker>, rustc_driver_impl[685633a5d1c26086]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
21:     0x7cd7102d29e0 - rustc_interface[6c13097cf9f19f86]::interface::run_compiler::<(), rustc_driver_impl[685633a5d1c26086]::run_compiler::{closure#0}>::{closure#1}
22:     0x7cd71015e8c8 - std[fe011135ce22c601]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[6c13097cf9f19f86]::util::run_in_thread_with_globals<rustc_interface[6c13097cf9f19f86]::util::run_in_thread_pool_with_globals<rustc_interface[6c13097cf9f19f86]::interface::run_compiler<(), rustc_driver_impl[685633a5d1c26086]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
23:     0x7cd71015f074 - <<std[fe011135ce22c601]::thread::Builder>::spawn_unchecked_<rustc_interface[6c13097cf9f19f86]::util::run_in_thread_with_globals<rustc_interface[6c13097cf9f19f86]::util::run_in_thread_pool_with_globals<rustc_interface[6c13097cf9f19f86]::interface::run_compiler<(), rustc_driver_impl[685633a5d1c26086]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[5ec1fcc0a718fbac]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
24:     0x7cd71016056b - std::sys::pal::unix::thread::Thread::new::thread_start::h3ad2c4029bc451ad
25:     0x7cd70a28aa94 - <unknown>
26:     0x7cd70a317a34 - clone
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 `/playground/rustc-ice-2025-02-26T19_57_33-20.txt` to your bug report

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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 `playground` (lib)

Caused by:
process didn't exit successfully: ... (exit status: 101)

@DaniPopes DaniPopes 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
@y21
Copy link
Member

y21 commented Feb 26, 2025

This is rust-lang/rust#137640. Maybe we should keep this issue open here on this repo for visibility to help with the duplicates.

@flip1995 flip1995 pinned this issue Feb 26, 2025
@flip1995
Copy link
Member

I also pinned this issue now. We had a free slot anyway. Maybe that prevents people from opening more issues about this.

@flip1995 flip1995 marked this as a duplicate of #14312 Feb 27, 2025
@samueltardieu samueltardieu marked this as a duplicate of #14313 Feb 27, 2025
@flip1995 flip1995 marked this as a duplicate of #14316 Feb 27, 2025
flip1995 added a commit to flip1995/rust-clippy that referenced this issue Feb 27, 2025
It is not possible to write a declarative macro, that produces an attribute w/o
an item attached to it. This means that the `check_item` will already insert the
span in the map, if it came from an expansion. So additionally checking if the
macro came from an expansion doesn't add anything here. So the
`check_attribute` function, and with that the problematic `attr.span()` call can
be completely removed.

Fixes rust-lang#14303
flip1995 added a commit to flip1995/rust-clippy that referenced this issue Feb 27, 2025
It is not possible to write a declarative macro, that produces an attribute w/o
an item attached to it. This means that the `check_item` will already insert the
span in the map, if it came from an expansion. So additionally checking if the
macro came from an expansion doesn't add anything here. So the
`check_attribute` function, and with that the problematic `attr.span()` call can
be completely removed.

Fixes rust-lang#14303
github-merge-queue bot pushed a commit that referenced this issue Feb 27, 2025
It is not possible to write a declarative macro, that produces an
attribute w/o
an item attached to it. This means that the `check_item` will already
insert the
span in the map, if it came from an expansion. So additionally checking
if the
macro came from an expansion doesn't add anything here. So the
`check_attribute` function, and with that the problematic `attr.span()`
call can
be completely removed.

Fixes #14303

r? @y21

cc @jdonszelmann

changelog: Fix ICE in [`macro_use_import`] lint
@flip1995
Copy link
Member

Update: The issue was fixed in Clippy. Now this has to be synced to the Rust repo in order to get into nightly. This is done in rust-lang/rust#137752. However, that is delayed due to CI issues in the Rust repo. It should land in nightly-2025-03-01.

@flip1995
Copy link
Member

flip1995 commented Mar 2, 2025

Update: the fix made it into the rust repo and will be in nightly-2025-03-03. Sorry for the delays!

@y21
Copy link
Member

y21 commented Mar 3, 2025

Looks like the fix indeed is in today's nightly 🎉

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

Successfully merging a pull request may close this issue.

3 participants