Skip to content

Commit

Permalink
Store Pattern in surface::Term::Let behind a pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
Kmeakin committed Jan 12, 2023
1 parent 2da5be1 commit 8dbe29a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions fathom/src/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ pub enum Term<'arena, Range> {
/// Let expressions.
Let(
Range,
Pattern<'arena, Range>,
&'arena Pattern<'arena, Range>,
Option<&'arena Term<'arena, Range>>,
&'arena Term<'arena, Range>,
&'arena Term<'arena, Range>,
Expand Down Expand Up @@ -525,8 +525,8 @@ mod tests {
#[test]
#[cfg(target_pointer_width = "64")]
fn term_size() {
assert_eq!(std::mem::size_of::<Term<()>>(), 48);
assert_eq!(std::mem::size_of::<Term<ByteRange>>(), 72);
assert_eq!(std::mem::size_of::<Term<()>>(), 40);
assert_eq!(std::mem::size_of::<Term<ByteRange>>(), 48);
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions fathom/src/surface/distillation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ impl<'interner, 'arena, 'env> Context<'interner, 'arena, 'env> {

Term::Let(
(),
Pattern::Name((), def_name),
self.scope.to_scope(Pattern::Name((), def_name)),
Some(self.scope.to_scope(def_type)),
self.scope.to_scope(def_expr),
self.scope.to_scope(body_expr),
Expand Down Expand Up @@ -477,7 +477,7 @@ impl<'interner, 'arena, 'env> Context<'interner, 'arena, 'env> {

Term::Let(
(),
Pattern::Name((), def_name),
self.scope.to_scope(Pattern::Name((), def_name)),
Some(self.scope.to_scope(def_type)),
self.scope.to_scope(def_expr),
self.scope.to_scope(body_expr),
Expand Down
2 changes: 1 addition & 1 deletion fathom/src/surface/grammar.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ LetTerm: Term<'arena, ByteRange> = {
<start: @L> "let" <def_pattern: Pattern> <def_type: (":" <LetTerm>)?> "=" <def_expr: Term> ";" <body_expr: LetTerm> <end: @R> => {
Term::Let(
ByteRange::new(file_id, start, end),
def_pattern,
scope.to_scope(def_pattern),
def_type.map(|def_type| scope.to_scope(def_type) as &_),
scope.to_scope(def_expr),
scope.to_scope(body_expr),
Expand Down

0 comments on commit 8dbe29a

Please sign in to comment.