Skip to content

Fix false positive with DOC_MARKDOWN and links + rustup #824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn collect_doc(attrs: &[ast::Attribute]) -> (Cow<str>, Option<Span>) {
let (doc, span) = doc_attrs.next().unwrap_or_else(|| unreachable!());
(doc.into(), Some(span))
}
_ => (doc_attrs.map(|s| s.0).collect::<String>().into(), None),
_ => (doc_attrs.map(|s| format!("{}\n", s.0)).collect::<String>().into(), None),
}
}

Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions tests/compile-fail/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
18 changes: 9 additions & 9 deletions tests/compile-fail/transmute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,19 @@ unsafe fn _ptr_to_ref<T, U>(p: *const T, m: *mut T, o: *const U, om: *mut U) {
fn useless() {
unsafe {
let _: Vec<i32> = core::intrinsics::transmute(my_vec());
//~^ ERROR transmute from a type (`collections::vec::Vec<i32>`) to itself
//~^ ERROR transmute from a type (`std::vec::Vec<i32>`) to itself

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

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

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

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

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

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

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

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

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

Expand Down