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.
This commit is contained in:
Camelid 2021-04-12 19:23:49 -07:00
parent 9859e2b01d
commit 48da66f28f
2 changed files with 6 additions and 2 deletions

View File

@ -830,11 +830,14 @@ fn item_typedef(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::T
document(w, cx, it, None);
let def_id = it.def_id.expect_real();
// Render any items associated directly to this alias, as otherwise they
// won't be visible anywhere in the docs. It would be nice to also show
// associated items from the aliased type (see discussion in #32077), but
// we need #14072 to make sense of the generics.
render_assoc_items(w, cx, it, it.def_id.expect_real(), AssocItemRender::All)
render_assoc_items(w, cx, it, def_id, AssocItemRender::All);
document_ty_layout(w, cx, def_id);
}
fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Union) {

View File

@ -36,7 +36,8 @@ pub struct Generic<T>(T);
// @has - '(unsized)'
pub struct Unsized([u8]);
// @!has type_layout/type.TypeAlias.html 'Size: '
// @has type_layout/type.TypeAlias.html 'Size: '
// @has - ' bytes'
pub type TypeAlias = X;
// @!has type_layout/trait.MyTrait.html 'Size: '