Skip to content

Commit 4d143d7

Browse files
committed
Auto merge of rust-lang#11518 - mojave2:issue-11420, r=Alexendoo
fix FP with needless_raw_string_hashes changelog: Fix [`needless_raw_string_hashes`]: Continue the lint checking of raw string when `needless_raw_strings` is allowed. fix rust-lang#11420
2 parents c556695 + 5b790ff commit 4d143d7

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

clippy_lints/src/attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ fn check_should_panic_reason(cx: &LateContext<'_>, attr: &Attribute) {
616616
attr.span,
617617
"#[should_panic] attribute without a reason",
618618
"consider specifying the expected panic",
619-
r#"#[should_panic(expected = /* panic message */)]"#.into(),
619+
"#[should_panic(expected = /* panic message */)]".into(),
620620
Applicability::HasPlaceholders,
621621
);
622622
}

clippy_lints/src/raw_strings.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ impl EarlyLintPass for RawStrings {
9696
);
9797
},
9898
);
99-
100-
return;
99+
if !matches!(cx.get_lint_level(NEEDLESS_RAW_STRINGS), rustc_lint::Allow) {
100+
return;
101+
}
101102
}
102103

103104
let req = {

tests/ui/needless_raw_string_hashes.fixed

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ fn main() {
2121
multiline
2222
string
2323
";
24+
25+
r"rust";
26+
r"hello world";
2427
}

tests/ui/needless_raw_string_hashes.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ fn main() {
2121
multiline
2222
string
2323
"#;
24+
25+
r###"rust"###;
26+
r#"hello world"#;
2427
}

tests/ui/needless_raw_string_hashes.stderr

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,29 @@ LL | string
163163
LL ~ ";
164164
|
165165

166-
error: aborting due to 13 previous errors
166+
error: unnecessary hashes around raw string literal
167+
--> $DIR/needless_raw_string_hashes.rs:25:5
168+
|
169+
LL | r###"rust"###;
170+
| ^^^^^^^^^^^^^
171+
|
172+
help: remove all the hashes around the literal
173+
|
174+
LL - r###"rust"###;
175+
LL + r"rust";
176+
|
177+
178+
error: unnecessary hashes around raw string literal
179+
--> $DIR/needless_raw_string_hashes.rs:26:5
180+
|
181+
LL | r#"hello world"#;
182+
| ^^^^^^^^^^^^^^^^
183+
|
184+
help: remove all the hashes around the literal
185+
|
186+
LL - r#"hello world"#;
187+
LL + r"hello world";
188+
|
189+
190+
error: aborting due to 15 previous errors
167191

0 commit comments

Comments
 (0)