Skip to content

Add analysis crate + la_arena#153

Merged
0xGeorgii merged 18 commits intomainfrom
add-analysis-crate
Mar 12, 2026
Merged

Add analysis crate + la_arena#153
0xGeorgii merged 18 commits intomainfrom
add-analysis-crate

Conversation

@0xGeorgii
Copy link
Copy Markdown
Contributor

@0xGeorgii 0xGeorgii commented Mar 2, 2026

Closes #37 #156

@0xGeorgii 0xGeorgii self-assigned this Mar 2, 2026
@0xGeorgii 0xGeorgii added static analysis Static code analysis refactoring Project supplements labels Mar 2, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 2, 2026

@0xGeorgii 0xGeorgii force-pushed the add-analysis-crate branch from 60e5f6e to befbb33 Compare March 6, 2026 08:09
0xGeorgii added 12 commits March 6, 2026 19:03
- Renamed `AnalysisError` to `AnalysisDiagnostic` for clarity.
- Updated the `Rule` trait and all implementing rules to use `AnalysisDiagnostic`.
- Changed the return type of the `analyze` function to return `Result<AnalysisResult, AnalysisErrors>`.
- Modified the `all_rules` function to return a static slice of rules instead of a vector of boxed rules.
- Enhanced the walker context to track the kind of non-deterministic blocks.
- Updated CLI output to display findings more succinctly.
- Adjusted tests to reflect the new diagnostic structure and ensure correctness.
- Removed unnecessary line breaks and adjusted formatting in type checker tests for better readability.
- Simplified function calls and expressions by consolidating match statements into single lines.
- Enhanced clarity in assertions and checks throughout the type inference tests.
- Streamlined utility functions by removing redundant code and improving consistency in function signatures.
- Ensured consistent formatting across various test files to adhere to coding standards.
@0xGeorgii 0xGeorgii marked this pull request as ready for review March 12, 2026 04:48
@0xGeorgii 0xGeorgii requested a review from Copilot March 12, 2026 04:48
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a new inference-analysis crate and wires an analyze phase into the compiler pipeline, while also migrating the AST and downstream crates/tests to a new typed-index, arena-backed representation.

Changes:

  • Add inference-analysis crate with rule-based control-flow diagnostics and shared AST walker.
  • Refactor AST storage/API to AstArena + typed IDs (DefId, StmtId, etc.) and update type-checker/codegen accordingly.
  • Update tests and docs to align with the new AST and analysis pipeline.

Reviewed changes

Copilot reviewed 51 out of 64 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
tests/src/type_checker/features.rs Updates generic parsing tests to traverse the new arena/typed ID AST.
tests/src/lib.rs Registers the new analysis test module.
tests/src/codegen/wasm/loops.rs Adjusts cov_mark expected counts after codegen changes.
tests/src/codegen/wasm/algo_iter.rs Adjusts cov_mark expected counts after codegen changes.
tests/src/codegen/wasm/algo_array.rs Adjusts cov_mark expected counts after codegen changes.
tests/src/ast/primitive_type.rs Migrates primitive type parsing tests to new typed arena representation.
tests/src/analysis/mod.rs Adds analysis test module wiring.
tests/Cargo.toml Adds dependency on inference-analysis for tests.
core/wasm-codegen/src/lib.rs Updates typed-AST traversal to use arena + DefId and new helper APIs.
core/wasm-codegen/docs/arrays-and-memory.md Updates documentation to reflect new variable name threading approach.
core/type-checker/src/typed_context.rs Migrates TypedContext to new AstArena + typed NodeId; simplifies API surface.
core/type-checker/src/type_info.rs Updates type conversion to work with arena-allocated TypeNode via TypeId.
core/type-checker/src/symbol_table.rs Updates symbol registration to consume TypeInfo/arena IDs and refactors scope refs.
core/type-checker/src/lib.rs Updates public docs and type-check entrypoint to accept AstArena.
core/type-checker/docs/api-guide.md Removes outdated docs for APIs removed from TypedContext.
core/inference/src/lib.rs Integrates new analysis phase and exposes analysis result/error types.
core/inference/Cargo.toml Adds dependency on inference-analysis.
core/cli/src/main.rs Updates CLI to run analysis and print findings/errors with new types.
core/ast/src/parser_context.rs Migrates multi-file parsing skeleton to new AstArena.
core/ast/src/nodes_impl.rs Replaces old node helper impls with AstArena query helpers for new representation.
core/ast/src/nodes.rs Replaces macro-based node model with typed-ID-based node wrappers/enums.
core/ast/src/lib.rs Updates crate docs/public modules to reflect AstArena design and adds typed IDs module.
core/ast/src/la_arena/mod.rs Vendors rust-analyzer’s la-arena implementation for typed arena indices.
core/ast/src/la_arena/map.rs Vendors rust-analyzer’s ArenaMap implementation.
core/ast/src/ids.rs Introduces typed ID aliases and NodeId enum for heterogeneous references.
core/ast/src/extern_prelude.rs Updates external module parsing to use AstArena.
core/ast/src/enums_impl.rs Removes obsolete helper impls tied to the old AST model.
core/ast/src/arena.rs Replaces old hash-map arena with typed AstArena and provides new query/source APIs.
core/ast/docs/location.md Updates location/source retrieval docs for AstArena + NodeId.
core/ast/README.md Updates README to reflect typed arena design and new usage patterns.
core/analysis/src/walker.rs Adds shared statement walker with loop/non-det depth tracking + tests.
core/analysis/src/rules/return_inside_nondet_block.rs Adds rule A005 preventing return inside non-det blocks.
core/analysis/src/rules/return_inside_loop.rs Adds rule A003 preventing return inside loops.
core/analysis/src/rules/mod.rs Registers all analysis rules.
core/analysis/src/rules/infinite_loop_without_break.rs Adds rule A004 detecting infinite loops missing a reachable break.
core/analysis/src/rules/break_outside_loop.rs Adds rule A001 preventing break outside loops.
core/analysis/src/rules/break_inside_nondet_block.rs Adds rule A002 preventing break inside non-det blocks.
core/analysis/src/rule.rs Introduces Rule trait and rule! macro for rule declarations.
core/analysis/src/lib.rs Implements analyze() orchestration over registered rules.
core/analysis/src/errors.rs Adds diagnostics, error/result aggregation, and display formatting.
core/analysis/README.md Documents analysis crate architecture, rules, and output format.
core/analysis/Cargo.toml Adds new inference-analysis crate metadata + dependencies.
Cargo.toml Adds inference-analysis to workspace dependencies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/ast/src/arena.rs
Comment thread core/analysis/src/walker.rs
Comment thread core/type-checker/src/symbol_table.rs
Comment thread core/type-checker/src/symbol_table.rs
Comment thread core/ast/src/la_arena/mod.rs
Comment thread core/analysis/src/walker.rs
Comment thread core/type-checker/src/typed_context.rs Outdated
Comment thread tests/src/lib.rs
@0xGeorgii 0xGeorgii linked an issue Mar 12, 2026 that may be closed by this pull request
@0xGeorgii 0xGeorgii changed the title Add analysis crate Add analysis crate + la_arena Mar 12, 2026
@0xGeorgii 0xGeorgii merged commit 14107e7 into main Mar 12, 2026
6 checks passed
@0xGeorgii 0xGeorgii deleted the add-analysis-crate branch March 12, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Project supplements static analysis Static code analysis

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add analysis crate Consider adopting Arena from rust analyzer

2 participants