From f16da4fddae85c73f088fdc38151eb69b1caffc3 Mon Sep 17 00:00:00 2001 From: mcarton Date: Fri, 1 Apr 2016 17:24:55 +0200 Subject: [PATCH 1/2] Fix false positive with `DOC_MARKDOWN` and links --- src/doc.rs | 9 +++++++-- tests/compile-fail/doc.rs | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/doc.rs b/src/doc.rs index 5637fb2cefb..9a6a86d4140 100644 --- a/src/doc.rs +++ b/src/doc.rs @@ -69,7 +69,7 @@ fn collect_doc(attrs: &[ast::Attribute]) -> (Cow, Option) { let (doc, span) = doc_attrs.next().unwrap_or_else(|| unreachable!()); (doc.into(), Some(span)) } - _ => (doc_attrs.map(|s| s.0).collect::().into(), None), + _ => (doc_attrs.map(|s| format!("{}\n", s.0)).collect::().into(), None), } } @@ -124,9 +124,14 @@ fn check_word(cx: &EarlyContext, word: &str, span: Span) { s != "_" && !s.contains("\\_") && s.contains('_') } + // Something with a `/` might be a link, don’t warn (see #823): + if word.contains('/') { + return; + } + // Trim punctuation as in `some comment (see foo::bar).` // ^^ - // Or even as `_foo bar_` which is emphasized. + // Or even as in `_foo bar_` which is emphasized. let word = word.trim_matches(|c: char| !c.is_alphanumeric()); if has_underscore(word) || word.contains("::") || is_camel_case(word) { diff --git a/tests/compile-fail/doc.rs b/tests/compile-fail/doc.rs index eecf5e0b206..a7b316e1f82 100755 --- a/tests/compile-fail/doc.rs +++ b/tests/compile-fail/doc.rs @@ -29,6 +29,11 @@ fn multiline_ticks() { fn test_emphasis() { } +/// This test has [a link with underscores][chunked-example] inside it. See #823. +/// See also [the issue tracker](https://github.com/Manishearth/rust-clippy/search?q=doc_markdown&type=Issues). +/// +/// [chunked-example]: http://en.wikipedia.org/wiki/Chunked_transfer_encoding#Example + /// The `main` function is the entry point of the program. Here it only calls the `foo_bar` and /// `multiline_ticks` functions. fn main() { From f8acc8344933d2abab88f77c2b8d7cc7a6498ed9 Mon Sep 17 00:00:00 2001 From: mcarton Date: Fri, 1 Apr 2016 17:48:13 +0200 Subject: [PATCH 2/2] Rustup to 1.9.0-nightly (e1195c24b 2016-03-31) This does not require a version bump, it only affects tests. --- tests/compile-fail/transmute.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/compile-fail/transmute.rs b/tests/compile-fail/transmute.rs index 5bae2c72643..cd86281d8f2 100644 --- a/tests/compile-fail/transmute.rs +++ b/tests/compile-fail/transmute.rs @@ -62,19 +62,19 @@ unsafe fn _ptr_to_ref(p: *const T, m: *mut T, o: *const U, om: *mut U) { fn useless() { unsafe { let _: Vec = core::intrinsics::transmute(my_vec()); - //~^ ERROR transmute from a type (`collections::vec::Vec`) to itself + //~^ ERROR transmute from a type (`std::vec::Vec`) to itself let _: Vec = core::mem::transmute(my_vec()); - //~^ ERROR transmute from a type (`collections::vec::Vec`) to itself + //~^ ERROR transmute from a type (`std::vec::Vec`) to itself let _: Vec = std::intrinsics::transmute(my_vec()); - //~^ ERROR transmute from a type (`collections::vec::Vec`) to itself + //~^ ERROR transmute from a type (`std::vec::Vec`) to itself let _: Vec = std::mem::transmute(my_vec()); - //~^ ERROR transmute from a type (`collections::vec::Vec`) to itself + //~^ ERROR transmute from a type (`std::vec::Vec`) to itself let _: Vec = my_transmute(my_vec()); - //~^ ERROR transmute from a type (`collections::vec::Vec`) to itself + //~^ ERROR transmute from a type (`std::vec::Vec`) to itself let _: Vec = core::intrinsics::transmute(my_vec()); let _: Vec = core::mem::transmute(my_vec()); @@ -92,16 +92,16 @@ fn crosspointer() { unsafe { let _: Vec = core::intrinsics::transmute(vec_const_ptr); - //~^ ERROR transmute from a type (`*const collections::vec::Vec`) to the type that it points to (`collections::vec::Vec`) + //~^ ERROR transmute from a type (`*const std::vec::Vec`) to the type that it points to (`std::vec::Vec`) let _: Vec = core::intrinsics::transmute(vec_mut_ptr); - //~^ ERROR transmute from a type (`*mut collections::vec::Vec`) to the type that it points to (`collections::vec::Vec`) + //~^ ERROR transmute from a type (`*mut std::vec::Vec`) to the type that it points to (`std::vec::Vec`) let _: *const Vec = core::intrinsics::transmute(my_vec()); - //~^ ERROR transmute from a type (`collections::vec::Vec`) to a pointer to that type (`*const collections::vec::Vec`) + //~^ ERROR transmute from a type (`std::vec::Vec`) to a pointer to that type (`*const std::vec::Vec`) let _: *mut Vec = core::intrinsics::transmute(my_vec()); - //~^ ERROR transmute from a type (`collections::vec::Vec`) to a pointer to that type (`*mut collections::vec::Vec`) + //~^ ERROR transmute from a type (`std::vec::Vec`) to a pointer to that type (`*mut std::vec::Vec`) } }