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`.
This commit is contained in:
Yuki Okushi 2022-07-27 11:52:54 +09:00 committed by GitHub
commit 181bf05d86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View File

@ -1485,6 +1485,7 @@ fn init_id_map() -> FxHashMap<Cow<'static, str>, usize> {
map.insert("synthetic-implementations-list".into(), 1);
map.insert("blanket-implementations-list".into(), 1);
map.insert("deref-methods".into(), 1);
map.insert("layout".into(), 1);
map
}

View File

@ -1880,7 +1880,11 @@ fn document_type_layout(w: &mut Buffer, cx: &Context<'_>, ty_def_id: DefId) {
return;
}
writeln!(w, "<h2 class=\"small-section-header\">Layout</h2>");
writeln!(
w,
"<h2 id=\"layout\" class=\"small-section-header\"> \
Layout<a href=\"#layout\" class=\"anchor\"></a></h2>"
);
writeln!(w, "<div class=\"docblock\">");
let tcx = cx.tcx();

View File

@ -2,6 +2,7 @@
// @has type_layout/struct.Foo.html 'Size: '
// @has - ' bytes'
// @has - '//*[@id="layout"]/a[@href="#layout"]' ''
pub struct Foo {
pub a: usize,
b: Vec<String>,