This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +63
-2
lines changed
tests/ui-toml/needless_raw_string_hashes_one_allowed Expand file tree Collapse file tree 5 files changed +63
-2
lines changed Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ impl EarlyLintPass for RawStrings {
108108 }
109109 }
110110
111- let req = {
111+ let mut req = {
112112 let mut following_quote = false ;
113113 let mut req = 0 ;
114114 // `once` so a raw string ending in hashes is still checked
@@ -136,7 +136,9 @@ impl EarlyLintPass for RawStrings {
136136 ControlFlow :: Continue ( num) | ControlFlow :: Break ( num) => num,
137137 }
138138 } ;
139-
139+ if self . allow_one_hash_in_raw_strings {
140+ req = req. max ( 1 ) ;
141+ }
140142 if req < max {
141143 span_lint_and_then (
142144 cx,
Original file line number Diff line number Diff line change 1+ allow-one-hash-in-raw-strings = true
Original file line number Diff line number Diff line change 1+ #![allow(clippy::no_effect, unused)]
2+ #![warn(clippy::needless_raw_string_hashes)]
3+
4+ fn main() {
5+ r#"\aaa"#;
6+ r#"\aaa"#;
7+ r#"Hello "world"!"#;
8+ r####" "### "## "# "####;
9+ }
Original file line number Diff line number Diff line change 1+ #![ allow( clippy:: no_effect, unused) ]
2+ #![ warn( clippy:: needless_raw_string_hashes) ]
3+
4+ fn main ( ) {
5+ r#"\aaa"# ;
6+ r##"\aaa"## ;
7+ r##"Hello "world"!"## ;
8+ r######" "### "## "# "###### ;
9+ }
Original file line number Diff line number Diff line change 1+ error: unnecessary hashes around raw string literal
2+ --> tests/ui-toml/needless_raw_string_hashes_one_allowed/needless_raw_string_hashes.rs:6:5
3+ |
4+ LL | r##"\aaa"##;
5+ | ^^^^^^^^^^^
6+ |
7+ = note: `-D clippy::needless-raw-string-hashes` implied by `-D warnings`
8+ = help: to override `-D warnings` add `#[allow(clippy::needless_raw_string_hashes)]`
9+ help: remove one hash from both sides of the string literal
10+ |
11+ LL - r##"\aaa"##;
12+ LL + r#"\aaa"#;
13+ |
14+
15+ error: unnecessary hashes around raw string literal
16+ --> tests/ui-toml/needless_raw_string_hashes_one_allowed/needless_raw_string_hashes.rs:7:5
17+ |
18+ LL | r##"Hello "world"!"##;
19+ | ^^^^^^^^^^^^^^^^^^^^^
20+ |
21+ help: remove one hash from both sides of the string literal
22+ |
23+ LL - r##"Hello "world"!"##;
24+ LL + r#"Hello "world"!"#;
25+ |
26+
27+ error: unnecessary hashes around raw string literal
28+ --> tests/ui-toml/needless_raw_string_hashes_one_allowed/needless_raw_string_hashes.rs:8:5
29+ |
30+ LL | r######" "### "## "# "######;
31+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32+ |
33+ help: remove 2 hashes from both sides of the string literal
34+ |
35+ LL - r######" "### "## "# "######;
36+ LL + r####" "### "## "# "####;
37+ |
38+
39+ error: aborting due to 3 previous errors
40+
You can’t perform that action at this time.
0 commit comments