Skip to content

Commit 6509c42

Browse files
Use proper impl self type for alias impl in rustdoc
1 parent cba1407 commit 6509c42

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/librustdoc/clean/mod.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -2414,14 +2414,15 @@ fn clean_impl<'tcx>(
24142414
}
24152415

24162416
let for_ = clean_ty(impl_.self_ty, cx);
2417-
let type_alias = for_.def_id(&cx.cache).and_then(|did| match tcx.def_kind(did) {
2418-
DefKind::TyAlias => Some(clean_middle_ty(
2419-
ty::Binder::dummy(tcx.type_of(did).subst_identity()),
2420-
cx,
2421-
Some(did),
2422-
)),
2423-
_ => None,
2424-
});
2417+
let type_alias =
2418+
for_.def_id(&cx.cache).and_then(|alias_def_id: DefId| match tcx.def_kind(alias_def_id) {
2419+
DefKind::TyAlias => Some(clean_middle_ty(
2420+
ty::Binder::dummy(tcx.type_of(def_id).subst_identity()),
2421+
cx,
2422+
Some(def_id.to_def_id()),
2423+
)),
2424+
_ => None,
2425+
});
24252426
let mut make_item = |trait_: Option<Path>, for_: Type, items: Vec<Item>| {
24262427
let kind = ImplItem(Box::new(Impl {
24272428
unsafety: impl_.unsafety,
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pub struct Matrix<T, const N: usize, const M: usize>([[T; N]; M]);
2+
3+
pub type Vector<T, const N: usize> = Matrix<T, N, 1>;
4+
5+
// @has "impl_alias_substituted/struct.Matrix.html" '//*[@class="impl"]//h3[@class="code-header"]' \
6+
// "impl<T: Copy> Matrix<T, 3, 1>"
7+
impl<T: Copy> Vector<T, 3> {
8+
pub fn test() {}
9+
}

0 commit comments

Comments
 (0)