From 9f3fba8da81300dc1a734a9cb1e2d804286b4f8d Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 5 Jul 2023 13:46:42 +0300 Subject: [PATCH] resolve: Add comments explaining use of `Interned` --- compiler/rustc_resolve/src/imports.rs | 2 ++ compiler/rustc_resolve/src/lib.rs | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index 036fbf2dbf0..d37fe783bba 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -172,6 +172,8 @@ pub(crate) struct ImportData<'a> { pub used: Cell, } +/// All imports are unique and allocated on a same arena, +/// so we can use referential equality to compare them. pub(crate) type Import<'a> = Interned<'a, ImportData<'a>>; impl<'a> ImportData<'a> { diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index b6a312c2982..da3d86a4718 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -514,6 +514,8 @@ struct ModuleData<'a> { expansion: ExpnId, } +/// All modules are unique and allocated on a same arena, +/// so we can use referential equality to compare them. #[derive(Clone, Copy, PartialEq)] #[rustc_pass_by_value] struct Module<'a>(Interned<'a, ModuleData<'a>>); @@ -661,6 +663,8 @@ struct NameBindingData<'a> { vis: ty::Visibility, } +/// All name bindings are unique and allocated on a same arena, +/// so we can use referential equality to compare them. type NameBinding<'a> = Interned<'a, NameBindingData<'a>>; trait ToNameBinding<'a> {