Lower twill-parser's borrowed AST to an owned/interned tree #43

Closed
opened 2026-08-20 19:06:07 +00:00 by jacksonopp · 0 comments
Owner

twill-parser's Expr<'src> is zero-copy, borrowing from the source &str. Salsa's tracked-struct outputs need to be cheaply Eq/hashable for early-cutoff, and threading twill-parser's 'src lifetime through salsa's 'db-bound tracked structs fights the framework for no benefit.

Decided in #1's discussion: immediately after parsing, lower the borrowed Spanned<Expr<'src>> into an owned tree, and intern identifiers as a Symbol type (via salsa::interned) from the start rather than starting with plain owned Strings. Reasoning: interned symbols give stable identity across revisions, which is what makes structural Eq on the lowered tree actually early-cutoff unrelated queries, and Step 2's type checker will want Symbol-shaped identifiers for the symbol table anyway -- deferring interning just means redoing this once Step 2 lands.

Scope: define the lowering module/pass and the Symbol interned type; everything else in the lowered tree stays plain owned data for now.

twill-parser's Expr<'src> is zero-copy, borrowing from the source &str. Salsa's tracked-struct outputs need to be cheaply Eq/hashable for early-cutoff, and threading twill-parser's 'src lifetime through salsa's 'db-bound tracked structs fights the framework for no benefit. Decided in #1's discussion: immediately after parsing, lower the borrowed Spanned<Expr<'src>> into an owned tree, and intern identifiers as a Symbol type (via salsa::interned) from the start rather than starting with plain owned Strings. Reasoning: interned symbols give stable identity across revisions, which is what makes structural Eq on the lowered tree actually early-cutoff unrelated queries, and Step 2's type checker will want Symbol-shaped identifiers for the symbol table anyway -- deferring interning just means redoing this once Step 2 lands. Scope: define the lowering module/pass and the Symbol interned type; everything else in the lowered tree stays plain owned data for now.
jacksonopp added this to the twill project 2026-08-20 19:06:38 +00:00
jacksonopp removed this from the twill project 2026-10-04 02:28:22 +00:00
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jacksonopp/twill#43
No description provided.