rust-clippy/tests/ui/write_literal_2.rs
Jason Newcomb a7fa2a6fa8
Add suggestion to write_literal and print_literal
Don't lint on a mixture of raw and regular strings
Fix spans in format strings
2021-03-16 12:13:46 -04:00

27 lines
540 B
Rust

#![allow(unused_must_use)]
#![warn(clippy::write_literal)]
use std::io::Write;
fn main() {
let mut v = Vec::new();
writeln!(&mut v, "{}", "{hello}");
writeln!(&mut v, r"{}", r"{hello}");
writeln!(&mut v, "{}", '\'');
writeln!(&mut v, "{}", '"');
writeln!(&mut v, r"{}", '"'); // don't lint
writeln!(&mut v, r"{}", '\'');
writeln!(
&mut v,
"some {}",
"hello \
world!"
);
writeln!(
&mut v,
"some {}\
{} \\ {}",
"1", "2", "3",
);
}