mirror of
https://github.com/rust-lang/rust
synced 2024-11-05 20:45:15 +00:00
Correctly handle Weak type aliases in rustdoc
This commit is contained in:
parent
1af48beed7
commit
53761e1222
2 changed files with 19 additions and 8 deletions
|
@ -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) => {
|
||||
|
|
|
@ -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<Reexport, ()>'
|
||||
// @has - '//*[@class="rust item-decl"]' 'pub fn foo2() -> Result<u8, ()>'
|
||||
// @has - '//*[@class="rust item-decl"]' 'pub fn foo2() -> Result<Reexported, ()>'
|
||||
// @has 'foo/reexport/type.Reexported.html'
|
||||
// @has - '//*[@class="rust item-decl"]' 'pub type Reexported = u8;'
|
||||
#[doc(inline)]
|
||||
|
|
Loading…
Reference in a new issue