Skip to content

Commit e5ece90

Browse files
committed
Auto merge of rust-lang#119552 - krtab:dead_code_priv_mod_pub_field, r=cjgillot,saethlin
Replace visibility test with reachability test in dead code detection Fixes rust-lang#119545 Also included is a fix for an error now flagged by the lint
2 parents 02e11b9 + cbbb0ae commit e5ece90

File tree

5 files changed

+63
-2
lines changed

5 files changed

+63
-2
lines changed

Diff for: clippy_lints/src/raw_strings.rs

+4-2
Original file line numberDiff line numberDiff 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 numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
allow-one-hash-in-raw-strings = true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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 numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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 numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+

0 commit comments

Comments
 (0)