Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #111452

Merged
merged 15 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use proper impl self type for alias impl in rustdoc
  • Loading branch information
compiler-errors committed May 10, 2023
commit 6509c42d165eab4a6a91fd94114e3df85532fd80
17 changes: 9 additions & 8 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2414,14 +2414,15 @@ fn clean_impl<'tcx>(
}

let for_ = clean_ty(impl_.self_ty, cx);
let type_alias = for_.def_id(&cx.cache).and_then(|did| match tcx.def_kind(did) {
DefKind::TyAlias => Some(clean_middle_ty(
ty::Binder::dummy(tcx.type_of(did).subst_identity()),
cx,
Some(did),
)),
_ => None,
});
let type_alias =
for_.def_id(&cx.cache).and_then(|alias_def_id: DefId| match tcx.def_kind(alias_def_id) {
DefKind::TyAlias => Some(clean_middle_ty(
ty::Binder::dummy(tcx.type_of(def_id).subst_identity()),
cx,
Some(def_id.to_def_id()),
)),
_ => None,
});
let mut make_item = |trait_: Option<Path>, for_: Type, items: Vec<Item>| {
let kind = ImplItem(Box::new(Impl {
unsafety: impl_.unsafety,
Expand Down
9 changes: 9 additions & 0 deletions tests/rustdoc/impl-alias-substituted.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pub struct Matrix<T, const N: usize, const M: usize>([[T; N]; M]);

pub type Vector<T, const N: usize> = Matrix<T, N, 1>;

// @has "impl_alias_substituted/struct.Matrix.html" '//*[@class="impl"]//h3[@class="code-header"]' \
// "impl<T: Copy> Matrix<T, 3, 1>"
impl<T: Copy> Vector<T, 3> {
pub fn test() {}
}