Skip to content

ICE: attr_parsing: None #137589

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

Closed
matthiaskrgr opened this issue Feb 25, 2025 · 2 comments · Fixed by #137622
Closed

ICE: attr_parsing: None #137589

matthiaskrgr opened this issue Feb 25, 2025 · 2 comments · Fixed by #137622
Assignees
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) 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

auto-reduced (treereduce-rust):

#[crate_type = foo!()]

macro_rules! foo {}

original:

#[crate_type = foo!()] //~ ERROR malformed `crate_type` attribute

macro_rules! foo {
    ($x:expr) => {"rlib"}
}

fn main(input: TokenStream) {}

Version information

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

Possibly related line of code:

// literal suffices because the error is handled elsewhere.
if let ExprKind::Lit(token_lit) = expr.kind
&& let Ok(lit) = MetaItemLit::from_token_lit(token_lit, expr.span)
{
lit
} else {
let guar = dcx.has_errors().unwrap();
MetaItemLit { symbol: kw::Empty, suffix: None, kind: LitKind::Err(guar), span: DUMMY_SP }
}
}
struct MetaItemListParserContext<'a> {
// the tokens inside the delimiters, so `#[some::attr(a b c)]` would have `a b c` inside

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

Program output


thread 'rustc' panicked at compiler/rustc_attr_parsing/src/parser.rs:359:37:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7454c8db0f34 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hca18af6381e1367c
   1:     0x7454c961622c - core::fmt::write::h5592619a5f30a24e
   2:     0x7454ca6dcbd1 - std::io::Write::write_fmt::hc543125416d93a55
   3:     0x7454c8db0d92 - std::sys::backtrace::BacktraceLock::print::h2507b83f5fdb3698
   4:     0x7454c8db359e - std::panicking::default_hook::{{closure}}::h25029c6d53322486
   5:     0x7454c8db3174 - std::panicking::default_hook::hded85171c110cc3b
   6:     0x7454c7f1a827 - std[581eff941795a880]::panicking::update_hook::<alloc[44b1b4d4d47dda6c]::boxed::Box<rustc_driver_impl[dcc8af57e0e84081]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7454c8db3e13 - std::panicking::rust_panic_with_hook::hbe0a3b6f34c80380
   8:     0x7454c8db3ad6 - std::panicking::begin_panic_handler::{{closure}}::h96108bfc4d0410ef
   9:     0x7454c8db1409 - std::sys::backtrace::__rust_end_short_backtrace::hbc5818272a3822f9
  10:     0x7454c8db37cd - rust_begin_unwind
  11:     0x7454c5a57230 - core::panicking::panic_fmt::hb6e77e50b01fee54
  12:     0x7454c656f1cc - core::panicking::panic::h45623d079da032ff
  13:     0x7454c6a6ca39 - core::option::unwrap_failed::h18b853f451c32f02
  14:     0x7454ca6fc7e9 - <rustc_attr_parsing[de2d70ad19620381]::parser::MetaItemParser>::from_attr
  15:     0x7454c9997f74 - <rustc_resolve[6538e53b518fe23]::def_collector::DefCollector as rustc_ast[4d549af5eee0e1c]::visit::Visitor>::visit_item
  16:     0x7454c9997ada - <rustc_resolve[6538e53b518fe23]::def_collector::DefCollector as rustc_ast[4d549af5eee0e1c]::visit::Visitor>::visit_crate
  17:     0x7454c9995377 - <rustc_resolve[6538e53b518fe23]::Resolver as rustc_expand[8161f5b87f9ed4]::base::ResolverExpand>::visit_ast_fragment_with_placeholders
  18:     0x7454c9e81a70 - <rustc_expand[8161f5b87f9ed4]::expand::MacroExpander>::collect_invocations
  19:     0x7454ca9099b6 - <rustc_expand[8161f5b87f9ed4]::expand::MacroExpander>::fully_expand_fragment
  20:     0x7454ca90942b - <rustc_expand[8161f5b87f9ed4]::expand::MacroExpander>::expand_crate
  21:     0x7454c99a14dd - rustc_interface[5317c0be442ff202]::passes::resolver_for_lowering_raw
  22:     0x7454c99a0927 - rustc_query_impl[c32460660d187a22]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c32460660d187a22]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e6f8bc74c8fc856c]::query::erase::Erased<[u8; 16usize]>>
  23:     0x7454c99a0915 - <rustc_query_impl[c32460660d187a22]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[f5b0be8ed3a1b4e]::ops::function::FnOnce<(rustc_middle[e6f8bc74c8fc856c]::ty::context::TyCtxt, ())>>::call_once
  24:     0x7454ca6d8458 - rustc_query_system[e93ee9904dcaa7d1]::query::plumbing::try_execute_query::<rustc_query_impl[c32460660d187a22]::DynamicConfig<rustc_query_system[e93ee9904dcaa7d1]::query::caches::SingleCache<rustc_middle[e6f8bc74c8fc856c]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[c32460660d187a22]::plumbing::QueryCtxt, false>
  25:     0x7454ca6d7fc7 - rustc_query_impl[c32460660d187a22]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  26:     0x7454ca758f6c - rustc_interface[5317c0be442ff202]::passes::create_and_enter_global_ctxt::<core[f5b0be8ed3a1b4e]::option::Option<rustc_interface[5317c0be442ff202]::queries::Linker>, rustc_driver_impl[dcc8af57e0e84081]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  27:     0x7454ca6e7ee0 - rustc_interface[5317c0be442ff202]::interface::run_compiler::<(), rustc_driver_impl[dcc8af57e0e84081]::run_compiler::{closure#0}>::{closure#1}
  28:     0x7454ca5a1ac8 - std[581eff941795a880]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[5317c0be442ff202]::util::run_in_thread_with_globals<rustc_interface[5317c0be442ff202]::util::run_in_thread_pool_with_globals<rustc_interface[5317c0be442ff202]::interface::run_compiler<(), rustc_driver_impl[dcc8af57e0e84081]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  29:     0x7454ca5a2274 - <<std[581eff941795a880]::thread::Builder>::spawn_unchecked_<rustc_interface[5317c0be442ff202]::util::run_in_thread_with_globals<rustc_interface[5317c0be442ff202]::util::run_in_thread_pool_with_globals<rustc_interface[5317c0be442ff202]::interface::run_compiler<(), rustc_driver_impl[dcc8af57e0e84081]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[f5b0be8ed3a1b4e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  30:     0x7454ca5a376f - std::sys::pal::unix::thread::Thread::new::thread_start::h717201ab54b439ec
  31:     0x7454c46a370a - <unknown>
  32:     0x7454c4727aac - <unknown>
  33:                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.87.0-nightly (f5729cfed 2025-02-25) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack

@matthiaskrgr matthiaskrgr added 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
@workingjubilee workingjubilee added the A-repr Area: the `#[repr(stuff)]` attribute label Feb 25, 2025
@fmease fmease added A-attributes Area: Attributes (`#[…]`, `#![…]`) and removed A-repr Area: the `#[repr(stuff)]` attribute labels Feb 25, 2025
@jdonszelmann
Copy link
Contributor

@rustbot claim

@jdonszelmann
Copy link
Contributor

So this was a case we silently ignored in the past, and isn't caught by any other check while I assumed it would be. I've got a local fix now so thats good :)

Openin a PR in a sec

jdonszelmann added a commit to jdonszelmann/rust that referenced this issue Feb 25, 2025
jdonszelmann added a commit to jdonszelmann/rust that referenced this issue Feb 25, 2025
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 25, 2025
fmease added a commit to fmease/rust that referenced this issue Feb 26, 2025
…r-errors

fix attribute-related ICE when parsing macro on the rhs of a name-value attribute

r? `@oli-obk`

Closes: rust-lang#137589
fmease added a commit to fmease/rust that referenced this issue Feb 26, 2025
…r-errors

fix attribute-related ICE when parsing macro on the rhs of a name-value attribute

r? ``@oli-obk``

Closes: rust-lang#137589
@bors bors closed this as completed in 4bf66c5 Feb 26, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 26, 2025
Rollup merge of rust-lang#137622 - jdonszelmann:fix-137589, r=compiler-errors

fix attribute-related ICE when parsing macro on the rhs of a name-value attribute

r? ``@oli-obk``

Closes: rust-lang#137589
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) 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.

6 participants