about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-05-11 07:05:29 +0200
committerGitHub <noreply@github.com>2023-05-11 07:05:29 +0200
commit07af55edd4253e9eef7c170cec246af1a3589e20 (patch)
tree458d6d5e2e9b8202b580eca7c9d61f9bfd19889c /src
parent968911dbc0fc58e19efb41bd6393a89723450b27 (diff)
parent6509c42d165eab4a6a91fd94114e3df85532fd80 (diff)
downloadrust-07af55edd4253e9eef7c170cec246af1a3589e20.tar.gz
rust-07af55edd4253e9eef7c170cec246af1a3589e20.zip
Rollup merge of #111448 - compiler-errors:rustdoc-alias-impl, r=notriddle
Use proper impl self type for alias impl in rustdoc

We don't want to use `type_of(type_alias)`, we want to use `type_of(impl)` -- this will give us the self type of the impl *properly substituted* in the case that it's an alias.

Fixes #111420
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/clean/mod.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index c432ce3c324..59a3e631724 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -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,