Skip to content

Commit

Permalink
Auto merge of #3510 - phansch:fix_doc_markdown_mixed_case, r=flip1995
Browse files Browse the repository at this point in the history
Fix doc_markdown mixed case false positive

Fixes #2343
  • Loading branch information
bors committed Dec 12, 2018
2 parents f5d6aca + 785167e commit 8a14065
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions clippy_lints/src/doc.rs
Expand Up @@ -281,6 +281,10 @@ fn check_word(cx: &EarlyContext<'_>, word: &str, span: Span) {
s != "_" && !s.contains("\\_") && s.contains('_')
}

fn has_hyphen(s: &str) -> bool {
s != "-" && s.contains('-')
}

if let Ok(url) = Url::parse(word) {
// try to get around the fact that `foo::bar` parses as a valid URL
if !url.cannot_be_a_base() {
Expand All @@ -295,6 +299,11 @@ fn check_word(cx: &EarlyContext<'_>, word: &str, span: Span) {
}
}

// We assume that mixed-case words are not meant to be put inside bacticks. (Issue #2343)
if has_underscore(word) && has_hyphen(word) {
return;
}

if has_underscore(word) || word.contains("::") || is_camel_case(word) {
span_lint(
cx,
Expand Down
4 changes: 4 additions & 0 deletions tests/ui/doc.rs
Expand Up @@ -177,3 +177,7 @@ fn issue_1832() {}

/// Ok: CamelCase (It should not be surrounded by backticks)
fn issue_2395() {}

/// This should not cause the lint to trigger:
/// #REQ-data-family.lint_partof_exists
fn issue_2343() {}

0 comments on commit 8a14065

Please sign in to comment.