diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 851002d5e7965..67d433dd0ad87 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2024,8 +2024,8 @@ pub(crate) fn clean_middle_ty<'tcx>( Tuple(t.iter().map(|t| clean_middle_ty(bound_ty.rebind(t), cx, None, None)).collect()) } - ty::Alias(ty::Projection, ref data) => { - clean_projection(bound_ty.rebind(*data), cx, parent_def_id) + ty::Alias(ty::Projection, data) => { + clean_projection(bound_ty.rebind(data), cx, parent_def_id) } ty::Alias(ty::Inherent, alias_ty) => { @@ -2053,8 +2053,21 @@ pub(crate) fn clean_middle_ty<'tcx>( } ty::Alias(ty::Weak, data) => { - let ty = cx.tcx.type_of(data.def_id).subst(cx.tcx, data.substs); - clean_middle_ty(bound_ty.rebind(ty), cx, None, None) + if cx.tcx.features().lazy_type_alias { + // Weak type alias `data` represents the `type X` in `type X = Y`. If we need `Y`, + // we need to use `type_of`. + let path = external_path( + cx, + data.def_id, + false, + ThinVec::new(), + bound_ty.rebind(data.substs), + ); + Type::Path { path } + } else { + let ty = cx.tcx.type_of(data.def_id).subst(cx.tcx, data.substs); + clean_middle_ty(bound_ty.rebind(ty), cx, None, None) + } } ty::Param(ref p) => { diff --git a/tests/rustdoc/alias-reexport.rs b/tests/rustdoc/alias-reexport.rs index 029891197fc45..a2a8e651caf6d 100644 --- a/tests/rustdoc/alias-reexport.rs +++ b/tests/rustdoc/alias-reexport.rs @@ -7,11 +7,9 @@ extern crate alias_reexport2; // @has 'foo/reexport/fn.foo.html' -// FIXME: should be 'pub fn foo() -> Reexport' -// @has - '//*[@class="rust item-decl"]' 'pub fn foo() -> u8' +// @has - '//*[@class="rust item-decl"]' 'pub fn foo() -> Reexported' // @has 'foo/reexport/fn.foo2.html' -// FIXME: should be 'pub fn foo2() -> Result' -// @has - '//*[@class="rust item-decl"]' 'pub fn foo2() -> Result' +// @has - '//*[@class="rust item-decl"]' 'pub fn foo2() -> Result' // @has 'foo/reexport/type.Reexported.html' // @has - '//*[@class="rust item-decl"]' 'pub type Reexported = u8;' #[doc(inline)]