Skip to content

Commit 5fcd2f7

Browse files
committed
Add a clickable link to the layout section
1 parent 2a990f7 commit 5fcd2f7

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
@@ -1869,7 +1869,11 @@ fn document_type_layout(w: &mut Buffer, cx: &Context<'_>, ty_def_id: DefId) {
18691869
return;
18701870
}
18711871

1872-
writeln!(w, "<h2 class=\"small-section-header\">Layout</h2>");
1872+
writeln!(
1873+
w,
1874+
"<h2 id=\"layout\" class=\"small-section-header\"> \
1875+
Layout<a href=\"#layout\" class=\"anchor\"></a></h2>"
1876+
);
18731877
writeln!(w, "<div class=\"docblock\">");
18741878

18751879
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+
// @matches - '<h2 id="layout".+Layout.+a href="#layout" class="anchor">'
56
pub struct Foo {
67
pub a: usize,
78
b: Vec<String>,

0 commit comments

Comments
 (0)