@@ -2595,7 +2595,7 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait)
2595
2595
}
2596
2596
2597
2597
// If there are methods directly on this trait object, render them here.
2598
- render_assoc_items ( w, cx, it, it. def_id , AssocItemRender :: All ) ;
2598
+ render_assoc_items ( w, cx, it, it. def_id , & AssocItemRender :: All ) ;
2599
2599
2600
2600
let mut synthetic_types = Vec :: new ( ) ;
2601
2601
@@ -2942,7 +2942,7 @@ fn item_struct(w: &mut Buffer, cx: &Context, it: &clean::Item, s: &clean::Struct
2942
2942
}
2943
2943
}
2944
2944
}
2945
- render_assoc_items ( w, cx, it, it. def_id , AssocItemRender :: All )
2945
+ render_assoc_items ( w, cx, it, it. def_id , & AssocItemRender :: All )
2946
2946
}
2947
2947
2948
2948
fn item_union ( w : & mut Buffer , cx : & Context , it : & clean:: Item , s : & clean:: Union ) {
@@ -2988,7 +2988,7 @@ fn item_union(w: &mut Buffer, cx: &Context, it: &clean::Item, s: &clean::Union)
2988
2988
document ( w, cx, field) ;
2989
2989
}
2990
2990
}
2991
- render_assoc_items ( w, cx, it, it. def_id , AssocItemRender :: All )
2991
+ render_assoc_items ( w, cx, it, it. def_id , & AssocItemRender :: All )
2992
2992
}
2993
2993
2994
2994
fn item_enum ( w : & mut Buffer , cx : & Context , it : & clean:: Item , e : & clean:: Enum ) {
@@ -3130,7 +3130,7 @@ fn item_enum(w: &mut Buffer, cx: &Context, it: &clean::Item, e: &clean::Enum) {
3130
3130
render_stability_since ( w, variant, it) ;
3131
3131
}
3132
3132
}
3133
- render_assoc_items ( w, cx, it, it. def_id , AssocItemRender :: All )
3133
+ render_assoc_items ( w, cx, it, it. def_id , & AssocItemRender :: All )
3134
3134
}
3135
3135
3136
3136
fn render_attribute ( attr : & ast:: MetaItem ) -> Option < String > {
@@ -3344,7 +3344,7 @@ fn render_assoc_items(
3344
3344
cx : & Context ,
3345
3345
containing_item : & clean:: Item ,
3346
3346
it : DefId ,
3347
- what : AssocItemRender < ' _ > ,
3347
+ what : & AssocItemRender < ' _ > ,
3348
3348
) {
3349
3349
let c = & cx. cache ;
3350
3350
let v = match c. impls . get ( & it) {
@@ -3377,7 +3377,7 @@ fn render_assoc_items(
3377
3377
trait_. print( ) ,
3378
3378
type_. print( )
3379
3379
) ;
3380
- RenderMode :: ForDeref { mut_ : deref_mut_ }
3380
+ RenderMode :: ForDeref { mut_ : * deref_mut_ }
3381
3381
}
3382
3382
} ;
3383
3383
for i in & non_trait {
@@ -3461,6 +3461,19 @@ fn render_assoc_items(
3461
3461
}
3462
3462
}
3463
3463
3464
+ fn get_def_id ( real_target : & clean:: Type , cx : & Context ) -> Option < DefId > {
3465
+ if let Some ( did) = real_target. def_id ( ) {
3466
+ return Some ( did) ;
3467
+ } else {
3468
+ if let Some ( prim) = real_target. primitive_type ( ) {
3469
+ if let Some ( & did) = cx. cache . primitive_locations . get ( & prim) {
3470
+ return Some ( did) ;
3471
+ }
3472
+ }
3473
+ }
3474
+ None
3475
+ }
3476
+
3464
3477
fn render_deref_methods (
3465
3478
w : & mut Buffer ,
3466
3479
cx : & Context ,
@@ -3475,23 +3488,21 @@ fn render_deref_methods(
3475
3488
. iter ( )
3476
3489
. filter_map ( |item| match item. inner {
3477
3490
clean:: TypedefItem ( ref t, true ) => Some ( match * t {
3478
- clean:: Typedef { item_type : Some ( ref type_) , .. } => ( & t. type_ , type_) ,
3479
- _ => ( & t. type_ , & t . type_ ) ,
3491
+ clean:: Typedef { item_type : Some ( ref type_) , .. } => ( & t. type_ , Some ( type_) ) ,
3492
+ _ => ( & t. type_ , None ) ,
3480
3493
} ) ,
3481
3494
_ => None ,
3482
3495
} )
3483
3496
. next ( )
3484
3497
. expect ( "Expected associated type binding" ) ;
3498
+ let did = get_def_id ( & target, cx) ;
3485
3499
let what =
3486
3500
AssocItemRender :: DerefFor { trait_ : deref_type, type_ : target, deref_mut_ : deref_mut } ;
3487
- if let Some ( did) = real_target. def_id ( ) {
3488
- render_assoc_items ( w, cx, container_item, did, what)
3489
- } else {
3490
- if let Some ( prim) = real_target. primitive_type ( ) {
3491
- if let Some ( & did) = cx. cache . primitive_locations . get ( & prim) {
3492
- render_assoc_items ( w, cx, container_item, did, what) ;
3493
- }
3494
- }
3501
+ if let Some ( did) = did {
3502
+ render_assoc_items ( w, cx, container_item, did, & what) ;
3503
+ }
3504
+ if let Some ( did) = real_target. and_then ( |x| get_def_id ( x, cx) ) {
3505
+ render_assoc_items ( w, cx, container_item, did, & what) ;
3495
3506
}
3496
3507
}
3497
3508
@@ -3873,7 +3884,7 @@ fn item_opaque_ty(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Opa
3873
3884
// won't be visible anywhere in the docs. It would be nice to also show
3874
3885
// associated items from the aliased type (see discussion in #32077), but
3875
3886
// we need #14072 to make sense of the generics.
3876
- render_assoc_items ( w, cx, it, it. def_id , AssocItemRender :: All )
3887
+ render_assoc_items ( w, cx, it, it. def_id , & AssocItemRender :: All )
3877
3888
}
3878
3889
3879
3890
fn item_trait_alias ( w : & mut Buffer , cx : & Context , it : & clean:: Item , t : & clean:: TraitAlias ) {
@@ -3894,7 +3905,7 @@ fn item_trait_alias(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::T
3894
3905
// won't be visible anywhere in the docs. It would be nice to also show
3895
3906
// associated items from the aliased type (see discussion in #32077), but
3896
3907
// we need #14072 to make sense of the generics.
3897
- render_assoc_items ( w, cx, it, it. def_id , AssocItemRender :: All )
3908
+ render_assoc_items ( w, cx, it, it. def_id , & AssocItemRender :: All )
3898
3909
}
3899
3910
3900
3911
fn item_typedef ( w : & mut Buffer , cx : & Context , it : & clean:: Item , t : & clean:: Typedef ) {
@@ -3915,7 +3926,7 @@ fn item_typedef(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Typed
3915
3926
// won't be visible anywhere in the docs. It would be nice to also show
3916
3927
// associated items from the aliased type (see discussion in #32077), but
3917
3928
// we need #14072 to make sense of the generics.
3918
- render_assoc_items ( w, cx, it, it. def_id , AssocItemRender :: All )
3929
+ render_assoc_items ( w, cx, it, it. def_id , & AssocItemRender :: All )
3919
3930
}
3920
3931
3921
3932
fn item_foreign_type ( w : & mut Buffer , cx : & Context , it : & clean:: Item ) {
@@ -3930,7 +3941,7 @@ fn item_foreign_type(w: &mut Buffer, cx: &Context, it: &clean::Item) {
3930
3941
3931
3942
document ( w, cx, it) ;
3932
3943
3933
- render_assoc_items ( w, cx, it, it. def_id , AssocItemRender :: All )
3944
+ render_assoc_items ( w, cx, it, it. def_id , & AssocItemRender :: All )
3934
3945
}
3935
3946
3936
3947
fn print_sidebar ( cx : & Context , it : & clean:: Item , buffer : & mut Buffer ) {
@@ -4602,7 +4613,7 @@ fn item_proc_macro(w: &mut Buffer, cx: &Context, it: &clean::Item, m: &clean::Pr
4602
4613
4603
4614
fn item_primitive ( w : & mut Buffer , cx : & Context , it : & clean:: Item ) {
4604
4615
document ( w, cx, it) ;
4605
- render_assoc_items ( w, cx, it, it. def_id , AssocItemRender :: All )
4616
+ render_assoc_items ( w, cx, it, it. def_id , & AssocItemRender :: All )
4606
4617
}
4607
4618
4608
4619
fn item_keyword ( w : & mut Buffer , cx : & Context , it : & clean:: Item ) {
0 commit comments