about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src/collect/generics_of.rs
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-04-17 21:58:27 -0400
committerMichael Goulet <michael@errs.io>2024-04-17 22:29:59 -0400
commitffb42065774b5d500ef5649d4caa91e9e344ff46 (patch)
treec5ccc932c5f9c30ad2d5a29b555960602c26bb82 /compiler/rustc_hir_analysis/src/collect/generics_of.rs
parent00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82 (diff)
downloadrust-ffb42065774b5d500ef5649d4caa91e9e344ff46.tar.gz
rust-ffb42065774b5d500ef5649d4caa91e9e344ff46.zip
Don't repeatedly duplicate TAIT lifetimes for each subsequently nested TAIT
Diffstat (limited to 'compiler/rustc_hir_analysis/src/collect/generics_of.rs')
-rw-r--r--compiler/rustc_hir_analysis/src/collect/generics_of.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/compiler/rustc_hir_analysis/src/collect/generics_of.rs b/compiler/rustc_hir_analysis/src/collect/generics_of.rs
index 4d6a02f50bf..f83ddc51c76 100644
--- a/compiler/rustc_hir_analysis/src/collect/generics_of.rs
+++ b/compiler/rustc_hir_analysis/src/collect/generics_of.rs
@@ -195,16 +195,19 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
                 }
                 Some(fn_def_id.to_def_id())
             }
-            ItemKind::OpaqueTy(hir::OpaqueTy {
-                origin: hir::OpaqueTyOrigin::TyAlias { .. },
+            ItemKind::OpaqueTy(&hir::OpaqueTy {
+                origin: hir::OpaqueTyOrigin::TyAlias { parent, in_assoc_ty },
                 ..
             }) => {
-                let parent_id = tcx.hir().get_parent_item(hir_id);
-                assert_ne!(parent_id, hir::CRATE_OWNER_ID);
-                debug!("generics_of: parent of opaque ty {:?} is {:?}", def_id, parent_id);
+                if in_assoc_ty {
+                    assert!(matches!(tcx.def_kind(parent), DefKind::AssocTy));
+                } else {
+                    assert!(matches!(tcx.def_kind(parent), DefKind::TyAlias));
+                }
+                debug!("generics_of: parent of opaque ty {:?} is {:?}", def_id, parent);
                 // Opaque types are always nested within another item, and
                 // inherit the generics of the item.
-                Some(parent_id.to_def_id())
+                Some(parent.to_def_id())
             }
             _ => None,
         },