Skip to content

Commit

Permalink
resolve: Add comments explaining use of Interned
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Jul 5, 2023
1 parent c1f412f commit 9f3fba8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ pub(crate) struct ImportData<'a> {
pub used: Cell<bool>,
}

/// 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> {
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>>);
Expand Down Expand Up @@ -661,6 +663,8 @@ struct NameBindingData<'a> {
vis: ty::Visibility<DefId>,
}

/// 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> {
Expand Down

0 comments on commit 9f3fba8

Please sign in to comment.