Skip to content

Commit 833b33c

Browse files
committed
Merge pull request #824 from mcarton/doc
Fix false positive with `DOC_MARKDOWN` and links + rustup
2 parents 8bfe38c + f8acc83 commit 833b33c

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
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() {

tests/compile-fail/transmute.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,19 @@ unsafe fn _ptr_to_ref<T, U>(p: *const T, m: *mut T, o: *const U, om: *mut U) {
6262
fn useless() {
6363
unsafe {
6464
let _: Vec<i32> = core::intrinsics::transmute(my_vec());
65-
//~^ ERROR transmute from a type (`collections::vec::Vec<i32>`) to itself
65+
//~^ ERROR transmute from a type (`std::vec::Vec<i32>`) to itself
6666

6767
let _: Vec<i32> = core::mem::transmute(my_vec());
68-
//~^ ERROR transmute from a type (`collections::vec::Vec<i32>`) to itself
68+
//~^ ERROR transmute from a type (`std::vec::Vec<i32>`) to itself
6969

7070
let _: Vec<i32> = std::intrinsics::transmute(my_vec());
71-
//~^ ERROR transmute from a type (`collections::vec::Vec<i32>`) to itself
71+
//~^ ERROR transmute from a type (`std::vec::Vec<i32>`) to itself
7272

7373
let _: Vec<i32> = std::mem::transmute(my_vec());
74-
//~^ ERROR transmute from a type (`collections::vec::Vec<i32>`) to itself
74+
//~^ ERROR transmute from a type (`std::vec::Vec<i32>`) to itself
7575

7676
let _: Vec<i32> = my_transmute(my_vec());
77-
//~^ ERROR transmute from a type (`collections::vec::Vec<i32>`) to itself
77+
//~^ ERROR transmute from a type (`std::vec::Vec<i32>`) to itself
7878

7979
let _: Vec<u32> = core::intrinsics::transmute(my_vec());
8080
let _: Vec<u32> = core::mem::transmute(my_vec());
@@ -92,16 +92,16 @@ fn crosspointer() {
9292

9393
unsafe {
9494
let _: Vec<i32> = core::intrinsics::transmute(vec_const_ptr);
95-
//~^ ERROR transmute from a type (`*const collections::vec::Vec<i32>`) to the type that it points to (`collections::vec::Vec<i32>`)
95+
//~^ ERROR transmute from a type (`*const std::vec::Vec<i32>`) to the type that it points to (`std::vec::Vec<i32>`)
9696

9797
let _: Vec<i32> = core::intrinsics::transmute(vec_mut_ptr);
98-
//~^ ERROR transmute from a type (`*mut collections::vec::Vec<i32>`) to the type that it points to (`collections::vec::Vec<i32>`)
98+
//~^ ERROR transmute from a type (`*mut std::vec::Vec<i32>`) to the type that it points to (`std::vec::Vec<i32>`)
9999

100100
let _: *const Vec<i32> = core::intrinsics::transmute(my_vec());
101-
//~^ ERROR transmute from a type (`collections::vec::Vec<i32>`) to a pointer to that type (`*const collections::vec::Vec<i32>`)
101+
//~^ ERROR transmute from a type (`std::vec::Vec<i32>`) to a pointer to that type (`*const std::vec::Vec<i32>`)
102102

103103
let _: *mut Vec<i32> = core::intrinsics::transmute(my_vec());
104-
//~^ ERROR transmute from a type (`collections::vec::Vec<i32>`) to a pointer to that type (`*mut collections::vec::Vec<i32>`)
104+
//~^ ERROR transmute from a type (`std::vec::Vec<i32>`) to a pointer to that type (`*mut std::vec::Vec<i32>`)
105105
}
106106
}
107107

0 commit comments

Comments
 (0)