@@ -1237,104 +1237,63 @@ fn item_type_alias(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &c
12371237
12381238 write ! ( w, "{}" , document( cx, it, None , HeadingOffset :: H2 ) ) ;
12391239
1240- // Only show inner variants if:
1241- // - the typealias does NOT have any generics (modulo lifetimes)
1242- // - AND the aliased type has some generics
1243- //
1244- // Otherwise, showing a non-generic type is rendurant with its own page, or
1245- // if it still has some generics, it's not as useful.
1246- let should_print_inner_type = t
1247- . generics
1248- . params
1249- . iter ( )
1250- . all ( |param| matches ! ( param. kind, clean:: GenericParamDefKind :: Lifetime { .. } ) )
1251- && t. generics . where_predicates . is_empty ( )
1252- && t. type_ . generics ( ) . is_some_and ( |generics| !generics. is_empty ( ) ) ;
1253-
1254- if should_print_inner_type {
1255- fn toggle < W , F > ( w : & mut W , f : F )
1256- where
1257- W : fmt:: Write ,
1258- F : FnOnce ( & mut W ) ,
1259- {
1260- write ! (
1261- w,
1262- "<details class=\" toggle\" >\
1263- <summary>\
1264- <span>Show Aliased Type</span>\
1265- </summary>",
1266- )
1267- . unwrap ( ) ;
1268- f ( w) ;
1269- write ! ( w, "</details>" ) . unwrap ( ) ;
1270- }
1271-
1272- match & t. inner_type {
1273- Some ( clean:: TypeAliasInnerType :: Enum { variants, is_non_exhaustive } ) => {
1274- toggle ( w, |w| {
1275- let variants_iter = || variants. iter ( ) . filter ( |i| !i. is_stripped ( ) ) ;
1276- wrap_item ( w, |w| {
1277- let variants_len = variants. len ( ) ;
1278- let variants_count = variants_iter ( ) . count ( ) ;
1279- let has_stripped_entries = variants_len != variants_count;
1280-
1281- write ! ( w, "enum {}{}" , it. name. unwrap( ) , t. generics. print( cx) ) ;
1282- render_enum_fields (
1283- w,
1284- cx,
1285- None ,
1286- variants_iter ( ) ,
1287- variants_count,
1288- has_stripped_entries,
1289- * is_non_exhaustive,
1290- )
1291- } ) ;
1292- item_variants ( w, cx, it, variants_iter ( ) ) ;
1240+ if let Some ( inner_type) = & t. inner_type && t. should_display_inner_type ( ) {
1241+ write ! (
1242+ w,
1243+ "<h2 id=\" aliased-type\" class=\" small-section-header\" >\
1244+ Aliased Type<a href=\" #aliased-type\" class=\" anchor\" >§</a></h2>"
1245+ ) ;
1246+
1247+ match inner_type {
1248+ clean:: TypeAliasInnerType :: Enum { variants, is_non_exhaustive } => {
1249+ let variants_iter = || variants. iter ( ) . filter ( |i| !i. is_stripped ( ) ) ;
1250+ wrap_item ( w, |w| {
1251+ let variants_len = variants. len ( ) ;
1252+ let variants_count = variants_iter ( ) . count ( ) ;
1253+ let has_stripped_entries = variants_len != variants_count;
1254+
1255+ write ! ( w, "enum {}{}" , it. name. unwrap( ) , t. generics. print( cx) ) ;
1256+ render_enum_fields (
1257+ w,
1258+ cx,
1259+ None ,
1260+ variants_iter ( ) ,
1261+ variants_count,
1262+ has_stripped_entries,
1263+ * is_non_exhaustive,
1264+ )
12931265 } ) ;
1266+ item_variants ( w, cx, it, variants_iter ( ) ) ;
12941267 }
1295- Some ( clean:: TypeAliasInnerType :: Union { fields } ) => {
1296- toggle ( w, |w| {
1297- wrap_item ( w, |w| {
1298- let fields_count = fields. iter ( ) . filter ( |i| !i. is_stripped ( ) ) . count ( ) ;
1299- let has_stripped_fields = fields. len ( ) != fields_count;
1300-
1301- write ! ( w, "union {}{}" , it. name. unwrap( ) , t. generics. print( cx) ) ;
1302- render_struct_fields (
1303- w,
1304- None ,
1305- None ,
1306- fields,
1307- "" ,
1308- true ,
1309- has_stripped_fields,
1310- cx,
1311- ) ;
1312- } ) ;
1313- item_fields ( w, cx, it, fields, None ) ;
1268+ clean:: TypeAliasInnerType :: Union { fields } => {
1269+ wrap_item ( w, |w| {
1270+ let fields_count = fields. iter ( ) . filter ( |i| !i. is_stripped ( ) ) . count ( ) ;
1271+ let has_stripped_fields = fields. len ( ) != fields_count;
1272+
1273+ write ! ( w, "union {}{}" , it. name. unwrap( ) , t. generics. print( cx) ) ;
1274+ render_struct_fields ( w, None , None , fields, "" , true , has_stripped_fields, cx) ;
13141275 } ) ;
1276+ item_fields ( w, cx, it, fields, None ) ;
13151277 }
1316- Some ( clean:: TypeAliasInnerType :: Struct { ctor_kind, fields } ) => {
1317- toggle ( w, |w| {
1318- wrap_item ( w, |w| {
1319- let fields_count = fields. iter ( ) . filter ( |i| !i. is_stripped ( ) ) . count ( ) ;
1320- let has_stripped_fields = fields. len ( ) != fields_count;
1321-
1322- write ! ( w, "struct {}{}" , it. name. unwrap( ) , t. generics. print( cx) ) ;
1323- render_struct_fields (
1324- w,
1325- None ,
1326- * ctor_kind,
1327- fields,
1328- "" ,
1329- true ,
1330- has_stripped_fields,
1331- cx,
1332- ) ;
1333- } ) ;
1334- item_fields ( w, cx, it, fields, None ) ;
1278+ clean:: TypeAliasInnerType :: Struct { ctor_kind, fields } => {
1279+ wrap_item ( w, |w| {
1280+ let fields_count = fields. iter ( ) . filter ( |i| !i. is_stripped ( ) ) . count ( ) ;
1281+ let has_stripped_fields = fields. len ( ) != fields_count;
1282+
1283+ write ! ( w, "struct {}{}" , it. name. unwrap( ) , t. generics. print( cx) ) ;
1284+ render_struct_fields (
1285+ w,
1286+ None ,
1287+ * ctor_kind,
1288+ fields,
1289+ "" ,
1290+ true ,
1291+ has_stripped_fields,
1292+ cx,
1293+ ) ;
13351294 } ) ;
1295+ item_fields ( w, cx, it, fields, None ) ;
13361296 }
1337- None => { }
13381297 }
13391298 }
13401299
0 commit comments