Open
Description
I tried this code:
fn main() {
println!("{:02x?}", [10, 11, 12]);
println!("{:08b?}", [10, 11, 12]);
}
I expected to see this happen:
It prints the given arrays in hexadecimal and in binary.
Instead, this happened:
Hexadecimal works if you comment out the binary line, but binary doesn't work.
Meta
rustc --version --verbose
:
rustc 1.74.1 (a28077b28 2023-12-04)
binary: rustc
commit-hash: a28077b28a02b92985b3a3faecf92813155f1ea1
commit-date: 2023-12-04
host: x86_64-unknown-linux-gnu
release: 1.74.1
LLVM version: 17.0.4
rustc 1.75.0-beta.7 (b216e7b0e 2023-12-16)
binary: rustc
commit-hash: b216e7b0e7a2bdf11300a21a614dac6be3e99c5b
commit-date: 2023-12-16
host: x86_64-unknown-linux-gnu
release: 1.75.0-beta.7
LLVM version: 17.0.6
rustc 1.76.0-nightly (3f28fe133 2023-12-18)
binary: rustc
commit-hash: 3f28fe133475ec5faf3413b556bf3cfb0d51336c
commit-date: 2023-12-18
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.6
Compiling bug v0.1.0 (/home/chaitrex/dev/bug)
error: invalid format string: expected `'}'`, found `'?'`
--> src/main.rs:3:20
|
3 | println!("{:08b?}", [10, 20, 30]);
| - ^ expected `'}'` in format string
| |
| because of this opening brace
|
= note: if you intended to print `{`, you can escape it using `{{`
error: could not compile `bug` (bin "bug") due to previous error