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 {
393
393
debug ! ( "register_res({:?})" , res) ;
394
394
395
395
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
- }
404
396
// Each of these have their own page.
405
397
Res :: Def (
406
398
kind
407
399
@
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 ) ,
410
402
i,
411
403
) => ( i, kind. into ( ) ) ,
412
404
// 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};
13
13
use rustc_data_structures:: captures:: Captures ;
14
14
use rustc_data_structures:: fx:: FxHashSet ;
15
15
use rustc_hir as hir;
16
+ use rustc_hir:: def:: DefKind ;
16
17
use rustc_hir:: def_id:: DefId ;
17
18
use rustc_middle:: ty;
19
+ use rustc_middle:: ty:: DefIdTree ;
18
20
use rustc_middle:: ty:: TyCtxt ;
19
21
use rustc_span:: def_id:: CRATE_DEF_INDEX ;
20
22
use rustc_target:: spec:: abi:: Abi ;
@@ -502,7 +504,16 @@ crate fn href_with_root_path(
502
504
cx : & Context < ' _ > ,
503
505
root_path : Option < & str > ,
504
506
) -> 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 ( ) ;
506
517
let relative_to = & cx. current ;
507
518
fn to_module_fqp ( shortty : ItemType , fqp : & [ String ] ) -> & [ String ] {
508
519
if shortty == ItemType :: Module { fqp } else { & fqp[ ..fqp. len ( ) - 1 ] }
You can’t perform that action at this time.
0 commit comments