File tree Expand file tree Collapse file tree 2 files changed +14
-11
lines changed Expand file tree Collapse file tree 2 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -393,20 +393,12 @@ crate fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId {
393393 debug ! ( "register_res({:?})" , res) ;
394394
395395 let ( did, kind) = match res {
396- Res :: Def ( DefKind :: AssocTy | DefKind :: AssocFn | DefKind :: AssocConst , i) => {
397- // associated items are documented, but on the page of their parent
398- ( cx. tcx . parent ( i) . unwrap ( ) , ItemType :: Trait )
399- }
400- Res :: Def ( DefKind :: Variant , i) => {
401- // variant items are documented, but on the page of their parent
402- ( cx. tcx . parent ( i) . expect ( "cannot get parent def id" ) , ItemType :: Enum )
403- }
404396 // Each of these have their own page.
405397 Res :: Def (
406398 kind
407399 @
408- ( Fn | TyAlias | Enum | Trait | Struct | Union | Mod | ForeignTy | Const | Static
409- | Macro ( ..) | TraitAlias ) ,
400+ ( AssocTy | AssocFn | AssocConst | Variant | Fn | TyAlias | Enum | Trait | Struct
401+ | Union | Mod | ForeignTy | Const | Static | Macro ( ..) | TraitAlias ) ,
410402 i,
411403 ) => ( i, kind. into ( ) ) ,
412404 // This is part of a trait definition; document the trait.
Original file line number Diff line number Diff line change @@ -13,8 +13,10 @@ use rustc_attr::{ConstStability, StabilityLevel};
1313use rustc_data_structures:: captures:: Captures ;
1414use rustc_data_structures:: fx:: FxHashSet ;
1515use rustc_hir as hir;
16+ use rustc_hir:: def:: DefKind ;
1617use rustc_hir:: def_id:: DefId ;
1718use rustc_middle:: ty;
19+ use rustc_middle:: ty:: DefIdTree ;
1820use rustc_middle:: ty:: TyCtxt ;
1921use rustc_span:: def_id:: CRATE_DEF_INDEX ;
2022use rustc_target:: spec:: abi:: Abi ;
@@ -502,7 +504,16 @@ crate fn href_with_root_path(
502504 cx : & Context < ' _ > ,
503505 root_path : Option < & str > ,
504506) -> Result < ( String , ItemType , Vec < String > ) , HrefError > {
505- let cache = & cx. cache ( ) ;
507+ let tcx = cx. tcx ( ) ;
508+ let def_kind = tcx. def_kind ( did) ;
509+ let did = match def_kind {
510+ DefKind :: AssocTy | DefKind :: AssocFn | DefKind :: AssocConst | DefKind :: Variant => {
511+ // documented on their parent's page
512+ tcx. parent ( did) . unwrap ( )
513+ }
514+ _ => did,
515+ } ;
516+ let cache = cx. cache ( ) ;
506517 let relative_to = & cx. current ;
507518 fn to_module_fqp ( shortty : ItemType , fqp : & [ String ] ) -> & [ String ] {
508519 if shortty == ItemType :: Module { fqp } else { & fqp[ ..fqp. len ( ) - 1 ] }
You can’t perform that action at this time.
0 commit comments