diff options
Diffstat (limited to 'clippy_lints/src/doc.rs')
| -rw-r--r-- | clippy_lints/src/doc.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index 55d2265125e..75873fd7c1c 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -406,6 +406,15 @@ struct DocHeaders { } fn check_attrs<'a>(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, attrs: &'a [Attribute]) -> DocHeaders { + use pulldown_cmark::{BrokenLink, CowStr, Options}; + /// We don't want the parser to choke on intra doc links. Since we don't + /// actually care about rendering them, just pretend that all broken links are + /// point to a fake address. + #[allow(clippy::unnecessary_wraps)] // we're following a type signature + fn fake_broken_link_callback<'a>(_: BrokenLink<'_>) -> Option<(CowStr<'a>, CowStr<'a>)> { + Some(("fake".into(), "fake".into())) + } + let mut doc = String::new(); let mut spans = vec![]; @@ -440,7 +449,10 @@ fn check_attrs<'a>(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, attrs }; } - let parser = pulldown_cmark::Parser::new(&doc).into_offset_iter(); + let mut cb = fake_broken_link_callback; + + let parser = + pulldown_cmark::Parser::new_with_broken_link_callback(&doc, Options::empty(), Some(&mut cb)).into_offset_iter(); // Iterate over all `Events` and combine consecutive events into one let events = parser.coalesce(|previous, current| { use pulldown_cmark::Event::Text; |
