Skip to content

Commit cd57cad

Browse files
committed
Add comment for let bindings in SourceMap
1 parent c5a9fc3 commit cd57cad

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

crates/lowering/src/sourcemap.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,24 @@ use super::{
1414
type FxIndexMap<K, V> = IndexMap<K, V, FxBuildHasher>;
1515

1616
/// Mapping from recursive trees to stable IDs.
17+
///
18+
/// # Let Bindings
19+
///
20+
/// Let bindings are handled differently in the [`SourceMap`] as let declarations
21+
/// must be considered in groups rather than individually.
22+
///
23+
/// To accommodate this requirement, we make use of:
24+
/// * [`let_bindings_grouped`], to assign stable IDs to [`LetBindingKind`];
25+
/// * [`let_bindings`] to assign stable IDs to [`LetBindingPtr`] _and_ track
26+
/// the [`LetBindingKind`] that it belongs to.
27+
///
28+
/// [`let_bindings`]: SourceMap::let_bindings
29+
/// [`let_bindings_grouped`]: SourceMap::let_bindings_grouped
1730
#[derive(Debug, Default, PartialEq, Eq)]
1831
pub struct SourceMap {
1932
types: FxIndexMap<TypePtr, TypeKind>,
2033
binders: FxIndexMap<BinderPtr, BinderKind>,
2134
expressions: FxIndexMap<ExpressionPtr, ExpressionKind>,
22-
// We opt to define insertion logic for the following mappings in
23-
// the lowering code itself because it's non-trivial, thus we mark
24-
// them as pub(crate)
2535
pub(crate) let_bindings: FxIndexMap<LetBindingPtr, LetBindingKindId>,
2636
pub(crate) let_bindings_grouped: Vec<LetBindingKind>,
2737
}

0 commit comments

Comments
 (0)