Skip to content

Commit 33ebf4d

Browse files
authored
Rollup merge of #91682 - camelid:alias-layout, r=jyn514
rustdoc: Show type layout for type aliases Fixes #91265. 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 layout for generic types). So, I think it's useful to show layout info for type aliases. This is a followup of 78d4b453ad2e19d44011b26fc55c949bff5dba3d (originally part of #83501).
2 parents 7083f8e + e36da67 commit 33ebf4d

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/librustdoc/html/render/print_item.rs

+1
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,7 @@ fn item_typedef(
976976
// associated items from the aliased type (see discussion in #32077), but
977977
// we need #14072 to make sense of the generics.
978978
render_assoc_items(w, cx, it, def_id, AssocItemRender::All);
979+
document_type_layout(w, cx, def_id);
979980
}
980981

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

src/test/rustdoc/type-layout.rs

+12
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ pub struct GenericLifetimes<'a>(&'a str);
5050
// @has - '(unsized)'
5151
pub struct Unsized([u8]);
5252

53+
// @has type_layout/type.TypeAlias.html 'Size: '
54+
// @has - ' bytes'
55+
pub type TypeAlias = X;
56+
57+
// @has type_layout/type.GenericTypeAlias.html 'Size: '
58+
// @has - '8 bytes'
59+
pub type GenericTypeAlias = (Generic<(u32, ())>, Generic<u32>);
60+
61+
// Regression test for the rustdoc equivalent of #85103.
62+
// @has type_layout/type.Edges.html 'Encountered an error during type layout; the type failed to be normalized.'
63+
pub type Edges<'a, E> = std::borrow::Cow<'a, [E]>;
64+
5365
// @!has type_layout/trait.MyTrait.html 'Size: '
5466
pub trait MyTrait {}
5567

0 commit comments

Comments
 (0)