Don't use link.span yet

This shows the span of the _whole_ link, including the brackets.
But rustdoc only wants to warn about the link text.
This commit is contained in:
Joshua Nelson 2020-09-13 20:56:33 -04:00
parent e4c28bf61a
commit f7983cae70
2 changed files with 5 additions and 3 deletions

View file

@ -1088,7 +1088,9 @@ pub fn markdown_links(md: &str) -> Vec<(String, Option<Range<usize>>)> {
};
let mut push = |link: BrokenLink<'_>| {
shortcut_links.push((link.reference.to_owned(), Some(link.span)));
// FIXME: use `link.span` instead of `locate`
// (doing it now includes the `[]` as well as the text)
shortcut_links.push((link.reference.to_owned(), locate(link.reference)));
None
};
let p = Parser::new_with_broken_link_callback(md, opts(), Some(&mut push));

View file

@ -1,8 +1,8 @@
warning: `with#anchor#error` contains multiple anchors
--> $DIR/intra-link-double-anchor.rs:5:10
--> $DIR/intra-link-double-anchor.rs:5:18
|
LL | /// docs [label][with#anchor#error]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ contains invalid anchor
| ^^^^^^^^^^^^^^^^^ contains invalid anchor
|
= note: `#[warn(broken_intra_doc_links)]` on by default