Skip to content

ICE: didn't reparse a literal #140098

New issue

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

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

Already on GitHub? # to your account

Closed
matthiaskrgr opened this issue Apr 21, 2025 · 1 comment · Fixed by #140144
Closed

ICE: didn't reparse a literal #140098

matthiaskrgr opened this issue Apr 21, 2025 · 1 comment · Fixed by #140144
Labels
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

auto-reduced (treereduce-rust):

macro_rules! m {
  ($abi : literal) => { extern $abi }
}

fn main() {
    m!(-2)
}

original:

macro_rules! m {
  ($abi : literal) => { extern $abi } //~ ERROR expected expression, found keyword `extern`
}

fn main() {
    m!(-2)
}

Version information

rustc 1.88.0-nightly (b8005bff3 2025-04-20)
binary: rustc
commit-hash: b8005bff3248cfc6e327faf4fa631ac49bb49ba9
commit-date: 2025-04-20
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2

Possibly related line of code:

MetaVarKind::Literal,
))) => {
let lit = self
.eat_metavar_seq(MetaVarKind::Literal, |this| this.parse_literal_maybe_minus())
.expect("metavar seq literal");
let ast::ExprKind::Lit(token_lit) = lit.kind else {
panic!("didn't reparse a literal");
};
Some(token_lit)
}
token::OpenDelim(Delimiter::Invisible(InvisibleOrigin::MetaVar(
mv_kind @ MetaVarKind::Expr { can_begin_literal_maybe_minus: true, .. },
))) => {

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

Program output


thread 'rustc' panicked at compiler/rustc_parse/src/parser/expr.rs:2167:21:
didn't reparse a literal
stack backtrace:
   0:     0x7796dc0bfa13 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hd3d6a01c34b68e33
   1:     0x7796dc805b07 - core::fmt::write::hc8609d2830ea7209
   2:     0x7796ddca2b11 - std::io::Write::write_fmt::h5803b161d154e6bb
   3:     0x7796dc0bf872 - std::sys::backtrace::BacktraceLock::print::h7d1ba71c4ac8a197
   4:     0x7796dc0c31ea - std::panicking::default_hook::{{closure}}::h81636b35691bb80d
   5:     0x7796dc0c2d6f - std::panicking::default_hook::h3d6df3ec9a366961
   6:     0x7796db1439a3 - std[a4b1c5db45b5369]::panicking::update_hook::<alloc[a753183b20116edd]::boxed::Box<rustc_driver_impl[64822a3bbb8e5a99]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7796dc0c3a63 - std::panicking::rust_panic_with_hook::hc0072f606cfb3c45
   8:     0x7796dc0c3726 - std::panicking::begin_panic_handler::{{closure}}::h9dfbf037bfb6d7d4
   9:     0x7796dc0bfee9 - std::sys::backtrace::__rust_end_short_backtrace::hdeb7489c831217fd
  10:     0x7796dc0c341d - __rustc[d3657d69ef8eb27f]::rust_begin_unwind
  11:     0x7796d8a86440 - core::panicking::panic_fmt::h3cd888558dd93878
  12:     0x7796dcc8af2a - <rustc_parse[1eb829f8d0d4d997]::parser::Parser>::parse_opt_meta_item_lit
  13:     0x7796dcc89b21 - <rustc_parse[1eb829f8d0d4d997]::parser::Parser>::parse_abi
  14:     0x7796dd292961 - <rustc_parse[1eb829f8d0d4d997]::parser::Parser>::parse_item_foreign_mod
  15:     0x7796dd2a0365 - <rustc_parse[1eb829f8d0d4d997]::parser::Parser>::parse_item_kind
  16:     0x7796dd29c2b6 - <rustc_parse[1eb829f8d0d4d997]::parser::Parser>::parse_item_common
  17:     0x7796dd288229 - <rustc_parse[1eb829f8d0d4d997]::parser::Parser>::parse_stmt_without_recovery
  18:     0x7796dd286b4d - <rustc_parse[1eb829f8d0d4d997]::parser::Parser>::parse_full_stmt
  19:     0x7796ddbf56c6 - rustc_expand[bc4e8c07b7b0cd92]::expand::parse_ast_fragment
  20:     0x7796ddbbb5e1 - <rustc_expand[bc4e8c07b7b0cd92]::expand::MacroExpander>::fully_expand_fragment
  21:     0x7796ddb7a877 - <rustc_expand[bc4e8c07b7b0cd92]::expand::MacroExpander>::expand_crate
  22:     0x7796dcf3e0fb - rustc_interface[87387720858aeda]::passes::resolver_for_lowering_raw
  23:     0x7796dcf3d50d - rustc_query_impl[f9677782d554bbe0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f9677782d554bbe0]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[105e55ff3e6629a7]::query::erase::Erased<[u8; 16usize]>>
  24:     0x7796dcf3d4e9 - <rustc_query_impl[f9677782d554bbe0]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[89ea4ceba863dd14]::ops::function::FnOnce<(rustc_middle[105e55ff3e6629a7]::ty::context::TyCtxt, ())>>::call_once
  25:     0x7796dd8134d1 - rustc_query_system[6c94265d9bb07c02]::query::plumbing::try_execute_query::<rustc_query_impl[f9677782d554bbe0]::DynamicConfig<rustc_query_system[6c94265d9bb07c02]::query::caches::SingleCache<rustc_middle[105e55ff3e6629a7]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[f9677782d554bbe0]::plumbing::QueryCtxt, false>
  26:     0x7796dd813040 - rustc_query_impl[f9677782d554bbe0]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  27:     0x7796ddb1ed73 - rustc_interface[87387720858aeda]::passes::create_and_enter_global_ctxt::<core[89ea4ceba863dd14]::option::Option<rustc_interface[87387720858aeda]::queries::Linker>, rustc_driver_impl[64822a3bbb8e5a99]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  28:     0x7796dd955404 - rustc_interface[87387720858aeda]::interface::run_compiler::<(), rustc_driver_impl[64822a3bbb8e5a99]::run_compiler::{closure#0}>::{closure#1}
  29:     0x7796dd6ecd68 - std[a4b1c5db45b5369]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[87387720858aeda]::util::run_in_thread_with_globals<rustc_interface[87387720858aeda]::util::run_in_thread_pool_with_globals<rustc_interface[87387720858aeda]::interface::run_compiler<(), rustc_driver_impl[64822a3bbb8e5a99]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  30:     0x7796dd6ed1b4 - <<std[a4b1c5db45b5369]::thread::Builder>::spawn_unchecked_<rustc_interface[87387720858aeda]::util::run_in_thread_with_globals<rustc_interface[87387720858aeda]::util::run_in_thread_pool_with_globals<rustc_interface[87387720858aeda]::interface::run_compiler<(), rustc_driver_impl[64822a3bbb8e5a99]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[89ea4ceba863dd14]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  31:     0x7796dd6ee5b7 - std::sys::pal::unix::thread::Thread::new::thread_start::h763527da6478f178
  32:     0x7796d765d70a - <unknown>
  33:     0x7796d76e1aac - <unknown>
  34:                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.88.0-nightly (b8005bff3 2025-04-20) 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 Apr 21, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 21, 2025
@matthiaskrgr
Copy link
Member Author

macro_rules! a {
  ($abi : literal) => { extern $abi }
}
fn b() { a !(-2) }

bisects to #138478 cc @nnethercote

ChrisDenton added a commit to ChrisDenton/rust that referenced this issue Apr 22, 2025
…nkov

Handle another negated literal in `eat_token_lit`.

Extends the change from rust-lang#139653, which was on expressions, to literals.

Fixes rust-lang#140098.

r? `@petrochenkov`
ChrisDenton added a commit to ChrisDenton/rust that referenced this issue Apr 22, 2025
…nkov

Handle another negated literal in `eat_token_lit`.

Extends the change from rust-lang#139653, which was on expressions, to literals.

Fixes rust-lang#140098.

r? ``@petrochenkov``
@bors bors closed this as completed in 6be270b Apr 23, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 23, 2025
Rollup merge of rust-lang#140144 - nnethercote:fix-140098, r=petrochenkov

Handle another negated literal in `eat_token_lit`.

Extends the change from rust-lang#139653, which was on expressions, to literals.

Fixes rust-lang#140098.

r? ``@petrochenkov``
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 24, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
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.

3 participants