rust/tests/ui/fmt/format-string-wrong-order.rs
Mads Ravn f922c8395d PR fixing wrong order of format parameters in strings. Issue #106572
Adding

Adding

Fixing small issues for PR

Adding tests

Removing unused binding

Changing the wording on note

Fixing PR comment
2023-02-02 12:56:04 +01:00

16 lines
650 B
Rust

fn main() {
let bar = 3;
format!("{?:}", bar);
//~^ ERROR invalid format string: expected format parameter to occur after `:`
format!("{?:bar}");
//~^ ERROR invalid format string: expected format parameter to occur after `:`
format!("{?:?}", bar);
//~^ ERROR invalid format string: expected format parameter to occur after `:`
format!("{??}", bar);
//~^ ERROR invalid format string: expected `'}'`, found `'?'`
format!("{?;bar}");
//~^ ERROR invalid format string: expected `'}'`, found `'?'`
format!("{?:#?}", bar);
//~^ ERROR invalid format string: expected format parameter to occur after `:`
}