rust/tests/ui/fmt/format-string-wrong-order.rs
2024-10-14 23:22:51 +02:00

22 lines
993 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 `:`
format!("Hello {<5:}!", "x");
//~^ ERROR invalid format string: expected format parameter to occur after `:`
format!("Hello {^5:}!", "x");
//~^ ERROR invalid format string: expected format parameter to occur after `:`
format!("Hello {>5:}!", "x");
//~^ ERROR invalid format string: expected format parameter to occur after `:`
}