Skip to content

Commit 6b3bba8

Browse files
committed
rustdoc: handle typedef inner type when doing cross-crate inlining
1 parent 2c35abe commit 6b3bba8

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

src/librustdoc/clean/inline.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ use rustc_span::symbol::{kw, sym, Symbol};
2020
use crate::clean::{
2121
self, clean_fn_decl_from_did_and_sig, clean_generics, clean_impl_item, clean_middle_assoc_item,
2222
clean_middle_field, clean_middle_ty, clean_trait_ref_with_bindings, clean_ty,
23-
clean_ty_generics, clean_variant_def, utils, Attributes, AttributesExt, ImplKind, ItemId, Type,
23+
clean_ty_alias_inner_type, clean_ty_generics, clean_variant_def, utils, Attributes,
24+
AttributesExt, ImplKind, ItemId, Type,
2425
};
2526
use crate::core::DocContext;
2627
use crate::formats::item_type::ItemType;
@@ -289,19 +290,14 @@ fn build_union(cx: &mut DocContext<'_>, did: DefId) -> clean::Union {
289290

290291
fn build_type_alias(cx: &mut DocContext<'_>, did: DefId) -> Box<clean::TypeAlias> {
291292
let predicates = cx.tcx.explicit_predicates_of(did);
292-
let type_ = clean_middle_ty(
293-
ty::Binder::dummy(cx.tcx.type_of(did).instantiate_identity()),
294-
cx,
295-
Some(did),
296-
None,
297-
);
293+
let ty = cx.tcx.type_of(did).instantiate_identity();
294+
let type_ = clean_middle_ty(ty::Binder::dummy(ty), cx, Some(did), None);
295+
let inner_type = clean_ty_alias_inner_type(ty, cx);
298296

299297
Box::new(clean::TypeAlias {
300298
type_,
301299
generics: clean_ty_generics(cx, cx.tcx.generics_of(did), predicates),
302-
// FIXME: Figure-out how to handle inner_type with
303-
// clean_ty_typedef_inner_type
304-
inner_type: None,
300+
inner_type,
305301
item_type: None,
306302
})
307303
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pub struct InlineOne<A> {
2+
pub inline: A
3+
}
4+
5+
pub type InlineU64 = InlineOne<u64>;

tests/rustdoc/typedef-inner-variants.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
// This test checks different combinations of structs, enums, and unions
2+
// for the "Show Aliased Type" feature on type definition.
3+
14
#![crate_name = "inner_variants"]
25

6+
// aux-build:cross_crate_generic_typedef.rs
7+
extern crate cross_crate_generic_typedef;
8+
39
pub struct Adt;
410
pub struct Ty;
511

@@ -78,3 +84,8 @@ pub struct HighlyGenericStruct<A, B, C, D> {
7884
// @count - '//*[@id="variants"]' 0
7985
// @count - '//*[@id="fields"]' 0
8086
pub type HighlyGenericAABB<A, B> = HighlyGenericStruct<A, A, B, B>;
87+
88+
// @has 'inner_variants/type.InlineU64.html'
89+
// @count - '//*[@id="variants"]' 0
90+
// @count - '//*[@id="fields"]' 1
91+
pub use cross_crate_generic_typedef::InlineU64;

0 commit comments

Comments
 (0)