mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
Don't lint autolinks in doc_markdown
This commit is contained in:
parent
06280e838b
commit
e40c270d4f
3 changed files with 23 additions and 2 deletions
|
@ -195,16 +195,26 @@ fn check_doc<'a, Events: Iterator<Item = (usize, pulldown_cmark::Event<'a>)>>(
|
|||
use pulldown_cmark::Tag::*;
|
||||
|
||||
let mut in_code = false;
|
||||
let mut in_link = None;
|
||||
|
||||
for (offset, event) in docs {
|
||||
match event {
|
||||
Start(CodeBlock(_)) | Start(Code) => in_code = true,
|
||||
End(CodeBlock(_)) | End(Code) => in_code = false,
|
||||
Start(_tag) | End(_tag) => (), // We don't care about other tags
|
||||
Start(Link(link, _)) => in_link = Some(link),
|
||||
End(Link(_, _)) => in_link = None,
|
||||
Start(_tag) | End(_tag) => (), // We don't care about other tags
|
||||
Html(_html) | InlineHtml(_html) => (), // HTML is weird, just ignore it
|
||||
SoftBreak => (),
|
||||
HardBreak => (),
|
||||
FootnoteReference(text) | Text(text) => {
|
||||
if Some(&text) == in_link.as_ref() {
|
||||
// Probably a link of the form `<http://example.com>`
|
||||
// Which are represented as a link to "http://example.com" with
|
||||
// text "http://example.com" by pulldown-cmark
|
||||
continue;
|
||||
}
|
||||
|
||||
if !in_code {
|
||||
let index = match spans.binary_search_by(|c| c.0.cmp(&offset)) {
|
||||
Ok(o) => o,
|
||||
|
|
|
@ -159,3 +159,8 @@ fn issue_1469() {}
|
|||
*This would also be an error under a strict common mark interpretation
|
||||
*/
|
||||
fn issue_1920() {}
|
||||
|
||||
/// Ok: <http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels>
|
||||
///
|
||||
/// Not ok: http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels
|
||||
fn issue_1832() {}
|
||||
|
|
|
@ -156,5 +156,11 @@ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the doc
|
|||
138 | /// be_sure_we_got_to_the_end_of_it
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 26 previous errors
|
||||
error: you should put `http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels` between ticks in the documentation
|
||||
--> $DIR/doc.rs:165:13
|
||||
|
|
||||
165 | /// Not ok: http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 27 previous errors
|
||||
|
||||
|
|
Loading…
Reference in a new issue