Skip to content

Commit 7787236

Browse files
committed
Fix doc_markdown mixed case false positive
1 parent 2f467ac commit 7787236

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

clippy_lints/src/doc.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ fn check_word(cx: &EarlyContext<'_>, word: &str, span: Span) {
281281
s != "_" && !s.contains("\\_") && s.contains('_')
282282
}
283283

284+
fn has_hyphen(s: &str) -> bool {
285+
s != "-" && s.contains('-')
286+
}
287+
284288
if let Ok(url) = Url::parse(word) {
285289
// try to get around the fact that `foo::bar` parses as a valid URL
286290
if !url.cannot_be_a_base() {
@@ -295,6 +299,11 @@ fn check_word(cx: &EarlyContext<'_>, word: &str, span: Span) {
295299
}
296300
}
297301

302+
// We assume that mixed-case words are not meant to be put inside bacticks. (Issue #2343)
303+
if has_underscore(word) && has_hyphen(word) {
304+
return;
305+
}
306+
298307
if has_underscore(word) || word.contains("::") || is_camel_case(word) {
299308
span_lint(
300309
cx,

tests/ui/doc.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,7 @@ fn issue_2395() {}
181181
/// An iterator over mycrate::Collection's values.
182182
/// It should not lint a `'static` lifetime in ticks.
183183
fn issue_2210() {}
184+
185+
/// This should not cause the lint to trigger:
186+
/// #REQ-data-family.lint_partof_exists
187+
fn issue_2343() {}

0 commit comments

Comments
 (0)