File tree 5 files changed +63
-2
lines changed
tests/ui-toml/needless_raw_string_hashes_one_allowed
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 {
108
108
}
109
109
}
110
110
111
- let req = {
111
+ let mut req = {
112
112
let mut following_quote = false ;
113
113
let mut req = 0 ;
114
114
// `once` so a raw string ending in hashes is still checked
@@ -136,7 +136,9 @@ impl EarlyLintPass for RawStrings {
136
136
ControlFlow :: Continue ( num) | ControlFlow :: Break ( num) => num,
137
137
}
138
138
} ;
139
-
139
+ if self . allow_one_hash_in_raw_strings {
140
+ req = req. max ( 1 ) ;
141
+ }
140
142
if req < max {
141
143
span_lint_and_then (
142
144
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