Skip to content

Commit e6ad49a

Browse files
Include type alias implementations
1 parent 6e79146 commit e6ad49a

File tree

1 file changed

+32
-21
lines changed

1 file changed

+32
-21
lines changed

src/librustdoc/html/render.rs

+32-21
Original file line numberDiff line numberDiff line change
@@ -2595,7 +2595,7 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait)
25952595
}
25962596

25972597
// 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);
25992599

26002600
let mut synthetic_types = Vec::new();
26012601

@@ -2942,7 +2942,7 @@ fn item_struct(w: &mut Buffer, cx: &Context, it: &clean::Item, s: &clean::Struct
29422942
}
29432943
}
29442944
}
2945-
render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All)
2945+
render_assoc_items(w, cx, it, it.def_id, &AssocItemRender::All)
29462946
}
29472947

29482948
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)
29882988
document(w, cx, field);
29892989
}
29902990
}
2991-
render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All)
2991+
render_assoc_items(w, cx, it, it.def_id, &AssocItemRender::All)
29922992
}
29932993

29942994
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) {
31303130
render_stability_since(w, variant, it);
31313131
}
31323132
}
3133-
render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All)
3133+
render_assoc_items(w, cx, it, it.def_id, &AssocItemRender::All)
31343134
}
31353135

31363136
fn render_attribute(attr: &ast::MetaItem) -> Option<String> {
@@ -3344,7 +3344,7 @@ fn render_assoc_items(
33443344
cx: &Context,
33453345
containing_item: &clean::Item,
33463346
it: DefId,
3347-
what: AssocItemRender<'_>,
3347+
what: &AssocItemRender<'_>,
33483348
) {
33493349
let c = &cx.cache;
33503350
let v = match c.impls.get(&it) {
@@ -3377,7 +3377,7 @@ fn render_assoc_items(
33773377
trait_.print(),
33783378
type_.print()
33793379
);
3380-
RenderMode::ForDeref { mut_: deref_mut_ }
3380+
RenderMode::ForDeref { mut_: *deref_mut_ }
33813381
}
33823382
};
33833383
for i in &non_trait {
@@ -3461,6 +3461,19 @@ fn render_assoc_items(
34613461
}
34623462
}
34633463

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+
34643477
fn render_deref_methods(
34653478
w: &mut Buffer,
34663479
cx: &Context,
@@ -3475,23 +3488,21 @@ fn render_deref_methods(
34753488
.iter()
34763489
.filter_map(|item| match item.inner {
34773490
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),
34803493
}),
34813494
_ => None,
34823495
})
34833496
.next()
34843497
.expect("Expected associated type binding");
3498+
let did = get_def_id(&target, cx);
34853499
let what =
34863500
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);
34953506
}
34963507
}
34973508

@@ -3873,7 +3884,7 @@ fn item_opaque_ty(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Opa
38733884
// won't be visible anywhere in the docs. It would be nice to also show
38743885
// associated items from the aliased type (see discussion in #32077), but
38753886
// 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)
38773888
}
38783889

38793890
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
38943905
// won't be visible anywhere in the docs. It would be nice to also show
38953906
// associated items from the aliased type (see discussion in #32077), but
38963907
// 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)
38983909
}
38993910

39003911
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
39153926
// won't be visible anywhere in the docs. It would be nice to also show
39163927
// associated items from the aliased type (see discussion in #32077), but
39173928
// 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)
39193930
}
39203931

39213932
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) {
39303941

39313942
document(w, cx, it);
39323943

3933-
render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All)
3944+
render_assoc_items(w, cx, it, it.def_id, &AssocItemRender::All)
39343945
}
39353946

39363947
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
46024613

46034614
fn item_primitive(w: &mut Buffer, cx: &Context, it: &clean::Item) {
46044615
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)
46064617
}
46074618

46084619
fn item_keyword(w: &mut Buffer, cx: &Context, it: &clean::Item) {

0 commit comments

Comments
 (0)