Skip to content

Commit 39e09ac

Browse files
authored
Rollup merge of rust-lang#109351 - GuillaumeGomez:no-footnote-in-summary, r=notriddle
rustdoc: Remove footnote references from doc summary Since it's one line, we don't have the footnote definition so it doesn't make sense to have the reference. Part of rust-lang#109024. r? `@notriddle`
2 parents fb4f015 + 5a752cd commit 39e09ac

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/librustdoc/html/markdown.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,15 @@ fn check_if_allowed_tag(t: &Tag<'_>) -> bool {
556556
}
557557

558558
fn is_forbidden_tag(t: &Tag<'_>) -> bool {
559-
matches!(t, Tag::CodeBlock(_) | Tag::Table(_) | Tag::TableHead | Tag::TableRow | Tag::TableCell)
559+
matches!(
560+
t,
561+
Tag::CodeBlock(_)
562+
| Tag::Table(_)
563+
| Tag::TableHead
564+
| Tag::TableRow
565+
| Tag::TableCell
566+
| Tag::FootnoteDefinition(_)
567+
)
560568
}
561569

562570
impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> {
@@ -589,6 +597,10 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> {
589597
is_start = false;
590598
check_if_allowed_tag(c)
591599
}
600+
Event::FootnoteReference(_) => {
601+
self.skipped_tags += 1;
602+
false
603+
}
592604
_ => true,
593605
};
594606
if !is_allowed_tag {

tests/rustdoc/footnote-in-summary.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// This test ensures that no footnote reference is generated inside
2+
// summary doc.
3+
4+
#![crate_name = "foo"]
5+
6+
// @has 'foo/index.html'
7+
// @has - '//*[@class="desc docblock-short"]' 'hello bla'
8+
// @!has - '//*[@class="desc docblock-short"]/sup' '1'
9+
10+
// @has 'foo/struct.S.html'
11+
// @has - '//*[@class="docblock"]//sup' '1'
12+
// @has - '//*[@class="docblock"]' 'hello 1 bla'
13+
14+
/// hello [^foot] bla
15+
///
16+
/// [^foot]: blabla
17+
pub struct S;

0 commit comments

Comments
 (0)