rust/tests/ui/macros/missing-writer.rs
James Dietz ff88787ff0 check for write macro and write_fmt with err msg
added ui test
blessed stderrs
fixed typo
reblessed
2023-03-27 21:01:23 -04:00

18 lines
793 B
Rust

// Check error for missing writer in writeln! and write! macro
fn main() {
let x = 1;
let y = 2;
write!("{}_{}", x, y);
//~^ ERROR format argument must be a string literal
//~| HELP you might be missing a string literal to format with
//~| ERROR cannot write into `&'static str`
//~| NOTE must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method
//~| HELP a writer is needed before this format string
writeln!("{}_{}", x, y);
//~^ ERROR format argument must be a string literal
//~| HELP you might be missing a string literal to format with
//~| ERROR cannot write into `&'static str`
//~| NOTE must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method
//~| HELP a writer is needed before this format string
}