Skip to content

Commit 5e8ecc6

Browse files
committed
rustdoc: always pass the owner of generic args
1 parent 2f93a73 commit 5e8ecc6

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -475,16 +475,17 @@ fn projection_to_path_segment<'tcx>(
475475
ty: ty::Binder<'tcx, ty::AliasTy<'tcx>>,
476476
cx: &mut DocContext<'tcx>,
477477
) -> PathSegment {
478-
let item = cx.tcx.associated_item(ty.skip_binder().def_id);
479-
let generics = cx.tcx.generics_of(ty.skip_binder().def_id);
478+
let def_id = ty.skip_binder().def_id;
479+
let item = cx.tcx.associated_item(def_id);
480+
let generics = cx.tcx.generics_of(def_id);
480481
PathSegment {
481482
name: item.name,
482483
args: GenericArgs::AngleBracketed {
483484
args: ty_args_to_args(
484485
cx,
485486
ty.map_bound(|ty| &ty.args[generics.parent_count..]),
486487
false,
487-
None,
488+
def_id,
488489
)
489490
.into(),
490491
bindings: Default::default(),
@@ -2200,18 +2201,19 @@ pub(crate) fn clean_middle_ty<'tcx>(
22002201
}
22012202

22022203
ty::Alias(ty::Inherent, alias_ty) => {
2204+
let def_id = alias_ty.def_id;
22032205
let alias_ty = bound_ty.rebind(alias_ty);
22042206
let self_type = clean_middle_ty(alias_ty.map_bound(|ty| ty.self_ty()), cx, None, None);
22052207

22062208
Type::QPath(Box::new(QPathData {
22072209
assoc: PathSegment {
2208-
name: cx.tcx.associated_item(alias_ty.skip_binder().def_id).name,
2210+
name: cx.tcx.associated_item(def_id).name,
22092211
args: GenericArgs::AngleBracketed {
22102212
args: ty_args_to_args(
22112213
cx,
22122214
alias_ty.map_bound(|ty| ty.args.as_slice()),
22132215
true,
2214-
None,
2216+
def_id,
22152217
)
22162218
.into(),
22172219
bindings: Default::default(),

src/librustdoc/clean/utils.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ pub(crate) fn ty_args_to_args<'tcx>(
7979
cx: &mut DocContext<'tcx>,
8080
ty_args: ty::Binder<'tcx, &'tcx [ty::GenericArg<'tcx>]>,
8181
has_self: bool,
82-
container: Option<DefId>,
82+
owner: DefId,
8383
) -> Vec<GenericArg> {
84-
let params = container.map(|container| &cx.tcx.generics_of(container).params);
84+
let params = &cx.tcx.generics_of(owner).params;
8585
let mut elision_has_failed_once_before = false;
8686

8787
let offset = if has_self { 1 } else { 0 };
@@ -94,7 +94,6 @@ pub(crate) fn ty_args_to_args<'tcx>(
9494
GenericArgKind::Type(_) if has_self && index == 0 => None,
9595
GenericArgKind::Type(ty) => {
9696
if !elision_has_failed_once_before
97-
&& let Some(params) = params
9897
&& let Some(default) = params[index].default_value(cx.tcx)
9998
{
10099
let default =
@@ -111,8 +110,8 @@ pub(crate) fn ty_args_to_args<'tcx>(
111110
ty_args.rebind(ty),
112111
cx,
113112
None,
114-
container.map(|container| crate::clean::ContainerTy::Regular {
115-
ty: container,
113+
Some(crate::clean::ContainerTy::Regular {
114+
ty: owner,
116115
args: ty_args,
117116
has_self,
118117
arg: index,
@@ -130,7 +129,6 @@ pub(crate) fn ty_args_to_args<'tcx>(
130129
}
131130

132131
if !elision_has_failed_once_before
133-
&& let Some(params) = params
134132
&& let Some(default) = params[index].default_value(cx.tcx)
135133
{
136134
let default =
@@ -200,7 +198,7 @@ fn external_generic_args<'tcx>(
200198
bindings: ThinVec<TypeBinding>,
201199
ty_args: ty::Binder<'tcx, GenericArgsRef<'tcx>>,
202200
) -> GenericArgs {
203-
let args = ty_args_to_args(cx, ty_args.map_bound(|args| &args[..]), has_self, Some(did));
201+
let args = ty_args_to_args(cx, ty_args.map_bound(|args| &args[..]), has_self, did);
204202

205203
if cx.tcx.fn_trait_kind_from_def_id(did).is_some() {
206204
let ty = ty_args

0 commit comments

Comments
 (0)