Change:
= note: positional arguments are zero-based = note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html <ins> error: 2 positional arguments in format string, but no arguments were given --> $DIR/ifmt-bad-arg.rs:92:15 | LL |     println!("{:.*}"); |               ^^--^ |                 | |                 this precision flag adds an extra required argument at position 0, which is why there are 2 arguments expected | = note: positional arguments are zero-based = note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html </ins> error[E0308]: mismatched types --> $DIR/ifmt-bad-arg.rs:78:32 |

Discussion:
Hi there! This is the second time I've compiled code with Rust ever, and my first time filing a bug report, so I may need some guidance if the info here isn't quite enough to work with :). Learning about println! in Rust by Example, I incorrectly entered the below code. I looked at the documentation and realized I had made a mistake, but the compiler still panicked and recommended I open a bug report. I really believe in Rust and want to see this project succeed, hopefully this information is helpful! I tried this code: println!("Pi is roughly: {:.*}, 3, 3.") Expected to see this happen: "Pi is roughly 3.142" Instead, this happened: thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', note: run with environment variable to display a backtrace. error: internal compiler error: unexpected panic note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: note: rustc 1.38.0 ( 2019-09-23) running on x8664-unknown-linux-gnu :rustc 1.38.0 ( 2019-09-23) binary: rustc commit-hash: commit-date: 2019-09-23 host: x8664-unknown-linux-gnu release: 1.38.0 LLVM version: 9.0 Backtrace: thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0',

stack backtrace: 0: backtrace::backtrace::libunwind::trace at 1: backtrace::backtrace::traceunsynchronized at 2: std::syscommon::backtrace::print at 3: std::syscommon::backtrace::print at 4: std::panicking::defaulthook::{{closure}} at 5: std::panicking::defaulthook at 6: rustc::util::common::panichook 7: std::panicking::rustpanicwithhook at 8: std::panicking::continuepanicfmt at 9: rustbeginunwind at 10: core::panicking::panicfmt at 11: core::panicking::panicboundscheck at 12: syntaxext::format::expandpreparsedformatargs 13: syntaxext::format::expandformatargsimpl 14: <F as syntax::ext::base::TTMacroExpander::expand 15: syntax::ext::expand::MacroExpander::expandfragment 16: syntax::ext::expand::MacroExpander::expandcrate 17: rustcinterface::passes::configureandexpandinner::{{closure}} 18: rustc::util::common::time 19: rustcinterface::passes::configureandexpandinner 20: rustcinterface::passes::configureandexpand::{{closure}} 21: rustcdatastructures::boxregion::PinnedGenerator<I,A,R::new 22: rustcinterface::passes::configureandexpand 23: rustcinterface::queries::Query<T::compute 24: rustcinterface::queries::<impl rustcinterface::interface::Compiler::expansion 25: rustcinterface::interface::runcompilerinexistingthreadpool 26: std::thread::local::LocalKey<T::with 27: syntax::withglobals note: Some details are omitted, run with for a verbose backtrace. query stack during panic: end of query stack
This code fails on nightly, beta, and stable. Here's a link to the minimal failing code:
The entirety of the println is a string: So it shouldn't compile,instead it should print this error:
I believe the error is caused in the following line: the correct code would be , but you have encountered a bug in the compiler's diagnostic machinery. The output you should have seen is