From 5fcd2f72feefa22e2c304301a67f448fde21bb7e Mon Sep 17 00:00:00 2001 From: est31 Date: Mon, 25 Jul 2022 00:35:58 +0200 Subject: [PATCH 1/2] Add a clickable link to the layout section --- src/librustdoc/html/markdown.rs | 1 + src/librustdoc/html/render/print_item.rs | 6 +++++- src/test/rustdoc/type-layout.rs | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 4170c73b24625..52a2effca0ff7 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -1485,6 +1485,7 @@ fn init_id_map() -> FxHashMap, 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 } diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 81cc12c9d5596..c6a48d51a56da 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -1869,7 +1869,11 @@ fn document_type_layout(w: &mut Buffer, cx: &Context<'_>, ty_def_id: DefId) { return; } - writeln!(w, "

Layout

"); + writeln!( + w, + "

\ + Layout

" + ); writeln!(w, "
"); let tcx = cx.tcx(); diff --git a/src/test/rustdoc/type-layout.rs b/src/test/rustdoc/type-layout.rs index 4eea9809ac58f..3b13e12ee61ed 100644 --- a/src/test/rustdoc/type-layout.rs +++ b/src/test/rustdoc/type-layout.rs @@ -2,6 +2,7 @@ // @has type_layout/struct.Foo.html 'Size: ' // @has - ' bytes' +// @matches - '

' pub struct Foo { pub a: usize, b: Vec, From 15db4186b76a95adad15428d391fe7726112ea03 Mon Sep 17 00:00:00 2001 From: est31 Date: Tue, 26 Jul 2022 12:45:16 +0200 Subject: [PATCH 2/2] Simplify test Co-authored-by: Guillaume Gomez --- src/test/rustdoc/type-layout.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/rustdoc/type-layout.rs b/src/test/rustdoc/type-layout.rs index 3b13e12ee61ed..e5c6e9dc3f9ed 100644 --- a/src/test/rustdoc/type-layout.rs +++ b/src/test/rustdoc/type-layout.rs @@ -2,7 +2,7 @@ // @has type_layout/struct.Foo.html 'Size: ' // @has - ' bytes' -// @matches - '

' +// @has - '//*[@id="layout"]/a[@href="#layout"]' '' pub struct Foo { pub a: usize, b: Vec,