rust/tests/ui/write_literal_2.rs

36 lines
804 B
Rust
Raw Normal View History

2023-07-27 06:40:22 -05:00
//@no-rustfix: overlapping suggestions
#![allow(unused_must_use)]
#![warn(clippy::needless_raw_strings, clippy::write_literal)]
use std::io::Write;
fn main() {
let mut v = Vec::new();
writeln!(v, "{}", "{hello}");
writeln!(v, r"{}", r"{hello}");
writeln!(v, "{}", '\'');
writeln!(v, "{}", '"');
2022-08-30 07:20:49 -05:00
writeln!(v, r"{}", '"');
writeln!(v, r"{}", '\'');
writeln!(
v,
"some {}",
"hello \
world!"
);
writeln!(
v,
"some {}\
{} \\ {}",
"1", "2", "3",
);
2022-08-30 07:20:49 -05:00
writeln!(v, "{}", "\\");
writeln!(v, r"{}", "\\");
writeln!(v, r#"{}"#, "\\");
writeln!(v, "{}", r"\");
writeln!(v, "{}", "\r");
writeln!(v, r#"{}{}"#, '#', '"'); // hard mode
writeln!(v, r"{}", "\r"); // should not lint
}