Skip to content

Commit

Permalink
fix FP with needless_raw_string_hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
kiscad committed Sep 17, 2023
1 parent f54275f commit 78c9798
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
5 changes: 3 additions & 2 deletions clippy_lints/src/raw_strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ impl EarlyLintPass for RawStrings {
);
},
);

return;
if !matches!(cx.get_lint_level(NEEDLESS_RAW_STRINGS), rustc_lint::Allow) {
return;
}
}

let req = {
Expand Down
3 changes: 3 additions & 0 deletions tests/ui/needless_raw_string_hashes.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ fn main() {
multiline
string
";

r"rust";
r"hello world";
}
3 changes: 3 additions & 0 deletions tests/ui/needless_raw_string_hashes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ fn main() {
multiline
string
"#;
r###"rust"###;
r#"hello world"#;
}
26 changes: 25 additions & 1 deletion tests/ui/needless_raw_string_hashes.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,29 @@ LL | string
LL ~ ";
|

error: aborting due to 13 previous errors
error: unnecessary hashes around raw string literal
--> $DIR/needless_raw_string_hashes.rs:25:5
|
LL | r###"rust"###;
| ^^^^^^^^^^^^^
|
help: remove all the hashes around the literal
|
LL - r###"rust"###;
LL + r"rust";
|

error: unnecessary hashes around raw string literal
--> $DIR/needless_raw_string_hashes.rs:26:5
|
LL | r#"hello world"#;
| ^^^^^^^^^^^^^^^^
|
help: remove all the hashes around the literal
|
LL - r#"hello world"#;
LL + r"hello world";
|

error: aborting due to 15 previous errors

0 comments on commit 78c9798

Please sign in to comment.