Auto merge of #13504 - samueltardieu:needless-raw-strings, r=Alexendoo
Check for needless raw strings in `format_args!()` template as well changelog: [`needless_raw_strings`, `needless_raw_string_hashes`]: check `format_args!()` template as well Fix #13503
This commit is contained in:
commit
1f8f982f22
11 changed files with 236 additions and 98 deletions
|
|
@ -20,7 +20,7 @@ fn book() {
|
|||
|
||||
let configs = metadata().map(|conf| conf.to_markdown_paragraph()).join("\n");
|
||||
let expected = format!(
|
||||
r#"<!--
|
||||
r"<!--
|
||||
This file is generated by `cargo bless --test config-metadata`.
|
||||
Please use that command to update the file and do not edit it by hand.
|
||||
-->
|
||||
|
|
@ -33,7 +33,7 @@ and lints affected.
|
|||
---
|
||||
|
||||
{}
|
||||
"#,
|
||||
",
|
||||
configs.trim(),
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,3 +22,12 @@ fn main() {
|
|||
b"no hashes";
|
||||
c"no hashes";
|
||||
}
|
||||
|
||||
fn issue_13503() {
|
||||
println!("SELECT * FROM posts");
|
||||
println!("SELECT * FROM posts");
|
||||
println!(r##"SELECT * FROM "posts""##);
|
||||
|
||||
// Test arguments as well
|
||||
println!("{}", "foobar".len());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,3 +22,12 @@ fn main() {
|
|||
br"no hashes";
|
||||
cr"no hashes";
|
||||
}
|
||||
|
||||
fn issue_13503() {
|
||||
println!(r"SELECT * FROM posts");
|
||||
println!(r#"SELECT * FROM posts"#);
|
||||
println!(r##"SELECT * FROM "posts""##);
|
||||
|
||||
// Test arguments as well
|
||||
println!("{}", r"foobar".len());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,5 +91,41 @@ LL - cr"no hashes";
|
|||
LL + c"no hashes";
|
||||
|
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
error: unnecessary raw string literal
|
||||
--> tests/ui/needless_raw_string.rs:27:14
|
||||
|
|
||||
LL | println!(r"SELECT * FROM posts");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: use a plain string literal instead
|
||||
|
|
||||
LL - println!(r"SELECT * FROM posts");
|
||||
LL + println!("SELECT * FROM posts");
|
||||
|
|
||||
|
||||
error: unnecessary raw string literal
|
||||
--> tests/ui/needless_raw_string.rs:28:14
|
||||
|
|
||||
LL | println!(r#"SELECT * FROM posts"#);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: use a plain string literal instead
|
||||
|
|
||||
LL - println!(r#"SELECT * FROM posts"#);
|
||||
LL + println!("SELECT * FROM posts");
|
||||
|
|
||||
|
||||
error: unnecessary raw string literal
|
||||
--> tests/ui/needless_raw_string.rs:32:20
|
||||
|
|
||||
LL | println!("{}", r"foobar".len());
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
help: use a plain string literal instead
|
||||
|
|
||||
LL - println!("{}", r"foobar".len());
|
||||
LL + println!("{}", "foobar".len());
|
||||
|
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -24,3 +24,13 @@ fn main() {
|
|||
r"rust";
|
||||
r"hello world";
|
||||
}
|
||||
|
||||
fn issue_13503() {
|
||||
println!(r"SELECT * FROM posts");
|
||||
println!(r"SELECT * FROM posts");
|
||||
println!(r#"SELECT * FROM "posts""#);
|
||||
println!(r#"SELECT * FROM "posts""#);
|
||||
|
||||
// Test arguments as well
|
||||
println!("{}", r"foobar".len());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,3 +24,13 @@ fn main() {
|
|||
r###"rust"###;
|
||||
r#"hello world"#;
|
||||
}
|
||||
|
||||
fn issue_13503() {
|
||||
println!(r"SELECT * FROM posts");
|
||||
println!(r#"SELECT * FROM posts"#);
|
||||
println!(r##"SELECT * FROM "posts""##);
|
||||
println!(r##"SELECT * FROM "posts""##);
|
||||
|
||||
// Test arguments as well
|
||||
println!("{}", r"foobar".len());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -187,5 +187,41 @@ LL - r#"hello world"#;
|
|||
LL + r"hello world";
|
||||
|
|
||||
|
||||
error: aborting due to 15 previous errors
|
||||
error: unnecessary hashes around raw string literal
|
||||
--> tests/ui/needless_raw_string_hashes.rs:30:14
|
||||
|
|
||||
LL | println!(r#"SELECT * FROM posts"#);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: remove all the hashes around the string literal
|
||||
|
|
||||
LL - println!(r#"SELECT * FROM posts"#);
|
||||
LL + println!(r"SELECT * FROM posts");
|
||||
|
|
||||
|
||||
error: unnecessary hashes around raw string literal
|
||||
--> tests/ui/needless_raw_string_hashes.rs:31:14
|
||||
|
|
||||
LL | println!(r##"SELECT * FROM "posts""##);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: remove one hash from both sides of the string literal
|
||||
|
|
||||
LL - println!(r##"SELECT * FROM "posts""##);
|
||||
LL + println!(r#"SELECT * FROM "posts""#);
|
||||
|
|
||||
|
||||
error: unnecessary hashes around raw string literal
|
||||
--> tests/ui/needless_raw_string_hashes.rs:32:14
|
||||
|
|
||||
LL | println!(r##"SELECT * FROM "posts""##);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: remove one hash from both sides of the string literal
|
||||
|
|
||||
LL - println!(r##"SELECT * FROM "posts""##);
|
||||
LL + println!(r#"SELECT * FROM "posts""#);
|
||||
|
|
||||
|
||||
error: aborting due to 18 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue