Skip to content

Commit 75fedfc

Browse files
Correctly get complete intra-doc link data
1 parent 35936c4 commit 75fedfc

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/librustdoc/passes/lint/redundant_explicit_links.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fn check_redundant_explicit_link<'md>(
9090
) -> Option<()> {
9191
let mut broken_line_callback = |link: BrokenLink<'md>| Some((link.reference, "".into()));
9292
let mut offset_iter = Parser::new_with_broken_link_callback(
93-
&doc,
93+
doc,
9494
main_body_opts(),
9595
Some(&mut broken_line_callback),
9696
)
@@ -264,6 +264,7 @@ fn collect_link_data(offset_iter: &mut OffsetIter<'_, '_>) -> LinkData {
264264
let mut resolvable_link = None;
265265
let mut resolvable_link_range = None;
266266
let mut display_link = String::new();
267+
let mut is_resolvable = true;
267268

268269
while let Some((event, range)) = offset_iter.next() {
269270
match event {
@@ -281,13 +282,23 @@ fn collect_link_data(offset_iter: &mut OffsetIter<'_, '_>) -> LinkData {
281282
resolvable_link = Some(code);
282283
resolvable_link_range = Some(range);
283284
}
285+
Event::Start(_) => {
286+
// If there is anything besides backticks, it's not considered as an intra-doc link
287+
// so we ignore it.
288+
is_resolvable = false;
289+
}
284290
Event::End(_) => {
285291
break;
286292
}
287293
_ => {}
288294
}
289295
}
290296

297+
if !is_resolvable {
298+
resolvable_link_range = None;
299+
resolvable_link = None;
300+
}
301+
291302
LinkData { resolvable_link, resolvable_link_range, display_link }
292303
}
293304

0 commit comments

Comments
 (0)