54 matches across 1 files for func main lang:Markdown lang:Markdown path:compiler/docs/rust-port/rust-port-0004-build-hir.md
snippet_mode: auto · sorted by relevance
compiler/docs/rust-port/rust-port-0004-build-hir.md MARKDOWN 54 matches · showing 5 view file →
7The Rust port should be structurally as close to the TypeScript as possible: viewing the TS and Rust side by side, the logic should look, read, and feel similar while working naturally in Rust.
8
9**Current status**: M1-M13 fully implemented. All statement types, expression types, destructuring, function expressions, JSX, switch/try-catch, for-of/in, optional chaining, and recursive lowering are complete. No `todo!()` stubs remain. `cargo check` passes. Remaining work: test against fixtures and fix divergences from TypeScript output.
10
11**Known issues to fix:**
· · ·
12- All collection types must use `IndexMap`/`IndexSet` (from the `indexmap` crate), not `BTreeMap`/`BTreeSet`/`HashMap`/`HashSet`. This is critical for `HIR.blocks` where `BTreeMap` destroys RPO insertion ordering.
13- Functions `lower_function`, `lower_function_to_value`, `gather_captured_context`, `lower_object_property_key`, `lower_type` take `&Expression`. The AST crate uses `Expression` for keys and doesn't have standalone `Function`/`ObjectPropertyKey`/`TypeAnnotation` types, so `&Expression` is correct for the current AST structure. When these functions are implemented, they should pattern-match on the specific expression variants internally.
14- `VariableBinding::Identifier.binding_kind` is `String` — must be a `BindingKind` enum.
15- `HirBuilder` is missing `component_scope: ScopeId` field (needed for `gather_captured_context` in M9).
· · ·
33 Cargo.toml
34 src/
35 lib.rs # HIR types: HirFunction, BasicBlock, Instruction, Terminal, Place, etc.
36 environment.rs # Environment struct (arenas, counters, config)
37 react_compiler_diagnostics/
· · ·
57### 1. No NodePath — Work Directly with AST Structs + ScopeInfo
58
59The TypeScript `lower()` takes a `NodePath<t.Function>` and uses Babel's traversal API (`path.get()`, `path.scope.getBinding()`, etc.) extensively. The Rust port works with deserialized `react_compiler_ast` structs and the `ScopeInfo` from step 2.
60
61**TypeScript pattern:**
· · ·
62```typescript
63function lowerStatement(builder: HIRBuilder, stmtPath: NodePath<t.Statement>) {
64 switch (stmtPath.type) {
65 case 'IfStatement': {
+ 49 more matches in this file
Search syntax
auth loginboth terms (AND is implicit)
auth OR logineither term
NOT path:vendorexclude matches
"exact phrase"quoted exact match
/func\s+Test/regex
handler~1fuzzy (Levenshtein 1)
file:*_test.gofilename glob
path:pkg/auth/**full path glob
lang:golanguage filter

Search any public repo from your terminal

This page calls POST /api/v1/code_search. Same tool, available over MCP for Claude/Cursor/Copilot.