Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 48da66f

Browse files
committed
Show memory layout for type aliases
At first you might think "why not just click through to the aliased type?", but if a type alias instantiates all of the generic parameters of the aliased type, then it can show layout info even though the aliased type cannot (because we can't compute the layout of a generic type). So I think it's still useful to show layout info for type aliases.
1 parent 9859e2b commit 48da66f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/librustdoc/html/render/print_item.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,11 +830,14 @@ fn item_typedef(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::T
830830

831831
document(w, cx, it, None);
832832

833+
let def_id = it.def_id.expect_real();
833834
// Render any items associated directly to this alias, as otherwise they
834835
// won't be visible anywhere in the docs. It would be nice to also show
835836
// associated items from the aliased type (see discussion in #32077), but
836837
// we need #14072 to make sense of the generics.
837-
render_assoc_items(w, cx, it, it.def_id.expect_real(), AssocItemRender::All)
838+
render_assoc_items(w, cx, it, def_id, AssocItemRender::All);
839+
840+
document_ty_layout(w, cx, def_id);
838841
}
839842

840843
fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Union) {

src/test/rustdoc/type-layout.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ pub struct Generic<T>(T);
3636
// @has - '(unsized)'
3737
pub struct Unsized([u8]);
3838

39-
// @!has type_layout/type.TypeAlias.html 'Size: '
39+
// @has type_layout/type.TypeAlias.html 'Size: '
40+
// @has - ' bytes'
4041
pub type TypeAlias = X;
4142

4243
// @!has type_layout/trait.MyTrait.html 'Size: '

0 commit comments

Comments
 (0)