Skip to content

Commit 181bf05

Browse files
authored
Rollup merge of #99700 - est31:rustdoc_layout_heading, r=GuillaumeGomez
Add a clickable link to the layout section The layout section (activated by `--show-type-layout`) is currently not linkable to (outside of chrome's link to text feature). This PR makes it linkable via `#layout`.
2 parents 3ca1c31 + 15db418 commit 181bf05

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/librustdoc/html/markdown.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,7 @@ fn init_id_map() -> FxHashMap<Cow<'static, str>, usize> {
14851485
map.insert("synthetic-implementations-list".into(), 1);
14861486
map.insert("blanket-implementations-list".into(), 1);
14871487
map.insert("deref-methods".into(), 1);
1488+
map.insert("layout".into(), 1);
14881489
map
14891490
}
14901491

src/librustdoc/html/render/print_item.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1880,7 +1880,11 @@ fn document_type_layout(w: &mut Buffer, cx: &Context<'_>, ty_def_id: DefId) {
18801880
return;
18811881
}
18821882

1883-
writeln!(w, "<h2 class=\"small-section-header\">Layout</h2>");
1883+
writeln!(
1884+
w,
1885+
"<h2 id=\"layout\" class=\"small-section-header\"> \
1886+
Layout<a href=\"#layout\" class=\"anchor\"></a></h2>"
1887+
);
18841888
writeln!(w, "<div class=\"docblock\">");
18851889

18861890
let tcx = cx.tcx();

src/test/rustdoc/type-layout.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
// @has type_layout/struct.Foo.html 'Size: '
44
// @has - ' bytes'
5+
// @has - '//*[@id="layout"]/a[@href="#layout"]' ''
56
pub struct Foo {
67
pub a: usize,
78
b: Vec<String>,

0 commit comments

Comments
 (0)