Skip to content

ICE: called Result::unwrap() on an Err value: ParseIntError { kind: PosOverflow } in rustc_builtin_macros/src/format_foreign.rs #137580

@cushionbadak

Description

@cushionbadak

Code

Be aware of quotation mark locations.

fn main() {
    println!("%100000$, 1);
    println!(s%     65536", 1337f64);
}
Original Code (Mutant from Fuzzing)

fn main() {
    println!("%100000$, 1);
    //~^ ERROR argument never used
    println!(s%     65536", 1337f64);
    //~^ ERROR argument never used
}


// /home/jb/workspace/seeds_250219/tests/ui/macros/println-percent-prefix-num-issue-125002.rs

Meta

rustc --version --verbose:

rustc 1.87.0-nightly (617aad8c2 2025-02-24)
binary: rustc
commit-hash: 617aad8c2e8783f6df8e5d1f8bb1e4bcdc70aa7b
commit-date: 2025-02-24
host: x86_64-apple-darwin
release: 1.87.0-nightly
LLVM version: 20.1.0

Error output

thread 'rustc' panicked at compiler/rustc_builtin_macros/src/format_foreign.rs:417:85:
called `Result::unwrap()` on an `Err` value: ParseIntError { kind: PosOverflow }
Backtrace

thread 'rustc' panicked at compiler/rustc_builtin_macros/src/format_foreign.rs:417:85:
called `Result::unwrap()` on an `Err` value: ParseIntError { kind: PosOverflow }
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: <rustc_builtin_macros::format_foreign::printf::Substitutions as core::iter::traits::iterator::Iterator>::next
   4: rustc_builtin_macros::format::make_format_args
   5: rustc_builtin_macros::format::expand_format_args_impl
   6: <rustc_expand::expand::MacroExpander>::expand_invoc
   7: <rustc_expand::expand::MacroExpander>::fully_expand_fragment
   8: <rustc_expand::expand::MacroExpander>::expand_crate
   9: rustc_interface::passes::resolver_for_lowering_raw
      [... omitted 2 frames ...]
  10: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
  11: 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/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: please attach the file at `/Volumes/T7/workspace/250225 scratch/codes/rustc-ice-2025-02-25T03_39_56-16081.txt` to your bug report

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

Note

  • ICE location: compiler/rustc_builtin_macros/src/format_foreign.rs Line-417
    if let Start = state {
    match c {
    '1'..='9' => {
    let end = at_next_cp_while(next, char::is_ascii_digit);
    match end.next_cp() {
    // Yes, this *is* the parameter.
    Some(('$', end2)) => {
    state = Flags;
    parameter = Some(at.slice_between(end).unwrap().parse().unwrap());
    move_to!(end2);
    }

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions