diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-03-28 17:40:51 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-28 17:40:51 +0100 |
| commit | cba164c518f80268ed01ab58adfbdbaba6072ae7 (patch) | |
| tree | af03b18d0023a9ea9f5982b268775a7dc590c1c5 /src | |
| parent | 1ec73f0c4c133290ca1ea8dc0297ba38c66ddc2b (diff) | |
| parent | f1cfbdbb9970890fc3b850037e84164a6b5c4ca0 (diff) | |
| download | rust-cba164c518f80268ed01ab58adfbdbaba6072ae7.tar.gz rust-cba164c518f80268ed01ab58adfbdbaba6072ae7.zip | |
Rollup merge of #123162 - GuillaumeGomez:fix-123158, r=notriddle
Correctly get complete intra-doc link data Fixes https://github.com/rust-lang/rust/issues/123158. The problem was that we didn't take into account cases where there would be content other than backticks into the intra doc link definition. r? `@notriddle`
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/passes/lint/redundant_explicit_links.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/librustdoc/passes/lint/redundant_explicit_links.rs b/src/librustdoc/passes/lint/redundant_explicit_links.rs index f7bc5464707..569c17ee36e 100644 --- a/src/librustdoc/passes/lint/redundant_explicit_links.rs +++ b/src/librustdoc/passes/lint/redundant_explicit_links.rs @@ -90,7 +90,7 @@ fn check_redundant_explicit_link<'md>( ) -> Option<()> { let mut broken_line_callback = |link: BrokenLink<'md>| Some((link.reference, "".into())); let mut offset_iter = Parser::new_with_broken_link_callback( - &doc, + doc, main_body_opts(), Some(&mut broken_line_callback), ) @@ -264,6 +264,7 @@ fn collect_link_data(offset_iter: &mut OffsetIter<'_, '_>) -> LinkData { let mut resolvable_link = None; let mut resolvable_link_range = None; let mut display_link = String::new(); + let mut is_resolvable = true; while let Some((event, range)) = offset_iter.next() { match event { @@ -281,6 +282,11 @@ fn collect_link_data(offset_iter: &mut OffsetIter<'_, '_>) -> LinkData { resolvable_link = Some(code); resolvable_link_range = Some(range); } + Event::Start(_) => { + // If there is anything besides backticks, it's not considered as an intra-doc link + // so we ignore it. + is_resolvable = false; + } Event::End(_) => { break; } @@ -288,6 +294,11 @@ fn collect_link_data(offset_iter: &mut OffsetIter<'_, '_>) -> LinkData { } } + if !is_resolvable { + resolvable_link_range = None; + resolvable_link = None; + } + LinkData { resolvable_link, resolvable_link_range, display_link } } |
