Skip to content

Commit f16da4f

Browse files
committed
Fix false positive with DOC_MARKDOWN and links
1 parent 8bfe38c commit f16da4f

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/doc.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn collect_doc(attrs: &[ast::Attribute]) -> (Cow<str>, Option<Span>) {
6969
let (doc, span) = doc_attrs.next().unwrap_or_else(|| unreachable!());
7070
(doc.into(), Some(span))
7171
}
72-
_ => (doc_attrs.map(|s| s.0).collect::<String>().into(), None),
72+
_ => (doc_attrs.map(|s| format!("{}\n", s.0)).collect::<String>().into(), None),
7373
}
7474
}
7575

@@ -124,9 +124,14 @@ fn check_word(cx: &EarlyContext, word: &str, span: Span) {
124124
s != "_" && !s.contains("\\_") && s.contains('_')
125125
}
126126

127+
// Something with a `/` might be a link, don’t warn (see #823):
128+
if word.contains('/') {
129+
return;
130+
}
131+
127132
// Trim punctuation as in `some comment (see foo::bar).`
128133
// ^^
129-
// Or even as `_foo bar_` which is emphasized.
134+
// Or even as in `_foo bar_` which is emphasized.
130135
let word = word.trim_matches(|c: char| !c.is_alphanumeric());
131136

132137
if has_underscore(word) || word.contains("::") || is_camel_case(word) {

tests/compile-fail/doc.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ fn multiline_ticks() {
2929
fn test_emphasis() {
3030
}
3131

32+
/// This test has [a link with underscores][chunked-example] inside it. See #823.
33+
/// See also [the issue tracker](https://github.com/Manishearth/rust-clippy/search?q=doc_markdown&type=Issues).
34+
///
35+
/// [chunked-example]: http://en.wikipedia.org/wiki/Chunked_transfer_encoding#Example
36+
3237
/// The `main` function is the entry point of the program. Here it only calls the `foo_bar` and
3338
/// `multiline_ticks` functions.
3439
fn main() {

0 commit comments

Comments
 (0)