Skip to content

index out of bounds in rustc_builtin_macros/src/format.rs #99633

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
nyurik opened this issue Jul 23, 2022 · 2 comments
Closed

index out of bounds in rustc_builtin_macros/src/format.rs #99633

nyurik opened this issue Jul 23, 2022 · 2 comments
Labels
C-bug Category: This is a bug.

Comments

@nyurik
Copy link
Contributor

nyurik commented Jul 23, 2022

I tried this code:

fn main() {
    println!("{:p$.w$}", 1.0, w = 2, p = 3);
}

cargo build crashed with thread 'rustc' panicked at 'index out of bounds: the len is 1 but the index is 1', compiler/rustc_builtin_macros/src/format.rs:1001:28. I tried it on stable 1.62.1 and nightly 1.64.0-nightly (848090dcd 2022-07-22)

Meta

rustc --version --verbose:

rustc 1.64.0-nightly (c2f428d2f 2022-07-14)
binary: rustc
commit-hash: c2f428d2f3340a0e7d995f4726223db91b93704c
commit-date: 2022-07-14
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6
Backtrace

thread 'rustc' panicked at 'index out of bounds: the len is 1 but the index is 1', compiler/rustc_builtin_macros/src/format.rs:1001:28
stack backtrace:
   0: rust_begin_unwind
             at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/core/src/panicking.rs:142:14
   2: core::panicking::panic_bounds_check
             at /rustc/c2f428d2f3340a0e7d995f4726223db91b93704c/library/core/src/panicking.rs:84:5
   3: rustc_builtin_macros::format::expand_preparsed_format_args
   4: rustc_builtin_macros::format::expand_format_args_impl
   5: <rustc_expand::expand::MacroExpander>::fully_expand_fragment
   6: <rustc_expand::expand::MacroExpander>::expand_crate
   7: <rustc_session::session::Session>::time::<core::result::Result<rustc_ast::ast::Crate, rustc_errors::ErrorGuaranteed>, rustc_interface::passes::configure_and_expand::{closure#1}>
   8: rustc_interface::passes::configure_and_expand
   9: <rustc_interface::queries::Queries>::expansion
  10: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorGuaranteed>>
  11: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
  12: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
  13: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

@nyurik nyurik added the C-bug Category: This is a bug. label Jul 23, 2022
@fmease
Copy link
Member

fmease commented Jul 23, 2022

I cannot reproduce this with a more recent nightly (e.g. 2022-07-20). This seems to have been fixed by #99480. Can you check if that's the case on your machine as well?

@nyurik
Copy link
Contributor Author

nyurik commented Jul 23, 2022

@fmease I confirmed - the irony is overwhelming, years with this bug unnoticed, but the moment it gets fixed in the main branch, I somehow stumble on it... Weirdly enough, when I used rustup update && rustup default nightly && rustc -vV, I still see the 2022-07-14 nightly being used, whereas the rustup update shows 2022-07-22. Is this a bug?

@nyurik nyurik closed this as completed Jul 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants