rustdoc: Correctly classify enums/typedefs
Both of these items are surfaced as a DefTy, so some extra logic was needed in the decoder module to figure out whether one is actually an enum or whether it's a typedef. Closes #14757
This commit is contained in:
parent
14668f2791
commit
24cbe38423
@ -321,3 +321,8 @@ pub fn get_reachable_extern_fns(cstore: &cstore::CStore, cnum: ast::CrateNum)
|
||||
let cdata = cstore.get_crate_data(cnum);
|
||||
decoder::get_reachable_extern_fns(&*cdata)
|
||||
}
|
||||
|
||||
pub fn is_typedef(cstore: &cstore::CStore, did: ast::DefId) -> bool {
|
||||
let cdata = cstore.get_crate_data(did.krate);
|
||||
decoder::is_typedef(&*cdata, did.node)
|
||||
}
|
||||
|
@ -1339,3 +1339,11 @@ pub fn get_reachable_extern_fns(cdata: Cmd) -> Vec<ast::DefId> {
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
pub fn is_typedef(cdata: Cmd, id: ast::NodeId) -> bool {
|
||||
let item_doc = lookup_item(id, cdata.data());
|
||||
match item_family(item_doc) {
|
||||
Type => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ fn build_struct(tcx: &ty::ctxt, did: ast::DefId) -> clean::Struct {
|
||||
fn build_type(tcx: &ty::ctxt, did: ast::DefId) -> clean::ItemEnum {
|
||||
let t = ty::lookup_item_type(tcx, did);
|
||||
match ty::get(t.ty).sty {
|
||||
ty::ty_enum(edid, _) => {
|
||||
ty::ty_enum(edid, _) if !csearch::is_typedef(&tcx.sess.cstore, did) => {
|
||||
return clean::EnumItem(clean::Enum {
|
||||
generics: t.generics.clean(),
|
||||
variants_stripped: false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user