Skip to content

Commit 1c235f1

Browse files
authored
deps: upgrade rowan 0.16 → 0.17 (#1451)
## Summary Closes #1448. Upgrade `rowan` from 0.16.1 to **0.17.0** in `assura-parser` and `assura-fmt`. ### Breaking changes in 0.17 (from upstream) Rowan 0.17 removed mutable syntax edit APIs (`SyntaxNodeMut` / in-place tree mutation). Assura only: - builds green trees via `GreenNodeBuilder` + events - wraps them with `SyntaxNode::new_root` - walks immutable `SyntaxNode` / `NodeOrToken` for lowering and formatting No call-site code changes were required; compile and tests are green as-is. ### Docs AGENTS.md and `docs/INTERNALS.md` version notes updated for 0.17 and the immutable-only API. ## Test plan - [x] `cargo check -p assura-parser -p assura-fmt --locked` - [x] `cargo test -p assura-parser --locked` (lib + integration, including demos/fixtures snapshots) - [x] `cargo test -p assura-fmt --locked` - [x] `cargo test -p assura-types --locked --lib` - [x] `cargo clippy -p assura-parser -p assura-fmt --locked -- -D warnings` - [x] `assura check` demos: libwebp-huffman, heartbleed, showcase-echo - [ ] CI green --------- Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
1 parent 290eb14 commit 1c235f1

6 files changed

Lines changed: 37 additions & 29 deletions

File tree

AGENTS.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -532,17 +532,25 @@ Keep dependencies up to date. Run `cargo outdated -R` periodically.
532532

533533
| Crate | Version | Notes |
534534
|-------|---------|-------|
535-
| rowan | 0.16 | stable, upgrades OK |
535+
| rowan | 0.17 | immutable CST only (0.17 removed mutable edit APIs; Assura never used them) |
536536
| ariadne | 0.6 | Report::build takes (kind, span) with 2 args; span is (Id, Range) |
537537
| logos | 0.16 | stable, upgrades OK |
538538
| z3 | 0.20 | No lifetime params on AST types; no &ctx first arg; pre-generated FFI bindings |
539539
| sha2 | 0.11 | Uses digest 0.11, high-level API unchanged |
540540
| cvc5 | 0.4 | Native FFI bindings; `Sort` not Copy; `Kind` names differ from SMT-LIB2; requires `features = ["static"]` for static linking |
541541

542-
**rowan 0.16 patterns**: `GreenNodeBuilder`, `SyntaxNode::new_root()`,
542+
**rowan 0.17 patterns**: `GreenNodeBuilder`, `SyntaxNode::new_root()`,
543543
`Language` trait on `AssuraLanguage`, `SyntaxKind` enum with `From<u16>`.
544544
The parser uses an events/markers pattern (Open/Close/Advance) with
545-
Pratt parsing for expressions.
545+
Pratt parsing for expressions. Rowan 0.17 removed mutable syntax APIs
546+
(`SyntaxNodeMut` / in-place tree edit); Assura only builds green trees
547+
and reads them immutably, so no call-site changes were required.
548+
549+
**Downstream crates must not depend on `rowan` directly.** `assura-fmt`
550+
walks CST children with `as_token()` / `as_node()` only. Matching on
551+
`rowan::NodeOrToken` while depending on a separate `rowan` crate version
552+
breaks `cargo package` when crates.io `assura-parser` still pins an
553+
older rowan (dual type instances). Keep rowan private to `assura-parser`.
546554

547555
**z3 0.20 patterns**: No lifetime params (`Bool`, not `Bool<'ctx>`).
548556
No `&ctx` first arg on constructors (`Int::from_i64(n)`, not
@@ -665,7 +673,7 @@ These are final. Do not revisit without explicit discussion.
665673
|----------|--------|-----------|
666674
| Compiler language | Rust | docs/INVESTIGATION.md |
667675
| Lexer | logos 0.16 | Fast, derive macro |
668-
| Parser | rowan 0.16 CST + hand-written recursive descent | Lossless CST, Pratt expressions |
676+
| Parser | rowan 0.17 CST + hand-written recursive descent | Lossless CST, Pratt expressions |
669677
| Error display | ariadne 0.6 | Colored spans |
670678
| SMT solver | Z3 primary (z3 crate), CVC5 fallback | docs/ROADMAP.md |
671679
| Codegen target | Rust source via prettyplease | NOT syn/quote |

Cargo.lock

Lines changed: 12 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/assura-fmt/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ categories.workspace = true
1111

1212
[dependencies]
1313
assura-parser = { version = "0.4.0", path = "../assura-parser" }
14-
rowan = "0.16"

crates/assura-fmt/src/lib.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,13 @@ pub fn format_source_file(_file: &assura_parser::ast::SourceFile) -> String {
123123
// ---------------------------------------------------------------------------
124124

125125
/// Collect all leaf tokens from the CST in document order.
126+
///
127+
/// Use `as_token` / `as_node` (not `rowan::NodeOrToken` match arms) so this
128+
/// crate does not depend on a concrete `rowan` version. Packaging against
129+
/// crates.io `assura-parser` would otherwise dual-link rowan 0.16 + 0.17.
126130
fn collect_leaf_tokens(node: &assura_parser::syntax_kind::SyntaxNode) -> Vec<(SyntaxKind, String)> {
127131
let mut tokens = Vec::new();
128-
for child in node.children_with_tokens() {
129-
match child {
130-
rowan::NodeOrToken::Token(tok) => {
131-
tokens.push((tok.kind(), tok.text().to_string()));
132-
}
133-
rowan::NodeOrToken::Node(n) => {
134-
collect_leaf_tokens_into(&n, &mut tokens);
135-
}
136-
}
137-
}
132+
collect_leaf_tokens_into(node, &mut tokens);
138133
tokens
139134
}
140135

@@ -143,13 +138,10 @@ fn collect_leaf_tokens_into(
143138
tokens: &mut Vec<(SyntaxKind, String)>,
144139
) {
145140
for child in node.children_with_tokens() {
146-
match child {
147-
rowan::NodeOrToken::Token(tok) => {
148-
tokens.push((tok.kind(), tok.text().to_string()));
149-
}
150-
rowan::NodeOrToken::Node(n) => {
151-
collect_leaf_tokens_into(&n, tokens);
152-
}
141+
if let Some(tok) = child.as_token() {
142+
tokens.push((tok.kind(), tok.text().to_string()));
143+
} else if let Some(n) = child.as_node() {
144+
collect_leaf_tokens_into(n, tokens);
153145
}
154146
}
155147
}

crates/assura-parser/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ categories.workspace = true
1313
assura-ast = { version = "0.4.0", path = "../assura-ast" }
1414
assura-diagnostics = { version = "0.4.0", path = "../assura-diagnostics" }
1515
logos = "0.16"
16-
rowan = "0.16"
16+
rowan = "0.17"
1717

1818
[dev-dependencies]
1919
insta = "1"

docs/INTERNALS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Source (.assura)
1515
Lexer (logos 0.16) crates/assura-parser/src/lexer.rs
1616
| produces tokens via logos derive
1717
v
18-
Parser (rowan 0.16 CST) crates/assura-parser/src/cst.rs
18+
Parser (rowan 0.17 CST) crates/assura-parser/src/cst.rs
1919
| hand-written recursive descent + Pratt expression parsing
2020
| produces GreenNode (lossless concrete syntax tree)
2121
v
@@ -47,7 +47,7 @@ optionally invokes `cargo check` on the generated Rust project.
4747

4848
| Crate | LOC | Tests | Purpose |
4949
|-------|-----|-------|---------|
50-
| `assura-parser` | 8,100 | 149 | Lexer (logos 0.16), CST (rowan 0.16), recursive descent parser, Pratt expressions, CST-to-AST lowering |
50+
| `assura-parser` | 8,100 | 149 | Lexer (logos 0.16), CST (rowan 0.17), recursive descent parser, Pratt expressions, CST-to-AST lowering |
5151
| `assura-resolve` | 4,300 | 91 | Name resolution, scope analysis, symbol table |
5252
| `assura-types` | 33,800 | 1,081 | Type checking, 50+ domain-specific checkers |
5353
| `assura-smt` | 13,800 | 397 | Z3/CVC5 SMT solver integration, verification |
@@ -559,7 +559,7 @@ cargo fmt --all && cargo clippy --workspace -- -D warnings && cargo test --works
559559
| Library | Version | Used For |
560560
|---------|---------|----------|
561561
| logos | 0.16 | Lexer (derive macro) |
562-
| rowan | 0.16 | Lossless concrete syntax tree |
562+
| rowan | 0.17 | Lossless concrete syntax tree (immutable; no mutable edit APIs) |
563563
| ariadne | 0.6 | Error display |
564564
| z3 | 0.20 | SMT solver bindings (optional, behind `z3-verify` feature) |
565565
| prettyplease | 0.2 | Rust source formatting in codegen |

0 commit comments

Comments
 (0)