Compare commits

...
11 Commits
Author SHA1 Message Date
lucioandClaude Fable 5.1 23e2e4bca5 Release 0.55.0 — loop 3 round 2: references reach a module's internals across files; a stale index omits, never mislocates
ci / checks (push) Successful in 1m11s
ci / corpus (push) Successful in 33s
release / build-and-publish (push) Successful in 9m37s
Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-17 14:36:35 -07:00
lucioandClaude Fable 5.1 a2a22adad8 Cross-file references reach a module's nets, variables and instances (§64.1, QA task_d8afe80f of §63.1): nav.rs's two index questions (leaves_this_file, indexed_def_in_file, the latter shared with hover's live_symbol) asked WorkspaceIndex::member — the connection surface, ports and parameters — so a declaration only a hierarchical path can name (a bind connection's expression half, a u_x.sig tail) was judged unable to leave its file and references fell to the single-file answer, while a rename already edited both files; from a use that did resolve cross-file, the declaring buffer's own uses could not re-identify themselves. Both now ask member_in(…, Surface::Hierarchical); the connection answer comes first and whole from that read, so every port/parameter/package/class/struct answer is byte-identical (nav harness controls and a 948-declaration opentitan census). A hierarchical-only member has no Local postings by the §49 ruling, so nav::declaring_file_uses parses exactly the closed declaring file once per request (0.4–1.5 ms on state_q into a shut entropy_src_main_sm.sv), hierarchical_only asking the index's own table rather than restating surface_of. Three QA rounds (Sonnet, Sonnet, then Fable per the escalation rule): the closed-file path read a cached FileView and rendered against a fresh text_of (a stale offset on a wrong line) — now one fresh read per closed file threaded to the rendering step; every index-time span about a closed file, and the open-buffer declaration fallback (nav::declaration_site), guarded by hover::spells_exactly (pub(crate), shared not copied): a stale index may omit a location, never mislocate one. Accepted: +25 % on a local-net references in a 40 267-line buffer (1.22 → 1.54 ms), the guard is textual (a different exact token at a deleted declaration's old bytes). opentitan: entropy_masking_req from aes.sv now lists aes_bind.sv; state_q lists entropy_src_core.sv; checkout untouched. Tests 4422 → 4459 (11 dev + 1 hover + 1 e2e wire test; 19 QA attacks incl. escaped identifiers, UTF-8 boundaries, a deleted declaring file, oracle equivalence with vlog_refactor::find_references); fmt, clippy, workspace suite green through tools/guard.sh. Feature README docs/features/references-hierarchical-surface; references-nav, hierarchical-tail and hover-declarations READMEs, record.rs's postings comment and the topo row amended; perf entry in docs/perf/README.md. Release 0.55.0 left to the owner.
ci / checks (push) Successful in 1m14s
ci / corpus (push) Successful in 36s
Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-12 14:50:16 -07:00
lucioandClaude Fable 5.1 9d1eb1671e TODO §64: loop 3 round 2 — cross-file references for hierarchical-surface-only declarations
ci / checks (push) Successful in 1m11s
ci / corpus (push) Successful in 33s
Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-12 13:01:38 -07:00
lucioandClaude Fable 5.1 5d70cb89cc TODO §63.3: 0.54.0 verified — loop 3 round 1 closed
ci / checks (push) Successful in 1m11s
ci / corpus (push) Successful in 32s
Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-12 03:23:09 -07:00
lucioandClaude Fable 5.1 da32237a0e Release 0.54.0 — loop 3 round 1: rename edits bind files; first request after an edit −19 %
ci / checks (push) Successful in 1m9s
ci / corpus (push) Successful in 33s
release / build-and-publish (push) Successful in 6m58s
Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-12 03:13:40 -07:00
lucioandClaude Fable 5.1 c82978c3db First request after an edit −19 % (§63.2, N1 of the 0.52.0 review): the flush split on the timing line (rebuild{lex parse defines analyze external lines publish documents}) named lex 29 + parse 26 of a 100 ms flush and no second lint or analysis; the lexer's two phases fused (the intermediate Vec<RawTok> gone), Parser::skip for the 178 bump() sites that discarded the token, a first-byte test in front of the operator table (tokenize 27.8 → 11.6 ms). Pinmux first menu after didChange 109 → 88 ms paired; every other row within noise; RSS not up. Token stream, diagnostics, AST and symbols digested over 4 807 files: 0 differ (re-derived by QA against a rebuilt 1b8723c); five gap fuzzers at their pins; corpus and opentitan byte-identical. Lead: an orphan trailing comment leads the next token instead of vanishing (unreachable, kept as a rule). QA: 16 attack tests, the flat-groups guard the harness relies on.
ci / checks (push) Successful in 1m16s
ci / corpus (push) Successful in 34s
Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-12 03:11:59 -07:00
lucioandClaude Fable 5.1 1b8723ca1f Rename edits and warns about a bind file's own occurrences (§63.1): a bind connection's bare name is a reference on the target's hierarchical surface under target::name (the resolver asked the connection surface — ports and parameters — so an internal net resolved to nothing and, with no name on the path, was never warned about); a hierarchical path in a bind connection is rooted at the bind target (Target::BindMember, walking descend/member_at shared with member_of); a multi-segment target is spelled tb::u_aes for follow_one; FACTS_FORMAT 19 → 20 (a 0.53.0 store rebuilds once); selection was never the gap. Parity: every difference against 0.53.0 is a bind file's new edit or warning (1 758 − 8 = 1 750 sentences held), tail rename 326 ms. 16 engine fixtures (QA's six attacks included), a preflight-parity fixture, a wire-level definition/references test; QA filed the pre-existing nav.rs references gap for loop 3.
ci / checks (push) Successful in 1m9s
ci / corpus (push) Successful in 34s
Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-12 01:05:14 -07:00
lucioandClaude Fable 5.1 2675131f8c TODO §63: loop 3 round 1 — the bind rename gap (63.1), N1 first-after-edit (63.2)
ci / checks (push) Successful in 1m7s
ci / corpus (push) Successful in 33s
Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-11 23:08:51 -07:00
lucioandClaude Fable 5.1 409acae087 TODO: correct the §61.3 closing note (the metadata hand-off shipped)
ci / checks (push) Successful in 1m6s
ci / corpus (push) Successful in 32s
Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-11 23:04:02 -07:00
lucioandClaude Fable 5.1 f5edac9197 TODO: tick the two loop-3 lines §61.2/§61.3 already closed
ci / checks (push) Successful in 1m8s
ci / corpus (push) Successful in 31s
Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-11 23:03:48 -07:00
lucio 7df86fe979 TODO §62.4: 0.53.0 verified — the 0.52.0 review closed
ci / checks (push) Successful in 1m14s
ci / corpus (push) Successful in 39s
2026-09-09 17:50:49 -05:00
53 changed files with 6562 additions and 379 deletions

No files matched your search

+80
View File
@@ -4,6 +4,86 @@ All notable changes to lucisv are recorded here. Versions follow
[semantic versioning](https://semver.org/); until 1.0 the CLI's exit codes
(see `README.md`) are the only frozen contract.
## 0.55.0 — 2026-09-17
### Loop 3, round 2 — find-references reaches a module's internals
- **References see every cross-file use of a module's nets, variables
and instances.** With `module leaf` declaring `logic sig` and another
file writing `assign w = u_leaf.sig;` (or a `bind` directive naming
`sig` in a connection), Find All References from the declaration
answered `leaf.sv` alone — while a rename already edited both files.
The two index questions behind references asked the module's
*connection* surface (ports and parameters), which cannot hold an
internal net; they now ask the *hierarchical* surface, the one a path
in another file actually reaches the declaration by. Every answer for
a port, parameter, package member, class field or struct field is
byte-for-byte what it was. Hover's declaration snippet uses the same
lookup and now shows the live line for such a signal in an edited
buffer. On the opentitan tree, references on `aes.sv`'s
`entropy_masking_req` now list `aes_bind.sv`, and `state_q` in
`entropy_src_main_sm.sv` lists its use in `entropy_src_core.sv`.
(`docs/features/references-hierarchical-surface/README.md`.)
- **A closed declaring file's own uses are in the answer.** The index
deliberately posts no in-file references for a module's internal
signals (a table sized by every RTL body, for a rarely asked
question), so a request from another file into a declaring file
nobody has open used to list the cross-file sites and silently omit
that file's own `assign … = sig;` lines. That one file is now parsed
once, on exactly that request shape — 0.4–1.5 ms on a real design
file, the same trade a rename already makes.
- **A stale index may omit a location; it can never point at a wrong
line.** Three QA rounds found that a span recorded at index time, or
computed against one read of a closed file, could be rendered against
a different read of the same file after an external edit (another
tool, `git checkout`, a build step) and land on a line that no longer
holds the name. Each closed file is now read exactly once per
request, and every index-time span — closed files and the
open-buffer declaration fallback alike — must still spell the name
exactly where it is rendered, or it is dropped. Escaped identifiers,
UTF-8 boundaries, a deleted declaring file and a name that is both a
port and a net are covered by tests; references and rename are
asserted to agree with the whole-scope engine.
- Cost, accepted and recorded in `docs/perf/README.md`: a references
request on a heavily used local net in a 40 000-line buffer now
walks the indexed path, 1.22 → 1.54 ms median; every other harness
row unchanged.
## 0.54.0 — 2026-09-12
### Loop 3, round 1 — a rename correctness fix and a faster first edit
- **Rename edits a `bind` file's own occurrences.** Renaming a module's
internal net that a `bind` directive's connection names bare
(`bind aes chk u (.req(entropy_masking_req))`), or reaches by a
hierarchical path (`u_aes_core.u_aes_prng_clearing.seed_en`), used to
leave the bind file untouched and say nothing — the design no longer
elaborated after the rename. The resolver had asked the bind target's
connection surface (ports and parameters) for a bare name, and rooted a
bind's hierarchical path in the scope the directive is written in,
which declares nothing. A bind connection is now a reference on the
target's hierarchical surface, a bind's path is rooted at the target
(a multi-segment target such as `bind tb.u_aes …` included), and an
occurrence the engine cannot resolve is warned about by file and line,
never silent. Definition, hover and references answer over bind files
the same way. The index store format is bumped (`FACTS_FORMAT` 20): a
0.53.0 store is rebuilt once. (Found by the previous round's QA on the
opentitan tree.)
- **The first request after an edit is ~19 % faster.** On a 40 000-line
generated register file the first code-action menu after a
one-character change costs 88 ms instead of 109: the lexer's raw and
comment-attachment phases are fused (no intermediate token vector), the
parser no longer clones a token it is about to discard, and the
operator table is filtered by first byte before the longest-match
scan. Token stream, diagnostics, AST and symbols are byte-for-byte what
they were over 4 807 files; every formatter and linter output is
identical.
- `--verbose` timing lines carry a third group, `rebuild{…}`, that splits
the document rebuild after an edit into its stages.
- Known remainder, filed: cross-file *references* from a module's
internal net (bind or not) still stop at the connection surface; the
rest of the rebuild (the token clone, analysis, external resolution).
## 0.53.0 — 2026-09-09
### The 0.52.0 review — one correctness fix
Generated
+8 -8
View File
@@ -97,7 +97,7 @@ dependencies = [
[[package]]
name = "lucisv"
version = "0.53.0"
version = "0.55.0"
dependencies = [
"lucisv_core",
"rayon",
@@ -108,11 +108,11 @@ dependencies = [
[[package]]
name = "lucisv_core"
version = "0.53.0"
version = "0.55.0"
[[package]]
name = "lucisv_server"
version = "0.53.0"
version = "0.55.0"
dependencies = [
"lsp-server",
"lsp-types",
@@ -248,14 +248,14 @@ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]]
name = "vlog_formatter"
version = "0.53.0"
version = "0.55.0"
dependencies = [
"vlog_parser",
]
[[package]]
name = "vlog_linter"
version = "0.53.0"
version = "0.55.0"
dependencies = [
"lucisv_core",
"vlog_formatter",
@@ -265,11 +265,11 @@ dependencies = [
[[package]]
name = "vlog_parser"
version = "0.53.0"
version = "0.55.0"
[[package]]
name = "vlog_refactor"
version = "0.53.0"
version = "0.55.0"
dependencies = [
"vlog_formatter",
"vlog_parser",
@@ -278,7 +278,7 @@ dependencies = [
[[package]]
name = "vlog_semantic"
version = "0.53.0"
version = "0.55.0"
dependencies = [
"vlog_parser",
]
+1 -1
View File
@@ -12,7 +12,7 @@ members = [
]
[workspace.package]
version = "0.53.0"
version = "0.55.0"
authors = ["Guoliang Chen"]
edition = "2021"
license = "MIT"
+291 -4
View File
@@ -4733,6 +4733,19 @@ in 0.49.0. Take 4's findings are in the loop-3 list above.
extract/inline/imports/ports/references — the resolves and the extract
edit are the candidates, the 805 ms refusal is after the build); the
31 ms store decode the one-place tie costs.
- **§63.1 QA (2026-09-12, pre-existing, `task_d8afe80f`):** cross-file
`references` cannot see a hierarchical-surface-only declaration (a
module's net, variable or instance), bind or not — `nav.rs`'s
`leaves_this_file` and `indexed_def_in_file` (shared with hover) ask
`WorkspaceIndex::member`, the connection surface; the fix is the
hierarchical-surface lookup in both call sites plus a fixture sweep
across definition/references/hover/documentHighlight.
- **§63.2 filed (2026-09-12):** the rest of the first-after-edit flush —
the token clone into `parse_tolerant` (3.9 ms; the parser mutates the
stream it is given, and `Document::tokens` is read for comments by
semantic tokens and the linter), `analyze` (9.4 ms), `resolve_external`
(4.7 ms against the 3 975-file index), and ~6 ms dropping the previous
revision's products on the request path (drop it after answering).
Sections after §46 are planned when reached.
## 45. Small items, round 4 (planned 2026-09-05) — topo §2.9-29, 30, 17, 22
@@ -5855,9 +5868,10 @@ document revision, computed only when a fix needs it
— residues named, not hidden: the declaring file's parse (2.2–2.4 ms
of the ports offer's 3.27) and the buffer's own share of the imports
index (~0.8 ms), the second a `vlog_semantic` handshake request
- [ ] lead ruling on a lint-result reuse item (new, from P1b's number:
- [x] lead ruling on a lint-result reuse item (new, from P1b's number:
24.0 ms, the whole of the pinmux row, for a client that sends no
`only`) — a keyed cache in §59's shape, not this lane's to add
— **closed by §61.2 (0.52.0): `lint_snapshot.rs`**
- [x] QA (P1c): the every-offset parity suites re-attacked, the two
counters sabotaged, the numbers re-taken on the same binary
— 2026-09-07: ports side clean (three refusal fixtures old vs new
@@ -6158,13 +6172,15 @@ semantic build/facts owners. Serialized after 60.1–60.3.
true with no scan running), and the include graph and completion
tables against a text-built pair on a tree with duplicate
spellings and `+incdir+`s
- [ ] the walk, filed by P4b3 for the next lane: `discovery` is 158 ms of
- [x] the walk, filed by P4b3 for the next lane: `discovery` is 158 ms of
scope walk plus one `fs::metadata` per file for the size cap, and
it is the floor under every first useful answer. Two things to
measure before building anything — the cap taking its size from the
walk's own metadata (`lucisv_core::walk::collect_files` is not
P4b3's file: a handshake request) and handing the first folder to
`scan_step` before the walk has finished the workspace
— **closed by §61.3 (0.52.0): two-phase discovery and the walk
metadata hand-off (per-file `stat`s 3 979 → 0, cap 6.92 → 0.10 ms)**
- [x] QA (P4a only, 2026-09-08: gates green, 4272/4272, no behaviour
change verified by hunk review and by running both binaries —
44/44 identical result_counts and identical scan file-counts;
@@ -6644,5 +6660,276 @@ per publication. Filed with the review's baselines; not started.
### 62.4 Closing
- [ ] `docs/perf/README.md` note; topo (the walk tracker); release 0.53.0
with assets verified
- [x] `docs/perf/README.md` note; topo (the walk tracker); release 0.53.0
with assets verified — done 2026-09-09: **0.53.0** (b4a0668,
v0.53.0), 8 assets, the darwin-arm64 vsix at 0.53.0 with both
binaries, `hierarchySections.js`, `extract.js`, no `*_test.js`.
## 63. Loop 3, round 1 (planned 2026-09-11) — the `bind` rename gap, then N1
Two lanes, serial, in the main tree (§36's protocol: one dev (Opus), then
one QA (Sonnet), then the lead's review; dev and QA both through
`tools/guard.sh`; no `sleep` over 60 s; no `pgrep -f`). Ships as 0.54.0.
### 63.1 A `bind` file's own occurrence of a renamed name (QA `task_834abda3`)
Found by §61.5's QA on the real opentitan tree, reproducible at HEAD and
unrelated to facts reuse. Renaming `entropy_masking_req` (a net declared in
`hw/ip/aes/rtl/aes.sv`) edits `aes.sv` but leaves `hw/ip/aes/dv/aes_bind.sv`'s
`.entropy_masking_req(entropy_masking_req)` — the expression half of a
connection inside `bind aes aes_reseed_if u_aes_reseed_if (…)`, which the
binder resolves in the bind target's scope (`Target::BindScope { target:
"aes" }`, `vlog_semantic/src/resolve.rs`) — neither edited nor warned about.
Renaming `seed_en` (declared in `aes_prng_clearing.sv`) leaves the same file's
two-level tail `u_aes_core.u_aes_prng_clearing.seed_en` neither edited nor
warned about, while §49's hierarchical tail from an ordinary instantiating
file (`u_entropy_src_main_sm.state_q` in `entropy_src_core.sv`) is edited.
The whole-scope engine is the refusal authority, so a silent miss is a
wrong answer: after the rename the design no longer elaborates.
The contract to reach: an occurrence in a `bind` directive's connection is
**edited** when the engine resolves it to the renamed declaration — a bare
name in the bind target's scope, or a hierarchical path whose root is the
bind target (the target module, a `: u_x` instance list, or a hierarchical
target path) — through the same rungs an instantiating file's occurrences
use; **warned about** (file:line, the sentence shape `rename/warnings.rs`
already uses) when the name occurs in a `bind` connection the engine cannot
resolve; never silent. Source selection (`rename_sources_traced`'s rungs,
`module_select::hierarchical_users`, `files_mentioning`) must bring the
`bind` file in — find out which rung drops it before adding one. Refusal
parity with `rename_preflight` stays one-directional (the preflight may
refuse only what the engine refuses); `check/after.rs`'s rebinding check
runs over the edited `bind` file like any other.
Feature README: `docs/features/rename-bind-occurrences/README.md`. Files:
`crates/vlog_refactor/src/{rename/,references.rs,scope.rs,check/}`,
`crates/vlog_semantic/src/{resolve.rs,workspace/}` only if a resolver rung is
missing (a Handshake entry in the README either way),
`crates/lucisv_server/src/{rename.rs,rename_trace.rs,module_select.rs,state/}`
for selection, `tools/perf/` only to add a fixture row. Nothing else.
- [x] the reproduction pinned first: engine-level fixtures in
`vlog_refactor` (a `bind` file beside the declaring file) for the
bare-name connection, the positional connection, the two-level tail,
a `: u_x` instance-list target, a hierarchical target path, a `bind`
inside a generate block (`if (…) begin : gen … end`), and one the
engine must *not* resolve (a bind whose target module is not in the
workspace) — each asserting today's silent miss, then flipped
- [x] the fix: occurrences resolved through `Target::BindScope` and tails
rooted at the bind target edited; unresolvable ones warned about;
the rung that dropped `aes_bind.sv` named in the README
- [x] parity: `renamewarn`'s 1 750 sentences and the 36-row `paired`
fingerprints re-taken against 0.53.0 — every difference is a `bind`
file's new edit or warning and is listed in the README, nothing else
moves; the eight rename shapes' timings within noise (the tail rename
≤ 330 ms median)
- [x] the three QA renames (`WidthPRDSBox`, `entropy_masking_req`,
`seed_en`) run against the real opentitan tree through
`rename_traced_with` under all three reuse modes: identical answers,
and `aes_bind.sv` now edited
- [x] QA: fixtures re-attacked (a `bind` whose connection names a
*different* declaration of the same name; the new name colliding in
the bind target's scope — refused; an escaped-name target; a
`defparam`-only bind file), parity re-derived, opentitan sweep
### 63.2 N1 — the first request after an edit (the 0.52.0 review, item 3)
The review's cell: `pinmux_reg_top.sv` (40 267 lines), one-character
`didChange`, then the all-family `codeAction` menu — **113.6 ms**, against
0.23 ms for the unchanged repeat. The lint snapshot cannot help a fresh
revision; what remains is the debounced `Document::new` the request wrapper
performs before any handler runs (`tokenize`, `parse_tolerant` over a clone
of the token stream, `collect_defines`, `analyze`, `resolve_external`,
`LineIndex::new`), the diagnostics publish that lints the new revision, and
the menu's own stages. `crate::lint_trace` already splits the request into
flush / config / build / lint / fence / serialize under `--verbose`; the
flush's inner stages are not yet split.
Target: ≥ 15 % off the first-after-edit cell (stretch < 95 ms) with the
AST, the diagnostics and the menu byte-identical; the unchanged-repeat cell
and every other `offeredit`/`offerkinds` row within noise; peak RSS not up.
Measure before building: split the flush in `lint_trace` (lex / parse /
defines / analyze / external / lines / publish-lint), take the numbers on
0.53.0, and go after the largest stage. Candidates, in the order the review
named them: the token-stream clone into `parse_tolerant` (borrow or hand
over, keeping `Document::tokens`), allocation in `tokenize`/`parse_tolerant`
for a 40 k-line generated file, `analyze`'s tables, `resolve_external`
against a 3 975-file index, a second lint of the same revision anywhere on
the path (the snapshot must serve both the publish and the menu — verify it
does). A change in `vlog_parser`'s public signatures is a Handshake in the
README and a topo row. No stopwatch assertions in tests.
Feature README: `docs/features/perf-first-after-edit/README.md`. Files:
`crates/lucisv_server/src/{lint_trace.rs,state/mod.rs,server/,diagnostics.rs,
code_action.rs}`, `crates/vlog_parser/src/{lexer.rs,parser/,lib.rs}`,
`crates/vlog_semantic/src/{analyze*,bind/}` only for a measured stage,
`tools/perf/` for the flush split rows. Nothing else.
- [x] the flush split in `lint_trace` and a harness row per stage; the
0.53.0 numbers in the README before any change — `Rebuild`'s seven
stages (`lex parse defines analyze external lines publish`) plus
`documents`, printed as a **third sibling group** `rebuild{…}` on
the `timing: codeaction` line, which `phases_r1.actionprofile`
picks up as `trace_rebuild_*` with no harness code change
(`phases_p2.parse_trace` flattens one level). **The 100 ms flush on
0.53.0: lex 29.1, parse 25.6, publish 22.2 (lint 22.0), analyze
10.1, external 4.8, lines 0.6, defines 0.5, ~7 dropping the old
revision.** Two of the review's candidates were answered by the
split: `action` reads `snapshot=hit`/`lint=0.00ms` (no second lint
of the revision) and `lint::context` already lends `doc.semantics`
(no second analysis)
- [x] the fix, one stage at a time, each with its before/after cell;
parser snapshot and idempotency suites green; corpus and opentitan
byte-identity gates — three changes, all in `vlog_parser`: the
lexer's two phases **fused** (the intermediate `Vec<RawTok>` gone;
`tokenize` 27.8 → 24.7 ms), **`Parser::skip`** for the 178
`bump()` sites that threw the token away (`parse_tolerant` 17.5 →
16.0 ms), and a **first-byte test in front of the 44-entry
operator table** (24.7 → **11.6 ms**, the largest single win).
Parity: token stream + parse diagnostics + whole AST + symbol
table digested per file over **4 807 files** (corpus + opentitan),
0 differ; `format --stdout` byte-identical over corpus (860) and
over opentitan (one tree digest, identical stderr); diagnostics
and the all-family + seven-family menus identical on the pinmux,
aes and tb buffers before and after an edit, including a revision
edited to *have* lint findings. 4 403 → **4 406 tests**
- [x] `offeredit`, `offerkinds`, `flush`, `diagnostics` phases paired
against 0.53.0 with the order alternated; RSS cell — the cell
**110.95 / 107.54 → 88.31 / 88.36 ms, −19.2 %**: the ≥ 15 % gate
met and the < 95 ms stretch met. The unchanged-repeat cell
(0.27/0.32 → 0.22/0.19) and every `offeredit`/`offerkinds`/
`flush`/`diagnostics` row are inside their own version's a/b
spread. RSS **not up**: warm flat (≈428 MiB both), cold scan
~25 MiB *lower* (506 → 480 MiB) — the `Vec<RawTok>` that is no
longer built; index store byte-identical at 45 468 KiB. Feature
README `docs/features/perf-first-after-edit/`; evidence and
runners in `~/.cache/lucisv-perf/63-2/`
- [x] QA: the trace's arithmetic re-derived, the parity attacked (a buffer
that fails to lex; a `` `define`` edit that changes the macro table;
an edit that moves a fence), the numbers re-taken
### 63.3 Closing
- [x] `docs/perf/README.md` entry; topo rows for every contract amended;
release 0.54.0 with assets verified — done 2026-09-12: **0.54.0**
(da32237, v0.54.0), 8 assets, the darwin-arm64 vsix at 0.54.0 with
both binaries, `hierarchySections.js`, `extract.js`, no `*_test.js`.
## 64. Loop 3, round 2 (planned 2026-09-12) — cross-file references for hierarchical-surface-only declarations
One lane. The dev half runs in the owner's spawned session
(`task_d8afe80f`, its own worktree); QA (Sonnet) and the lead's review run
on that result in the main tree after it lands. Same rules as §63: guard
every suite and sweep, no `sleep` over 60 s, no `pgrep -f`, opentitan
read-only. Ships as 0.55.0.
### 64.1 `references` stops at the connection surface (QA §63.1, `task_d8afe80f`)
`crates/lucisv_server/src/nav.rs`: `leaves_this_file` (~148) and
`indexed_def_in_file` (~235; `indexed_def_for_symbol` is shared with
`hover.rs`) decide whether a declaration can be referenced from another file
by `WorkspaceIndex::member(unit, name)` — the **connection** surface, ports
and parameters. A module's net, variable or instance lives on the
**hierarchical** surface only (`workspace/hierarchy.rs`, since 2026-09-05), so
both functions treat such a declaration as unable to leave its file. Two
symptoms, pinned by
`nav.rs::a_binds_connection_expression_is_reachable_by_definition_not_yet_by_references`:
`references` from the *declaration* of a hierarchically reached net falls to
the single-file fallback and never sees a cross-file use (a `bind`
connection or an ordinary `u_x.sig` tail alike); `references` from a *use*
that does resolve cross-file cannot re-identify the open buffer's own
in-file use of the same declaration, because `indexed_def_in_file` maps the
live symbol back the same wrong way. Not `bind`-specific; reproduced with a
plain `assign w = u_leaf.sig;`.
The contract to reach: a declaration's cross-file reachability is judged on
the surface a use can actually reach it by — `member_in(unit, name,
Surface::Hierarchical)` in both call sites (the connection answer is a prefix
of the hierarchical one, so package/class/struct members and ports keep
their answers byte-for-byte). `references_are_ambiguous` and the
single-record rule (`defs.len() != 1`) keep their meaning over the wider
answer — a name declared both as a port and as an internal net of the same
unit is ambiguous, not silently the port. Hover and definition, which share
`indexed_def_for_symbol`, must not change what they say for anything they
already answered. No new index field, so no `FACTS_FORMAT` bump; if one
turns out to be needed, say why in the README.
Feature README: `docs/features/references-hierarchical-surface/README.md`.
Files: `crates/lucisv_server/src/{nav.rs,hover.rs}` and the server's wire
tests (`server/tests/`), `crates/vlog_semantic/src/workspace/hierarchy.rs`
only if `member_in` needs a case it lacks (a Handshake entry either way).
Nothing else.
- [x] the fixture sweep first, asserting today's answers, then flipped:
`definition`, `references` (from the declaration and from each use,
`includeDeclaration` both ways), `hover`, `documentHighlight` over
(a) a `bind` connection's bare name, (b) a `u_x.sig` tail from an
instantiating file, (c) a two-level tail, (d) a port of the same
unit (unchanged answers), (e) a package member (unchanged), (f) a
name that is both a port and an internal net of one unit (ambiguous
— the single-file fallback, as today), (g) an unsaved buffer
(`untitled:`), (h) the open buffer's own in-file use seen from a
cross-file use
- [x] the fix in both call sites; the §63.1 QA test renamed to say what it
now asserts
- [x] on the real opentitan tree (read-only): `references` on
`entropy_masking_req` from `aes.sv` lists `aes_bind.sv`; on
`state_q` from `entropy_src_main_sm.sv` lists `entropy_src_core.sv`;
the `nav`/`navqueue` harness rows within noise (the hierarchical
lookup is one more map probe)
- [x] QA: fixtures re-attacked (a generate-scoped net; a net shadowed by a
port of the same name in a *different* unit; a class member — must
stay on the connection answer), opentitan census, gates. Verdict:
rework needed — three findings in the closed-declaring-file repair's
handling of a stale-on-disk file (one new to this lane, two
pre-existing and general); see the feature README's QA log.
- [x] rework (dev, per the lead's ruling on QA findings 1–3): one fresh read
per closed file per request, threaded to the rendering step
(`file_view`'s cache is no longer on this path); a re-analysed closed
file's declaration reported at its live span; every index-time
closed-file span guarded with `hover::spells_exactly` (now `pub(crate)`)
and dropped rather than misrendered. `qa_finding_1/2/3` flipped to the
fixed answers and renamed, plus one attack on the guard itself. QA's
+25 % on a local-net request in a 40 000-line file accepted as-is, for
§64.2 to note in `docs/perf/README.md`.
- [x] QA re-check (same worktree): findings 1–3 re-derived by hand and
confirmed fixed (a use-only shift, a deleted declaring file, a UTF-8
boundary, two independent closed files, an escaped port and an
escaped hierarchical net all attacked and held). **Finding 4, new**:
the `include_declaration` fallback's index-time span is rendered with
**no guard** when the file is *open* (only the closed path calls
`spells_exactly`) — reproduced with a renamed live buffer, a stale
3-byte span lands on the first three characters of the live token
`sig2`. Verdict: rework needed again; see the feature README's QA log
for the fix suggestion. Gates green (4453 passed), opentitan
re-confirmed byte-identical, size 423 lines.
- [x] rework 2 (dev, finding 4): the `include_declaration` chain lifted into
`nav::declaration_site`; an open buffer's index-time fallback span is
emitted only if `hover::spells_exactly` holds against the live text,
else the declaration is omitted (the closed path keeps its single guard
in `closed_locations`). QA's finding-4 test flipped and renamed, plus a
control (an unsaved edit above the declaration still reports the live
line). Gates green through `tools/guard.sh`.
- [x] QA final (escalated, same worktree): the finding-4 test re-derived
by hand (a real unsaved rename; honest omission, tails unchanged) and
the control shown to come from the live path; the declaration-site
ladder attacked rung by rung — five `qa_final_*` tests (a failed live
lookup with the name still in place → emitted; a suffix of a longer
live name → dropped; off a UTF-8 boundary → dropped, no panic;
`includeDeclaration: false` on the closed rungs; one observation, a
different exact `sig` at the old bytes is reported, for the lead).
`nav.rs` 433 production lines, no unwrap/expect/panic,
`indexed_references` 71 lines (reported). Gates green (4459 passed),
opentitan rows re-confirmed read-only, checkout status identical.
Verdict: **pass**.
### 64.2 Closing
- [x] `docs/perf/README.md` note if any harness number moved; topo row
(`lucisv_server ──▶ vlog_semantic`: nav asks the hierarchical
surface) — done 2026-09-12 (the perf entry records the +25 % on a
local-net `references` and the closed-file parse; the
`references-nav ──▶ workspace-index` row amended)
- [ ] release 0.55.0 with assets verified — owner's call; not run from the
`task_d8afe80f` session (a release chain never runs while a lane is
in flight, and the lane merges first)
+40 -1
View File
@@ -455,7 +455,7 @@ fn span_text(text: &str, span: TextRange) -> Option<&str> {
/// to not continue an identifier turns that prefix/suffix match back into a
/// miss, without needing anything more than the same "is this still a name
/// character" question a lexer already answers for `$`, `_` and alnum.
fn spells_exactly(text: &str, span: TextRange, name: &str) -> bool {
pub(crate) fn spells_exactly(text: &str, span: TextRange, name: &str) -> bool {
if span_text(text, span) != Some(name) {
return false;
}
@@ -1313,6 +1313,45 @@ endmodule
let _ = fs::remove_dir_all(&dir);
}
/// TODO §64.1. The same live-span read for a declaration only a
/// **hierarchical** path can reach — a module's internal net, named from
/// another file as `u_leaf.sig`.
///
/// `declaration_snippet` reaches it through `live_symbol` →
/// `nav::indexed_def_for_symbol`, which asked `WorkspaceIndex::member`
/// (the *connection* surface) until §64.1 and so mapped no live symbol
/// back to this `Def` at all: the card came out with its heading and no
/// fence, on a file that was open and perfectly readable. It now shows the
/// live line, which is the same guarantee the port above gets — and the
/// guard is untouched, so a buffer whose live text no longer declares the
/// name still prints nothing (asserted below).
#[test]
fn a_hierarchical_only_declaration_is_read_at_its_live_span_too() {
let top =
"module top;\n leaf u_leaf ();\n wire w;\n assign w = u_leaf.sig;\nendmodule\n";
let saved = "module leaf;\n logic [7:0] sig;\nendmodule\n";
let (dir, mut ws, uri) = included("livehier", &[("leaf.sv", saved), ("top.sv", top)]);
let leaf_uri = path_to_uri(&dir.join("leaf.sv")).expect("uri");
let edited =
"// two lines\n// pushed it down\nmodule leaf;\n logic [15:0] sig;\nendmodule\n";
ws.set_document(leaf_uri.clone(), edited.to_string());
let body = text_of(&hover(&ws, &uri, at(top, "u_leaf.sig") + 7).expect("hover"));
assert!(
body.contains("```systemverilog\n logic [15:0] sig;\n```"),
"the live line, width and all: got {body}"
);
assert!(!body.contains("[7:0]"), "not the saved one: got {body}");
// The guard half, on the same shape: the net renamed away in the
// buffer leaves the heading and no fence.
ws.set_document(leaf_uri, "module leaf;\n logic [15:0] renamed;\nendmodule\n".to_string());
let guarded = text_of(&hover(&ws, &uri, at(top, "u_leaf.sig") + 7).expect("hover"));
assert!(guarded.contains("— declared in"), "today's card, intact: got {guarded}");
assert!(!guarded.contains("```"), "and no snippet at all: got {guarded}");
let _ = fs::remove_dir_all(&dir);
}
#[test]
fn a_stale_indexed_span_drops_the_snippet_rather_than_showing_the_wrong_line() {
// The file changed on disk under a live index — a rescan the server has
+209 -2
View File
@@ -72,6 +72,86 @@ impl Stage {
[Stage::Config, Stage::Build, Stage::Lint, Stage::Fence, Stage::Serialize];
}
/// One stage of the debounced `Document` rebuild the flush performs, plus the
/// diagnostics publish that follows it.
///
/// TODO §63.2: `flush{wall=…}` said the rebuild cost 100 ms and nothing about
/// *which* of the six derivations that was, so the first thing this round does
/// is name them. The six are [`crate::state::Document::new`]'s own steps in
/// the order it runs them; `Publish` is what `flush_dirty` does with the
/// rebuilt buffer, and the flush group's `config`/`build`/`lint`/`fence`
/// stages are inside it.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Rebuild {
/// `tokenize` over the buffer's text.
Lex,
/// `parse_tolerant` over those tokens (or `parse_source_tolerant` when the
/// buffer does not lex).
Parse,
/// `collect_defines` over the tokens.
Defines,
/// `analyze` over the tree.
Analyze,
/// `resolve_external` against the workspace index.
External,
/// `LineIndex::new` over the text.
Lines,
/// The diagnostics publish for the rebuilt buffer.
Publish,
}
impl Rebuild {
/// The name this stage is counted under in the `timing:` line.
fn label(self) -> &'static str {
match self {
Rebuild::Lex => "lex",
Rebuild::Parse => "parse",
Rebuild::Defines => "defines",
Rebuild::Analyze => "analyze",
Rebuild::External => "external",
Rebuild::Lines => "lines",
Rebuild::Publish => "publish",
}
}
/// Every stage, in the order the flush passes through them.
const ALL: [Rebuild; 7] = [
Rebuild::Lex,
Rebuild::Parse,
Rebuild::Defines,
Rebuild::Analyze,
Rebuild::External,
Rebuild::Lines,
Rebuild::Publish,
];
}
/// The flush's inner stages: what rebuilding the dirty buffers cost, split.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct Rebuilt {
ms: [f64; Rebuild::ALL.len()],
/// How many `Document`s were built from scratch.
documents: usize,
}
impl Rebuilt {
/// The `const` form `thread_local!`'s initializer needs.
const EMPTY: Rebuilt = Rebuilt { ms: [0.0; Rebuild::ALL.len()], documents: 0 };
fn add(&mut self, stage: Rebuild, took: Duration) {
self.ms[stage as usize] += took.as_secs_f64() * 1_000.0;
}
/// This group's fields, in the `key=value` shape `tools/perf` parses.
fn fields(&self) -> String {
let stages: Vec<String> = Rebuild::ALL
.iter()
.map(|stage| format!("{}={:.2}ms", stage.label(), self.ms[*stage as usize]))
.collect();
format!("{} documents={}", stages.join(" "), self.documents)
}
}
/// What the fence filter did, when a pass reached it at all.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub enum Fences {
@@ -200,6 +280,8 @@ pub struct Trace {
pub flush_buffers: usize,
/// Whole-file parses the flush performed (`vlog_parser::stats`).
pub flush_parses: u64,
/// What the flush's `Document` rebuild and publish cost, stage by stage.
pub rebuild: Rebuilt,
/// The handler's own stages.
pub action: Group,
}
@@ -208,17 +290,25 @@ impl Trace {
/// Whether this request touched the lint path at all. A trace that did
/// not is not worth a line.
pub fn is_empty(&self) -> bool {
self.flush == Group::default() && self.action == Group::default() && self.flush_buffers == 0
self.flush == Group::default()
&& self.action == Group::default()
&& self.flush_buffers == 0
&& self.rebuild == Rebuilt::default()
}
/// The whole trace as one `timing:`-style fragment.
///
/// The three groups are siblings, never nested: `tools/perf`'s group
/// regex flattens `name{…}` one level and would not survive a brace
/// inside a brace.
pub fn line(&self) -> String {
format!(
"flush{{wall={:.2}ms buffers={} parses={} {}}} action{{{}}}",
"flush{{wall={:.2}ms buffers={} parses={} {}}} rebuild{{{}}} action{{{}}}",
self.flush_ms,
self.flush_buffers,
self.flush_parses,
self.flush.fields(),
self.rebuild.fields(),
self.action.fields(),
)
}
@@ -232,6 +322,7 @@ thread_local! {
flush_ms: 0.0,
flush_buffers: 0,
flush_parses: 0,
rebuild: Rebuilt::EMPTY,
action: Group::EMPTY,
}) };
/// Which group the stages recorded right now belong to.
@@ -292,6 +383,30 @@ pub fn stage<T>(stage: Stage, work: impl FnOnce() -> T) -> T {
out
}
/// Run `work`, counting what it took against one of the flush's inner stages.
///
/// Off costs the same one thread-local read [`stage`] costs. The flush group
/// is not consulted: a rebuild belongs to the rebuild it is part of whichever
/// half of the request it happens in, and outside a flush there is none.
pub fn rebuild<T>(stage: Rebuild, work: impl FnOnce() -> T) -> T {
if !ARMED.get() {
return work();
}
let started = Instant::now();
let out = work();
let took = started.elapsed();
TRACE.with_borrow_mut(|trace| trace.rebuild.add(stage, took));
out
}
/// Record that one `Document` was built from scratch.
pub fn saw_document() {
if !ARMED.get() {
return;
}
TRACE.with_borrow_mut(|trace| trace.rebuild.documents += 1);
}
/// Record what a lint pass ran and found.
pub fn saw_lint(rules: usize, violations: usize, reuse: Reuse) {
group(|held| {
@@ -397,4 +512,96 @@ mod tests {
assert!(line.contains("snapshot=none"), "{line}");
assert!(!line.contains(" "), "no empty field: {line}");
}
/// The flush's inner stages are their own sibling group, named whether or
/// not they ran, and never nested inside `flush{…}` — `tools/perf`'s
/// group regex flattens one level only (TODO §63.2).
#[test]
fn the_rebuild_group_names_every_stage_beside_the_other_two() {
arm();
rebuild(Rebuild::Lex, || {});
saw_document();
close_flush(Duration::from_millis(1), 1, 1);
let line = disarm().expect("armed").line();
let rebuilt = line.split("rebuild{").nth(1).expect("a rebuild group").split('}').next();
let rebuilt = rebuilt.expect("a closed rebuild group");
for stage in Rebuild::ALL {
assert!(rebuilt.contains(&format!("{}=", stage.label())), "{line}");
}
assert!(rebuilt.contains("documents=1"), "{line}");
assert!(!rebuilt.contains('{'), "no nested group: {line}");
}
/// TODO §63.2 QA: the sibling-group contract, attacked directly against
/// the parser it is a contract *with*.
///
/// `tools/perf/phases_p2.py`'s `GROUP` regex is `([a-z_]+)\{([^{}]*)\}` —
/// a group's body may not contain another `{`. Sabotaging `line()` to
/// nest `rebuild{…}` inside `flush{…}` (tried by hand while attacking
/// this pin) does **not** fail the test above: splitting on `"rebuild{"`
/// still finds a clean `rebuild` body, because the extra brace the
/// nesting adds sits *outside* the slice that test inspects. Run through
/// the actual regex, though, nesting is fatal: `[^{}]*` cannot cross the
/// inner `{`, so the whole `flush{...}` match fails and `flush_wall`,
/// `flush_buffers`, `flush_parses` and every `flush.fields()` entry
/// silently vanish from every `tools/perf` row — confirmed with
/// `GROUP.findall` in a scratch interpreter against the sabotaged line,
/// which matched only `rebuild` and `action`, never `flush`. This test
/// reads the line the way the regex does (each group's body must reach
/// its own `}` before another `{` opens) so a future nesting regression
/// fails here instead of only downstream in Python.
#[test]
fn the_three_top_level_groups_are_flat_never_nested() {
arm();
rebuild(Rebuild::Lex, || {});
saw_document();
close_flush(Duration::from_millis(1), 1, 1);
let line = disarm().expect("armed").line();
for name in ["flush", "rebuild", "action"] {
let open =
line.find(&format!("{name}{{")).unwrap_or_else(|| panic!("no {name}{{ in {line}"));
let body = &line[open + name.len() + 1..];
let close =
body.find('}').unwrap_or_else(|| panic!("no closing brace for {name}: {line}"));
let next_open = body.find('{');
assert!(
next_open.is_none_or(|o| o > close),
"{name}{{...}} is not flat — a nested group vanishes from every \
tools/perf row parsed by phases_p2.GROUP instead of failing loudly: {line}"
);
}
}
/// A rebuild is recorded in either half of the request, and an unarmed
/// one records nothing at all.
#[test]
fn a_rebuild_is_counted_whichever_half_of_the_request_runs_it() {
assert_eq!(rebuild(Rebuild::Parse, || 4), 4);
assert_eq!(disarm(), None);
arm();
rebuild(Rebuild::Parse, || {});
close_flush(Duration::ZERO, 1, 1);
rebuild(Rebuild::Parse, || {});
saw_document();
saw_document();
let trace = disarm().expect("armed");
assert_eq!(trace.rebuild.documents, 2);
assert_eq!(trace.flush.passes, 0, "a rebuild is not a lint pass");
assert_eq!(trace.action.passes, 0);
}
/// A request that only rebuilt a buffer still has something to say: the
/// trace must not be discarded as empty before the line is logged.
///
/// The rebuilt *count*, not a stage's milliseconds, is what says a
/// rebuild happened — a stage whose work takes less than the clock's
/// resolution adds 0.00 ms, which is why `Document::new` reports itself
/// with [`saw_document`] rather than leaving the evidence to a duration.
#[test]
fn a_trace_holding_only_a_rebuild_is_not_empty() {
arm();
rebuild(Rebuild::Analyze, || {});
saw_document();
assert!(!disarm().expect("armed").is_empty());
}
}
File diff suppressed because it is too large. Load diff
@@ -53,7 +53,7 @@ impl Server {
let buffers = self.dirty.len();
for (uri, text) in std::mem::take(&mut self.dirty) {
self.set_document(uri.clone(), text);
self.publish(&uri);
crate::lint_trace::rebuild(crate::lint_trace::Rebuild::Publish, || self.publish(&uri));
}
self.timed(started, |took| {
format!("flush of {buffers} dirty buffer{} took {took}", plural(buffers))
+78 -7
View File
@@ -122,17 +122,19 @@ impl Document {
// `tokenize` + `parse_tolerant`, so the tree is identical). A buffer
// that does not lex keeps the old path, so its all-error tree and its
// lex diagnostic are byte-for-byte what they always were.
let (tokens, (tree, diagnostics)) = match tokenize(&text) {
use crate::lint_trace::{rebuild, Rebuild};
crate::lint_trace::saw_document();
let (tokens, (tree, diagnostics)) = match rebuild(Rebuild::Lex, || tokenize(&text)) {
Ok(tokens) => {
let parsed = parse_tolerant(tokens.clone(), &text);
let parsed = rebuild(Rebuild::Parse, || parse_tolerant(tokens.clone(), &text));
(tokens, parsed)
}
Err(_) => (Vec::new(), parse_source_tolerant(&text)),
Err(_) => (Vec::new(), rebuild(Rebuild::Parse, || parse_source_tolerant(&text))),
};
let defines = collect_defines(&tokens);
let semantics = analyze(&tree, &text);
let external = resolve_external(&semantics, index);
let line_index = LineIndex::new(&text);
let defines = rebuild(Rebuild::Defines, || collect_defines(&tokens));
let semantics = rebuild(Rebuild::Analyze, || analyze(&tree, &text));
let external = rebuild(Rebuild::External, || resolve_external(&semantics, index));
let line_index = rebuild(Rebuild::Lines, || LineIndex::new(&text));
let large = false;
Document {
path,
@@ -5861,4 +5863,73 @@ mod tests {
assert_eq!(ws.index().member("a_pkg", "EDITED").len(), 1, "the live edit is indexed");
assert_eq!(ws.index().member("a_pkg", "K").len(), 0);
}
// ------------------------------------------------------------------
// TODO §63.2 QA: the trace's arithmetic, attacked with the three
// shapes TODO.md names — a buffer that fails to lex, a `define` edit
// that changes the macro table, and (below, via the server-level
// parity re-run) an edit that moves a fence.
// ------------------------------------------------------------------
/// A buffer that never lexes still reports a `Lex` stage (the failed
/// attempt is real work and costs real time) and a `Parse` stage (the
/// `parse_source_tolerant` fallback), and still counts as one document.
/// `defines`/`analyze`/`external`/`lines` all still run over the empty
/// token stream and empty-error tree exactly as the un-instrumented
/// path always did — the wrapping must not skip a stage just because
/// an earlier one errored.
#[test]
fn a_buffer_that_fails_to_lex_still_records_every_rebuild_stage() {
crate::lint_trace::arm();
// An unterminated string literal is an unambiguous lex error that
// does not depend on lexer internals that could drift between
// versions (`vlog_parser::tokenize` is documented all-or-nothing).
let text = "module m;\n string s = \"unterminated\nendmodule\n".to_string();
let doc = Document::new(None, text, &WorkspaceIndex::default());
assert!(doc.tokens.is_empty(), "a lex failure leaves an empty token stream");
assert!(!doc.diagnostics.is_empty(), "a lex failure is a diagnostic");
let trace = crate::lint_trace::disarm().expect("armed");
// Every stage's field is present on the line, whether or not it
// took measurable time (`saw_document`, not a duration, is what
// says a rebuild happened at all — see the flaky test this round
// fixed in `lint_trace.rs`).
let line = trace.line();
assert!(line.contains("documents=1"), "{line}");
for stage in ["lex=", "parse=", "defines=", "analyze=", "external=", "lines=", "publish="] {
assert!(line.contains(stage), "{line}");
}
}
/// A `` `define `` edit changes the macro table `collect_defines`
/// produces, and nothing about wrapping that call in `rebuild` changes
/// which tokens it sees or what it returns: the new revision's table
/// reflects only the new text, never a stale value from the revision
/// before it (`Document::new` builds a fresh `DefineTable` every time,
/// same as before this round).
#[test]
fn a_define_edit_changes_the_macro_table_the_rebuild_reports_on() {
crate::lint_trace::arm();
let before = Document::new(
None,
"`define WIDTH 8\nmodule m;\n wire [`WIDTH-1:0] w;\nendmodule\n".to_string(),
&WorkspaceIndex::default(),
);
assert_eq!(before.defines.latest("WIDTH").map(|d| d.body.trim()), Some("8"));
assert!(before.defines.latest("DEPTH").is_none());
let after = Document::new(
None,
"`define DEPTH 16\nmodule m;\n wire [`DEPTH-1:0] w;\nendmodule\n".to_string(),
&WorkspaceIndex::default(),
);
assert!(after.defines.latest("WIDTH").is_none(), "no macro survives across documents");
assert_eq!(after.defines.latest("DEPTH").map(|d| d.body.trim()), Some("16"));
let trace = crate::lint_trace::disarm().expect("armed");
let line = trace.line();
assert!(
line.contains("documents=2"),
"two fresh Document::new calls, two rebuilds: {line}"
);
}
}
+110
View File
@@ -8631,3 +8631,113 @@ fn organize_imports_is_offered_under_its_own_kind_and_runs_as_a_command() {
let _ = std::fs::remove_dir_all(&dir);
}
/// TODO §64.1 over the wire. `leaf` declares an internal net; `top.sv` names it
/// through a hierarchical tail and `leaf.sv` uses it itself. Before §64.1
/// `textDocument/references` answered `leaf.sv`'s two lines from the
/// declaration and never the tail, while `textDocument/rename` at the same
/// position edited both files — lucisv could change a reference it could not
/// list. Asserted here from both ends, with `leaf.sv` the only open buffer, so
/// the tail comes out of the persisted postings and `leaf.sv`'s own use out of
/// the live one; then from `top.sv` with `leaf.sv` closed, where that file's
/// own use is served by one re-analysis of it.
#[test]
fn a_hierarchical_nets_references_and_rename_agree_over_the_wire() {
let dir = temp_dir("hierrefs");
let leaf = dir.join("leaf.sv");
let leaf_text = "\
module leaf (input logic clk_i);
logic sig;
assign sig = clk_i;
endmodule
";
std::fs::write(&leaf, leaf_text).expect("write");
let top = dir.join("top.sv");
let top_text = "\
module top;
leaf u_leaf (.clk_i(1'b0));
wire w;
assign w = u_leaf.sig;
endmodule
";
std::fs::write(&top, top_text).expect("write");
let root = format!("file://{}", dir.display());
let leaf_uri = format!("file://{}", leaf.display());
let top_uri = format!("file://{}", top.display());
// `sig` is declared at line 1 column 8 of `leaf.sv`, used at line 2
// column 9 there, and named at line 3 column 20 of `top.sv`.
let session = [
frame(&format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"initialize","params":{{"processId":null,"rootUri":"{root}","capabilities":{{}}}}}}"#
)),
frame(r#"{"jsonrpc":"2.0","method":"initialized","params":{}}"#),
frame(WIDE_SCOPE),
frame(&format!(
r#"{{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{{"textDocument":{{"uri":"{leaf_uri}","languageId":"systemverilog","version":1,"text":{}}}}}}}"#,
serde_json::to_string(leaf_text).expect("json")
)),
frame(&format!(
r#"{{"jsonrpc":"2.0","id":2,"method":"textDocument/references","params":{{"textDocument":{{"uri":"{leaf_uri}"}},"position":{{"line":1,"character":8}},"context":{{"includeDeclaration":true}}}}}}"#
)),
frame(&format!(
r#"{{"jsonrpc":"2.0","id":3,"method":"textDocument/rename","params":{{"textDocument":{{"uri":"{leaf_uri}"}},"position":{{"line":1,"character":8}},"newName":"renamed"}}}}"#
)),
// Now from the other side, with `leaf.sv` shut.
frame(&format!(
r#"{{"jsonrpc":"2.0","method":"textDocument/didClose","params":{{"textDocument":{{"uri":"{leaf_uri}"}}}}}}"#
)),
frame(&format!(
r#"{{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{{"textDocument":{{"uri":"{top_uri}","languageId":"systemverilog","version":1,"text":{}}}}}}}"#,
serde_json::to_string(top_text).expect("json")
)),
frame(&format!(
r#"{{"jsonrpc":"2.0","id":4,"method":"textDocument/references","params":{{"textDocument":{{"uri":"{top_uri}"}},"position":{{"line":3,"character":20}},"context":{{"includeDeclaration":true}}}}}}"#
)),
frame(r#"{"jsonrpc":"2.0","id":9,"method":"shutdown","params":null}"#),
frame(r#"{"jsonrpc":"2.0","method":"exit","params":null}"#),
]
.concat();
let messages = talk(&session);
let response = |id: u32| -> &serde_json::Value {
messages
.iter()
.find(|m| m["id"] == id)
.unwrap_or_else(|| panic!("no response {id} in {messages:#?}"))
};
// Every place naming the net, as `(file, line)`.
let places = |id: u32| -> Vec<(String, i64)> {
let mut out: Vec<(String, i64)> = response(id)["result"]
.as_array()
.expect("a list")
.iter()
.map(|location| {
let uri = location["uri"].as_str().expect("a uri");
let name = uri.rsplit('/').next().unwrap_or("?").to_string();
(name, location["range"]["start"]["line"].as_i64().expect("a line"))
})
.collect();
out.sort();
out
};
let everywhere =
vec![("leaf.sv".to_string(), 1), ("leaf.sv".to_string(), 2), ("top.sv".to_string(), 3)];
assert_eq!(places(2), everywhere, "from the declaration");
assert_eq!(places(4), everywhere, "from the tail, with `leaf.sv` closed");
// And the rename that was already editing both files edits exactly those
// places — the asymmetry §64.1 was filed for, closed from both sides.
let changes = &response(3)["result"]["changes"];
let own = changes[&leaf_uri].as_array().expect("edits for the declaring file");
assert_eq!(own.len(), 2, "{own:#?}");
let elsewhere = changes[&top_uri].as_array().expect("edits for the naming file");
assert_eq!(elsewhere.len(), 1, "{elsewhere:#?}");
assert_eq!(elsewhere[0]["range"]["start"]["line"], 3);
assert_eq!(elsewhere[0]["range"]["start"]["character"], 20);
assert!(elsewhere.iter().all(|e| e["newText"] == "renamed"), "{elsewhere:#?}");
let _ = std::fs::remove_dir_all(&dir);
}
+280 -62
View File
@@ -403,8 +403,14 @@ impl<'a> RawLexer<'a> {
});
}
// Operators, longest match first.
// Operators, longest match first. The first-byte test is not a second
// way of matching — `starts_with` still decides — it is what keeps a
// `;` from being compared against all 42 spellings: one byte compare
// rejects every operator that cannot start here (TODO §63.2).
for op in OPERATORS {
if op.as_bytes()[0] != c {
continue;
}
if self.starts_with(op) {
for _ in 0..op.len() {
self.bump();
@@ -918,80 +924,111 @@ fn is_line_directive(word: &str) -> bool {
)
}
/// What the attachment phase carries from one raw token to the next.
#[derive(Default)]
struct Attaching {
/// Comments waiting for the real token they lead.
pending: Vec<Comment>,
/// Whether a blank line was seen since the last pending comment.
pending_blank: bool,
}
/// Tokenize source text, attaching comments and blank-line info to tokens.
///
/// The two phases are **fused**: each raw token is attached as it is lexed,
/// rather than collected into a `Vec<RawTok>` the attachment loop then walks.
/// Attachment only ever reads the raw token in hand and the token last pushed,
/// so the fusion is a pure reordering — it drops a second whole-file vector
/// (a 40 267-line file's worth of it is ~22 MB of allocation, growth copying
/// and teardown), which is why the first request after an edit pays less for
/// the same tokens (TODO §63.2).
pub fn tokenize(source: &str) -> Result<Vec<Token>, LexError> {
let mut raw_lexer = RawLexer::new(source.as_bytes());
let mut raws: Vec<RawTok> = Vec::new();
let mut tokens: Vec<Token> = Vec::with_capacity(estimated_tokens(source.len()));
let mut state = Attaching::default();
loop {
let tok = raw_lexer.next_raw()?;
let is_eof = tok.kind == RawKind::Real(TokenKind::Eof);
raws.push(tok);
let raw = raw_lexer.next_raw()?;
let is_eof = raw.kind == RawKind::Real(TokenKind::Eof);
attach(raw, &mut tokens, &mut state);
if is_eof {
break;
}
}
Ok(tokens)
}
// Attachment phase.
let mut tokens: Vec<Token> = Vec::new();
let mut pending: Vec<Comment> = Vec::new();
let mut pending_blank = false;
/// How many tokens a source of `bytes` bytes is guessed to hold.
///
/// Only to spare the growing vector its early doublings; a wrong guess costs
/// nothing but the growth it would have paid anyway. Six bytes a token is the
/// measured average over the corpus and over opentitan's generated register
/// files alike, and the guess is capped so a pathological file (one enormous
/// string literal) cannot reserve more than it could ever need.
fn estimated_tokens(bytes: usize) -> usize {
(bytes / 6).min(1 << 20)
}
for raw in raws {
match raw.kind {
RawKind::LineComment | RawKind::BlockComment => {
let same_line_as_prev =
raw.newlines_before == 0 && !tokens.is_empty() && pending.is_empty();
let comment = Comment {
text: raw.text,
blank_before: raw.newlines_before > 1 || pending_blank,
line: raw.line,
col: raw.col,
span: raw.span,
};
if same_line_as_prev {
// Trailing comment for the previous real token.
let prev = tokens.last_mut().unwrap();
match &mut prev.trailing {
Some(existing) => {
// Two comments on one line become one node, so its
// span has to cover both — the merge normalizes
// the gap between them to a single space, which is
// why a merged comment is the one comment whose
// text can differ from `source[span]`.
existing.text.push(' ');
existing.text.push_str(&comment.text);
existing.span = TextRange::new(existing.span.start, comment.span.end);
}
None => prev.trailing = Some(comment),
}
} else {
pending.push(comment);
pending_blank = false;
}
}
RawKind::Real(kind) => {
let blank_before = if pending.is_empty() {
raw.newlines_before > 1
} else {
// Comments already carry their own blank flags; the token
// is blank-separated only if there was a blank line
// between the last comment and the token itself.
raw.newlines_before > 1
};
tokens.push(Token {
kind,
text: raw.text,
line: raw.line,
col: raw.col,
span: raw.span,
leading: std::mem::take(&mut pending),
trailing: None,
blank_before,
});
/// Fold one raw token into the token stream: a comment onto its neighbour,
/// a real token onto the end with whatever comments were waiting for it.
fn attach(raw: RawTok, tokens: &mut Vec<Token>, state: &mut Attaching) {
match raw.kind {
RawKind::LineComment | RawKind::BlockComment => {
let same_line_as_prev =
raw.newlines_before == 0 && !tokens.is_empty() && state.pending.is_empty();
let comment = Comment {
text: raw.text,
blank_before: raw.newlines_before > 1 || state.pending_blank,
line: raw.line,
col: raw.col,
span: raw.span,
};
// A comment that finds no token to trail — unreachable while
// `same_line_as_prev` requires one, kept as a rule rather than a
// hope — leads the next token instead of vanishing (invariant 3).
let orphan =
if same_line_as_prev { attach_trailing(tokens, comment) } else { Some(comment) };
if let Some(comment) = orphan {
state.pending.push(comment);
state.pending_blank = false;
}
}
RawKind::Real(kind) => {
// Comments already carry their own blank flags; the token is
// blank-separated only if there was a blank line between the last
// comment and the token itself — which is the same test either
// way, so `pending` does not enter into it.
let blank_before = raw.newlines_before > 1;
tokens.push(Token {
kind,
text: raw.text,
line: raw.line,
col: raw.col,
span: raw.span,
leading: std::mem::take(&mut state.pending),
trailing: None,
blank_before,
});
}
}
Ok(tokens)
}
/// Hang a comment off the token before it, merging with one already there.
/// Handed back untouched when there is no token before it.
fn attach_trailing(tokens: &mut [Token], comment: Comment) -> Option<Comment> {
let Some(prev) = tokens.last_mut() else { return Some(comment) };
match &mut prev.trailing {
Some(existing) => {
// Two comments on one line become one node, so its span has to
// cover both — the merge normalizes the gap between them to a
// single space, which is why a merged comment is the one comment
// whose text can differ from `source[span]`.
existing.text.push(' ');
existing.text.push_str(&comment.text);
existing.span = TextRange::new(existing.span.start, comment.span.end);
}
None => prev.trailing = Some(comment),
}
None
}
#[cfg(test)]
@@ -1510,4 +1547,185 @@ mod tests {
assert!(texts.contains(&"!=="));
assert!(texts.contains(&"<="));
}
// ------------------------------------------------------------------
// TODO §63.2 QA: the fused attach phase, attacked
//
// These cover the shapes the two-phase code (a `Vec<RawTok>` fully
// built, then walked) could tell apart from the fused one-pass code
// (each raw token attached as it is produced) if the fusion were not a
// pure reordering: a comment with no token before it at all, comments
// that never see a "previous token" until much later, EOF immediately
// after a trailing comment, and so on. Every one of these was also
// cross-checked, file for file, against `tokenize` built from 1b8723c
// (the pre-fusion tree) with a throwaway digest tool in the QA
// scratchpad — token-for-token identical, hash and manual `Debug`
// inspection alike; the assertions below pin that result durably.
// ------------------------------------------------------------------
#[test]
fn a_comment_as_the_very_first_thing_in_the_file_is_the_first_token_s_leading() {
let toks = tokenize("// only thing before the module\nmodule m;\nendmodule").unwrap();
assert_eq!(toks[0].leading.len(), 1);
assert_eq!(toks[0].leading[0].text, "// only thing before the module");
assert!(!toks[0].leading[0].blank_before);
}
#[test]
fn two_comments_on_the_first_line_before_any_token_both_lead_it() {
// Two *separate* comments here means two lines, each its own line
// comment (a line comment always runs to end of line, so "two
// comments on one line" before any token is only possible with
// block comments — covered by `two_block_comments_on_one_line_merge`
// below).
let toks = tokenize("// one\n// two\nmodule m;\nendmodule").unwrap();
assert_eq!(toks[0].leading.len(), 2);
assert_eq!(toks[0].leading[0].text, "// one");
assert_eq!(toks[0].leading[1].text, "// two");
assert!(!toks[0].leading[1].blank_before);
}
#[test]
fn a_trailing_comment_after_the_last_real_token_reaches_eof() {
let toks = tokenize("module m;\nendmodule // trailing at eof\n").unwrap();
let end = toks.iter().find(|t| t.is_kw("endmodule")).unwrap();
let trailing = end.trailing.as_ref().expect("trailing comment on endmodule");
assert_eq!(trailing.text, "// trailing at eof");
assert_eq!(toks.last().unwrap().kind, TokenKind::Eof);
}
#[test]
fn two_block_comments_on_one_line_merge_into_one_trailing_comment() {
let toks = tokenize("wire w; /* one */ /* two */\nendmodule").unwrap();
let semi = toks.iter().find(|t| t.is_sym(";")).unwrap();
let trailing = semi.trailing.as_ref().expect("merged trailing comment");
assert_eq!(trailing.text, "/* one */ /* two */");
}
#[test]
fn a_blank_line_between_a_comment_and_its_token_marks_both() {
let toks = tokenize("// lead\n\nmodule m;\nendmodule").unwrap();
assert_eq!(toks[0].leading.len(), 1);
// The comment itself is not blank-separated from what came before it
// (nothing did); the blank line sits between the comment and the
// token, so the *token* carries the flag.
assert!(!toks[0].leading[0].blank_before);
assert!(toks[0].blank_before);
}
#[test]
fn crlf_line_endings_lex_like_lf_with_the_same_comment_attachment() {
let toks = tokenize("module m; // c\r\nendmodule\r\n").unwrap();
let semi = toks.iter().find(|t| t.is_sym(";")).unwrap();
assert_eq!(semi.trailing.as_ref().unwrap().text, "// c");
let end = toks.iter().find(|t| t.is_kw("endmodule")).unwrap();
assert_eq!(end.line, 2);
}
#[test]
fn a_block_comment_spanning_lines_still_leads_a_same_line_token() {
let toks = tokenize("/* block\n spanning\n lines */ module m;\nendmodule").unwrap();
assert_eq!(toks[0].leading.len(), 1);
assert!(toks[0].leading[0].text.starts_with("/* block"));
assert!(toks[0].leading[0].text.ends_with("lines */"));
// The module keyword itself sits on the block comment's last line.
assert_eq!(toks[0].line, 3);
}
#[test]
fn a_comment_between_a_macro_invocation_and_its_arguments_trails_the_macro() {
let toks = tokenize("module m;\n`MYMACRO /*c*/ (a, b);\nendmodule").unwrap();
let mac = toks.iter().find(|t| t.text == "`MYMACRO").unwrap();
assert_eq!(mac.trailing.as_ref().unwrap().text, "/*c*/");
// The macro call's parenthesized arguments are unaffected — still
// ordinary tokens right after, comment or not.
let open_paren_idx = toks.iter().position(|t| t.is_sym("(")).unwrap();
assert_eq!(toks[open_paren_idx + 1].text, "a");
}
#[test]
fn a_file_that_is_only_comments_attaches_them_all_to_the_synthetic_eof() {
let toks = tokenize("// only a comment, nothing else\n").unwrap();
assert_eq!(toks.len(), 1);
assert_eq!(toks[0].kind, TokenKind::Eof);
assert_eq!(toks[0].leading.len(), 1);
assert_eq!(toks[0].leading[0].text, "// only a comment, nothing else");
}
#[test]
fn an_empty_file_lexes_to_a_lone_eof_with_no_comments() {
let toks = tokenize("").unwrap();
assert_eq!(toks.len(), 1);
assert_eq!(toks[0].kind, TokenKind::Eof);
assert!(toks[0].leading.is_empty());
}
// ------------------------------------------------------------------
// TODO §63.2 QA: the operator table's first-byte test
// ------------------------------------------------------------------
#[test]
fn every_operator_s_first_byte_is_a_single_ascii_byte() {
// `op.as_bytes()[0] != c` compares one byte of `c: u8` against the
// table entry's first *byte*. If any entry's first character were
// multi-byte UTF-8, its first byte alone would not identify it and
// the guard could reject a spelling it should have let through. Every
// entry here is pure ASCII punctuation, so the byte comparison is the
// whole character.
for op in OPERATORS {
let first = op.chars().next().expect("no empty operator spellings");
assert!(first.is_ascii(), "{op:?} does not start with an ASCII byte");
assert_eq!(
op.as_bytes()[0],
first as u8,
"{op:?}'s first byte does not match its first char"
);
}
}
#[test]
fn the_operator_table_has_no_duplicate_or_empty_entries() {
// A duplicate wastes a comparison; an empty entry would make
// `op.as_bytes()[0]` panic before ever reaching `starts_with`.
for op in OPERATORS {
assert!(!op.is_empty());
}
let mut sorted = OPERATORS.to_vec();
sorted.sort_unstable();
sorted.dedup();
assert_eq!(sorted.len(), OPERATORS.len(), "OPERATORS has a duplicate entry");
}
#[test]
fn every_operator_followed_by_every_other_operator_still_lexes_without_a_gap() {
// The first-byte test must not change *which* entry `starts_with`
// picks — only how many entries are tried before it does. Lexing
// every `op1 op2` concatenation (no space) and requiring the token
// stream to account for every byte with no lex error is the
// regression gate: a wrong short-circuit would either misplace the
// split point or leave a byte unconsumed. Cross-checked pair for
// pair against `tokenize` built from 1b8723c (pre-first-byte-test)
// in the QA scratchpad: 1 764 pairs, 0 differ.
for &op1 in OPERATORS {
for &op2 in OPERATORS {
let src = format!("{op1}{op2} ;");
let toks = tokenize(&src)
.unwrap_or_else(|e| panic!("lexing {op1:?} followed by {op2:?} failed: {e}"));
// Everything up to the space must be Symbol tokens whose
// texts concatenate back to exactly op1 followed by op2,
// with no gap and no overlap.
let mut consumed = String::new();
let mut i = 0;
while toks[i].kind == TokenKind::Symbol && toks[i].text != ";" {
consumed.push_str(&toks[i].text);
i += 1;
}
assert_eq!(
consumed,
format!("{op1}{op2}"),
"{op1:?} followed by {op2:?} did not round-trip"
);
}
}
}
}
+17 -17
View File
@@ -53,11 +53,11 @@ impl<'a> Parser<'a> {
let start = self.here();
let col = self.cur().col;
if self.cur().kind == TokenKind::Ident && self.nth(1).is_sym(":") {
self.bump();
self.bump();
self.skip();
self.skip();
}
// `assert` / `assume` / `cover` / `restrict`.
self.bump();
self.skip();
self.expect_kw("property")?;
self.expect_sym("(")?;
self.skip_balanced("(", ")")?;
@@ -132,22 +132,22 @@ impl<'a> Parser<'a> {
at_stmt_start = false;
let t = self.cur();
if t.is_sym("(") {
self.bump();
self.skip();
self.skip_balanced("(", ")")?;
} else if t.is_sym("[") {
self.bump();
self.skip();
self.skip_balanced("[", "]")?;
} else if t.is_sym("{") {
self.bump();
self.skip();
self.skip_balanced("{", "}")?;
} else if (t.is_kw("disable") || t.is_kw("wait")) && self.nth(1).is_kw("fork") {
// `disable fork` / `wait fork` name the enclosing block; they
// do not open one.
self.bump();
self.bump();
self.skip();
self.skip();
} else if BLOCK_OPENERS.iter().any(|k| t.is_kw(k)) {
depth += 1;
self.bump();
self.skip();
} else if BLOCK_CLOSERS.iter().any(|k| t.is_kw(k)) {
if depth == 0 {
// A closer with nothing open: the action statement is
@@ -156,7 +156,7 @@ impl<'a> Parser<'a> {
return self.error("expected `;`");
}
depth -= 1;
self.bump();
self.skip();
if depth == 0 {
self.parse_label()?;
if !self.eat_kw("else") {
@@ -167,7 +167,7 @@ impl<'a> Parser<'a> {
} else if depth == 0 && self.eat_sym(";") {
return Ok(());
} else {
self.bump();
self.skip();
}
}
}
@@ -199,9 +199,9 @@ impl<'a> Parser<'a> {
let start = self.here();
let col = self.cur().col;
let end_kw = if self.cur().is_kw("sequence") { "endsequence" } else { "endproperty" };
self.bump();
self.skip();
while !self.at_eof() && !self.cur().is_kw(end_kw) {
self.bump();
self.skip();
}
self.expect_closer(end_kw)?;
self.parse_label()?;
@@ -220,7 +220,7 @@ impl<'a> Parser<'a> {
fn parse_default_disable(&mut self) -> PResult<RawText> {
let start = self.here();
let col = self.cur().col;
self.bump(); // default
self.skip(); // default
self.expect_kw("disable")?;
self.expect_kw("iff")?;
self.skip_to_semi()?;
@@ -252,7 +252,7 @@ impl<'a> Parser<'a> {
fn parse_prop_seq_decl_inner(&mut self) -> PResult<PropSeqDecl> {
let kw = self.cur().text.clone();
let end_kw = if kw == "sequence" { "endsequence" } else { "endproperty" };
self.bump();
self.skip();
let before_name = self.take_gap();
let name = self.expect_name()?;
let before_args = self.take_before_open("(");
@@ -407,7 +407,7 @@ impl<'a> Parser<'a> {
let mut action = ActionBlock::default();
if self.cur().is_sym(";") {
action.before = self.take_gap();
self.bump();
self.skip();
return Ok(action);
}
if !self.cur().is_kw("else") {
@@ -415,7 +415,7 @@ impl<'a> Parser<'a> {
}
if self.cur().is_kw("else") {
action.before_else = self.take_gap();
self.bump();
self.skip();
action.after_else = self.take_gap();
action.fail = Some(Box::new(self.parse_stmt()?));
}
+12 -12
View File
@@ -94,7 +94,7 @@ impl<'a> Parser<'a> {
let mut after_hash = Vec::new();
let mut param_directives = Vec::new();
if self.cur().is_sym("#") {
self.bump();
self.skip();
after_hash = self.take_gap();
self.expect_sym("(")?;
let mark = self.diags_mark();
@@ -305,7 +305,7 @@ impl<'a> Parser<'a> {
return self.parse_constraint_foreach();
}
if self.cur().is_kw("unique") && self.nth(1).is_sym("{") {
self.bump();
self.skip();
let comments = self.take_gap();
let items = self.parse_constraint_expr_set()?;
return Ok(ConstraintItemKind::Unique { items, comments });
@@ -314,9 +314,9 @@ impl<'a> Parser<'a> {
// `soft` is matched by text, for the reason `parse_constraint_expr`
// gives.
if self.cur().is_kw("disable") && word_at(self.nth(1), "soft") {
self.bump();
self.skip();
let before = self.take_gap();
self.bump();
self.skip();
let after = self.take_gap();
let expr = self.parse_expr()?;
return Ok(ConstraintItemKind::DisableSoft {
@@ -341,7 +341,7 @@ impl<'a> Parser<'a> {
let soft = self.at_soft_constraint();
let mut after_soft = Vec::new();
if soft {
self.bump();
self.skip();
after_soft = self.take_gap();
}
let mark = self.pending_trailing.len();
@@ -374,7 +374,7 @@ impl<'a> Parser<'a> {
}
if !soft && self.cur().is_sym("->") {
let before = self.take_around(mark);
self.bump();
self.skip();
let after = self.take_around(mark);
let set = self.parse_constraint_set()?;
return Ok(ConstraintItemKind::Implication {
@@ -403,7 +403,7 @@ impl<'a> Parser<'a> {
let mut els = None;
if self.cur().is_kw("else") {
else_comments = self.take_dangling();
self.bump();
self.skip();
// The gap after `else` is this item's when the set it introduces
// opens with a token of its own — a `{`, or the `if` of a chain.
// A set written on the next line leaves it to that item's own
@@ -458,13 +458,13 @@ impl<'a> Parser<'a> {
}
fn parse_solve_before(&mut self) -> PResult<ConstraintItemKind> {
self.bump(); // solve
self.skip(); // solve
let solve = self.parse_solve_operands()?;
if !word_at(self.cur(), "before") {
return self.error("expected `before`");
}
let before_comments = self.take_gap();
self.bump();
self.skip();
let before = self.parse_solve_operands()?;
Ok(ConstraintItemKind::SolveBefore { solve, before_comments, before })
}
@@ -526,7 +526,7 @@ impl<'a> Parser<'a> {
expr: Expr,
before: Vec<Comment>,
) -> PResult<Expr> {
self.bump(); // dist
self.skip(); // dist
let after = self.take_gap();
self.expect_sym("{")?;
let mut weights: Vec<DistItem> = Vec::new();
@@ -539,8 +539,8 @@ impl<'a> Parser<'a> {
let mut op_comments = BinaryComments::default();
if let Some(spelling) = self.dist_weight_op() {
op_comments.before = self.take_gap();
self.bump();
self.bump();
self.skip();
self.skip();
op_comments.after = self.take_gap();
op = Some(spelling.to_string());
weight = Some(self.parse_ternary()?);
+22 -22
View File
@@ -56,7 +56,7 @@ impl<'a> Parser<'a> {
self.take_member_prefix();
self.expect_kw("covergroup")?;
while !self.at_eof() && !self.cur().is_kw("endgroup") {
self.bump();
self.skip();
}
self.expect_closer("endgroup")?;
self.parse_label()?;
@@ -139,7 +139,7 @@ impl<'a> Parser<'a> {
fn parse_coverage_event(&mut self) -> PResult<Option<CoverageEvent>> {
if self.cur().is_kw("with") {
let before_with = self.take_gap();
self.bump();
self.skip();
let after_with = self.take_gap();
self.expect_kw("function")?;
let after_function = self.take_gap();
@@ -147,7 +147,7 @@ impl<'a> Parser<'a> {
return self.error("expected `sample`");
}
let name = Name { text: self.cur().text.clone(), span: self.cur().span };
self.bump();
self.skip();
let before_args = self.take_before_open("(");
let has_parens = self.cur().is_sym("(");
let args = self.parse_tf_ports(false)?.args;
@@ -163,7 +163,7 @@ impl<'a> Parser<'a> {
}
if self.cur().is_sym("@") {
let before = self.take_gap();
self.bump();
self.skip();
let sens = self.parse_sens_list()?;
return Ok(Some(CoverageEvent::Clocking { before, sens }));
}
@@ -206,9 +206,9 @@ impl<'a> Parser<'a> {
&& (word_at(self.nth(2), "coverpoint") || word_at(self.nth(2), "cross"))
{
let name = Name { text: self.cur().text.clone(), span: self.cur().span };
self.bump();
self.skip();
let before = self.take_gap();
self.bump(); // :
self.skip(); // :
let after = self.take_gap();
Some(CoverLabel { name, comments: Box::new(BinaryComments { before, after }) })
} else {
@@ -224,7 +224,7 @@ impl<'a> Parser<'a> {
}
fn parse_coverpoint(&mut self, label: Option<CoverLabel>) -> PResult<CoverpointDecl> {
self.bump(); // coverpoint
self.skip(); // coverpoint
let after_kw = self.take_gap();
let expr = self.parse_expr()?;
let iff = self.parse_cover_iff()?;
@@ -234,7 +234,7 @@ impl<'a> Parser<'a> {
}
fn parse_cross(&mut self, label: Option<CoverLabel>) -> PResult<CrossDecl> {
self.bump(); // cross
self.skip(); // cross
let after_kw = self.take_gap();
let mut items: Vec<ExprItem> = Vec::new();
loop {
@@ -265,7 +265,7 @@ impl<'a> Parser<'a> {
return Ok(None);
}
let before_kw = self.take_gap();
self.bump();
self.skip();
let after_kw = self.take_gap();
self.expect_sym("(")?;
let after_open = self.take_gap();
@@ -356,13 +356,13 @@ impl<'a> Parser<'a> {
let wildcard = word_at(self.cur(), "wildcard") && bin_kind_at(self.nth(1)).is_some();
let mut after_wildcard = Vec::new();
if wildcard {
self.bump();
self.skip();
after_wildcard = self.take_gap();
}
let Some(kind) = bin_kind_at(self.cur()) else {
return self.error("expected `bins`, `ignore_bins` or `illegal_bins`");
};
self.bump();
self.skip();
let before_name = self.take_gap();
let name = self.expect_name()?;
let array = self.parse_bin_array()?;
@@ -392,7 +392,7 @@ impl<'a> Parser<'a> {
return Ok(None);
}
let before = self.take_gap();
self.bump();
self.skip();
let inner_before = self.take_gap();
let size = if self.cur().is_sym("]") { None } else { Some(self.parse_expr()?) };
let inner_after = self.gap_before("]");
@@ -412,12 +412,12 @@ impl<'a> Parser<'a> {
/// `bins b = (1'b1[*5]);` wrong.
fn parse_bin_spec(&mut self, in_cross: bool) -> PResult<BinSpec> {
if self.cur().is_kw("default") {
self.bump();
self.skip();
// `sequence` really is a lexer keyword (a `sequence ... endsequence`
// declaration), so this one is not matched by text.
if self.cur().is_kw("sequence") {
let comments = self.take_gap();
self.bump();
self.skip();
return Ok(BinSpec::DefaultSequence { comments });
}
return Ok(BinSpec::Default);
@@ -446,7 +446,7 @@ impl<'a> Parser<'a> {
break;
}
let before = self.take_gap();
self.bump();
self.skip();
let after = self.take_gap();
arrow = BinaryComments { before, after };
}
@@ -494,7 +494,7 @@ impl<'a> Parser<'a> {
return Ok(None);
}
let before = self.take_gap();
self.bump(); // [
self.skip(); // [
let after_open = self.take_gap();
let op = self.bump().text;
let inner_before = self.take_gap();
@@ -503,7 +503,7 @@ impl<'a> Parser<'a> {
let mut hi = None;
if self.cur().is_sym(":") {
colon.before = self.take_gap();
self.bump();
self.skip();
colon.after = self.take_gap();
hi = Some(self.parse_expr()?);
}
@@ -541,13 +541,13 @@ impl<'a> Parser<'a> {
fn parse_select_primary(&mut self) -> PResult<SelectExpr> {
if self.cur().is_sym("!") {
self.bump();
self.skip();
let comments = self.take_gap();
let expr = self.parse_select_primary()?;
return Ok(SelectExpr::Not { comments, expr: Box::new(expr) });
}
if self.cur().is_sym("(") {
self.bump();
self.skip();
let before = self.take_gap();
let expr = self.parse_select_expr()?;
let after = self.gap_before(")");
@@ -577,7 +577,7 @@ impl<'a> Parser<'a> {
}
fn parse_binsof(&mut self) -> PResult<BinsofSel> {
self.bump(); // binsof
self.skip(); // binsof
let after_kw = self.take_gap();
self.expect_sym("(")?;
let after_open = self.take_gap();
@@ -589,7 +589,7 @@ impl<'a> Parser<'a> {
let mut intersect = None;
if word_at(self.cur(), "intersect") {
before_intersect = self.take_gap();
self.bump();
self.skip();
after_intersect = self.take_gap();
intersect = Some(self.parse_constraint_expr_set()?);
}
@@ -610,7 +610,7 @@ impl<'a> Parser<'a> {
return Ok(None);
}
let before_kw = self.take_gap();
self.bump();
self.skip();
let after_kw = self.take_gap();
self.expect_sym("(")?;
let after_open = self.take_gap();
+27 -2
View File
@@ -63,6 +63,31 @@ impl<'a> Parser<'a> {
t
}
/// Consume the current token without building a copy of it.
///
/// Exactly [`Parser::bump`] for the caller that throws the token away —
/// the same comment plumbing, the same cursor step, the same `self.tokens`
/// left untouched — minus the clone. `bump` copies the token's `text`
/// (a `String`, so an allocation) and its comment buckets for a value most
/// callers drop on the next line; on a 40 267-line generated file that is
/// one allocate-and-free per token consumed (TODO §63.2).
pub(super) fn skip(&mut self) {
let token = &self.tokens[self.pos];
// Cloned rather than moved out, because `bump` moved them out of its
// *copy*: the stream keeps its comments either way, which is what the
// rewind of a speculative parse relies on.
let (mut leading, trailing) = (token.leading.clone(), token.trailing.clone());
if self.pos + 1 < self.tokens.len() {
self.pos += 1;
}
if !leading.is_empty() {
self.pending_leading.append(&mut leading);
}
if let Some(trailing) = trailing {
self.pending_trailing.push(trailing);
}
}
/// Open one level of nesting, refusing to recurse past
/// [`MAX_NESTING_DEPTH`]. Callers that succeed must pair this with
/// [`Parser::leave`] on every path out, including the error paths.
@@ -199,7 +224,7 @@ impl<'a> Parser<'a> {
pub(super) fn eat_sym(&mut self, sym: &str) -> bool {
if self.cur().is_sym(sym) {
self.bump();
self.skip();
true
} else {
false
@@ -208,7 +233,7 @@ impl<'a> Parser<'a> {
pub(super) fn eat_kw(&mut self, kw: &str) -> bool {
if self.cur().is_kw(kw) {
self.bump();
self.skip();
true
} else {
false
+7 -7
View File
@@ -39,7 +39,7 @@ impl<'a> Parser<'a> {
// this function with the `virtual` already taken into
// `DataDecl::qualifiers`, so this only fires for the other positions.)
if self.cur().is_kw("virtual") {
self.bump();
self.skip();
ty.virt =
Some(if self.eat_kw("interface") { VirtualKw::Interface } else { VirtualKw::Bare });
// `virtual spi_if.tb sif` — a modport-qualified virtual interface
@@ -97,12 +97,12 @@ impl<'a> Parser<'a> {
// comment inside the brackets could attach.
let mut comments =
SegmentComments { before_open: self.take_gap(), ..Default::default() };
self.bump();
self.skip();
comments.after_open = self.take_gap();
let kind = if self.cur().is_sym("]") {
// `[]` — a dynamic array.
comments.before_close = std::mem::take(&mut comments.after_open);
self.bump();
self.skip();
dims.push(Dim {
kind: DimKind::Dynamic,
comments: Box::new(comments),
@@ -111,7 +111,7 @@ impl<'a> Parser<'a> {
continue;
} else if self.cur().is_sym("*") && self.nth(1).is_sym("]") {
// `[*]` — a wildcard-keyed associative array.
self.bump();
self.skip();
DimKind::Wildcard
} else {
let a = self.parse_expr()?;
@@ -303,7 +303,7 @@ impl<'a> Parser<'a> {
// `wire /* c */ #5 w;`. Taken only here — when the read does not
// happen the gap belongs to whatever comes next.
let before_hash = self.take_gap();
self.bump();
self.skip();
let after_hash = self.take_gap();
Ok(Some(NetDelay { before_hash, after_hash, expr: self.parse_delay_value()?, after_type }))
}
@@ -392,7 +392,7 @@ impl<'a> Parser<'a> {
let mut eq_comments = BinaryComments::default();
let value = if self.cur().is_sym("=") {
eq_comments.before = self.take_gap();
self.bump();
self.skip();
eq_comments.after = self.take_gap();
Some(self.parse_expr()?)
} else {
@@ -436,7 +436,7 @@ impl<'a> Parser<'a> {
// grammar of their own and are still a clean parse error.
let tagged = word_at(self.cur(), "tagged");
if tagged {
self.bump();
self.skip();
header_comments.after_tagged = self.take_gap();
}
let packed = self.eat_kw("packed");
+2 -2
View File
@@ -347,8 +347,8 @@ impl<'a> Parser<'a> {
let raw = if self.at_spaced_macro_call() {
let start = self.here();
let col = self.cur().col;
self.bump(); // `NAME
self.bump(); // (
self.skip(); // `NAME
self.skip(); // (
self.skip_balanced("(", ")")?;
// Verbatim, space included: the argument text is preprocessor
// input lucisv does not model, and closing the gap would make the
+8 -8
View File
@@ -64,7 +64,7 @@ impl<'a> Parser<'a> {
// Each of the four gaps inside a `? :` can hold comments; kept
// apart so none of them drifts across the `?` or the `:`.
let before_question = self.take_around(mark);
self.bump();
self.skip();
let after_question = self.take_around(mark);
let then = self.parse_expr()?;
let before_colon = self.take_around(mark);
@@ -144,7 +144,7 @@ impl<'a> Parser<'a> {
// The word is an operator like any other, and keeps the
// comments written on either side of it the same way.
let before = self.take_around(mark);
self.bump();
self.skip();
let after = self.take_around(mark);
let comments = Box::new(BinaryComments { before, after });
// `x inside `MACRO` — the macro expands to the `{...}` set,
@@ -324,7 +324,7 @@ impl<'a> Parser<'a> {
let base = Box::new(base);
if self.cur().is_sym(".") || self.cur().is_sym("::") {
let scoped = self.cur().is_sym("::");
self.bump();
self.skip();
comments.after_open = self.take_gap();
let name = self.expect_ident()?;
let comments = Box::new(comments);
@@ -415,7 +415,7 @@ impl<'a> Parser<'a> {
before_open: self.take_before_open("("),
..CallComments::default()
};
self.bump();
self.skip();
let mut args = Vec::new();
if !self.cur().is_sym(")") {
let arg_start = self.here();
@@ -462,14 +462,14 @@ impl<'a> Parser<'a> {
},
);
} else if self.nth(1).is_sym("[") {
self.bump(); // with
self.skip(); // with
let range = self.parse_stream_range(comments)?;
expr = self.expr_at(
start,
ExprKind::StreamWith { base: Box::new(expr), range: Box::new(range) },
);
} else {
self.bump(); // with
self.skip(); // with
comments.after_kw = self.take_before_open("(");
// `( expression )` — an ordinary parenthesized primary,
// which is what IEEE 1800 §7.12 spells here.
@@ -511,9 +511,9 @@ impl<'a> Parser<'a> {
},
);
} else {
self.bump(); // '
self.skip(); // '
comments.after_tick = self.take_gap();
self.bump(); // (
self.skip(); // (
comments.after_open = self.take_gap();
let inner = self.parse_expr()?;
comments.before_close = self.gap_before(")");
+11 -11
View File
@@ -24,7 +24,7 @@ impl<'a> Parser<'a> {
let mut after_hash = Vec::new();
let mut after_delay = Vec::new();
let delay = if self.cur().is_sym("#") {
self.bump();
self.skip();
after_hash = self.take_gap();
let delay = self.parse_delay_value()?;
// The gap between the delay and the first left-hand side is the
@@ -82,7 +82,7 @@ impl<'a> Parser<'a> {
}
let mut comments =
Box::new(DriveStrengthComments { before_open: self.take_gap(), ..Default::default() });
self.bump(); // (
self.skip(); // (
comments.after_open = self.take_gap();
let first = self.bump().text;
// The gap after the first strength ends either at the `,` or at the
@@ -121,7 +121,7 @@ impl<'a> Parser<'a> {
// What is written just inside the `(` belongs to the first value; the
// gap before each `,` and the gap after it belong to the values either
// side of it.
self.bump();
self.skip();
let mut leading = self.take_gap();
let mut out: Vec<DelayValue> = Vec::new();
loop {
@@ -242,7 +242,7 @@ impl<'a> Parser<'a> {
/// `bind <target> [: <inst>, ...] <module> [#(...)] <name> (...);`
pub(super) fn parse_bind(&mut self) -> PResult<BindDirective> {
self.bump(); // `bind`
self.skip(); // `bind`
// The target is a bare string, so a comment written before it has no
// node to attach to: harvest it here, where source order is still
// known, rather than letting it drift onto the instance below.
@@ -250,7 +250,7 @@ impl<'a> Parser<'a> {
let start = self.here();
let mut target = vec![self.parse_path_segment()?];
while self.cur().is_sym(".") {
self.bump();
self.skip();
target.push(self.parse_path_segment()?);
}
let target_span = self.span_from(start);
@@ -278,7 +278,7 @@ impl<'a> Parser<'a> {
let start = self.here();
let mut text = self.expect_ident()?;
while self.cur().is_sym(".") {
self.bump();
self.skip();
let segment = self.expect_ident()?;
Self::push_path_segment(&mut text, &segment);
}
@@ -301,7 +301,7 @@ impl<'a> Parser<'a> {
let module_start = self.here();
let mut module = self.expect_ident()?;
while self.cur().is_sym("::") {
self.bump();
self.skip();
let segment = self.expect_ident()?;
Self::push_scope_segment(&mut module, &segment);
}
@@ -312,7 +312,7 @@ impl<'a> Parser<'a> {
let mut after_hash = Vec::new();
let mut param_directives = Vec::new();
if self.cur().is_sym("#") {
self.bump();
self.skip();
after_hash = self.take_gap();
self.expect_sym("(")?;
let mut list = Vec::new();
@@ -571,7 +571,7 @@ impl<'a> Parser<'a> {
// `.name(/* unused */)`: the comments were written inside
// these parens and are printed back inside them.
let inside = self.take_around(mark);
self.bump();
self.skip();
Some(self.expr_at(paren_start, ExprKind::Empty(inside)))
} else {
after_open = self.take_gap();
@@ -684,7 +684,7 @@ impl<'a> Parser<'a> {
let start = self.here();
let col = self.cur().col;
while self.pos < end_pos && !self.at_eof() {
self.bump();
self.skip();
}
let raw = self.verbatim_since(start, col);
self.expr_at(start, ExprKind::Verbatim(raw))
@@ -699,7 +699,7 @@ impl<'a> Parser<'a> {
let before_hash = self.take_before_open("#");
let mut after_hash = Vec::new();
let delay = if self.cur().is_sym("#") {
self.bump();
self.skip();
after_hash = self.take_gap();
self.parse_delay_values()?
} else {
+11 -11
View File
@@ -155,7 +155,7 @@ impl<'a> Parser<'a> {
// `TokenKind` match below because punctuation is matched by text
// everywhere in this file. See `ItemKind::Empty`.
if self.cur().is_sym(";") {
self.bump();
self.skip();
return Ok(ItemKind::Empty);
}
let t = self.cur();
@@ -209,7 +209,7 @@ impl<'a> Parser<'a> {
"modport" => self.parse_modport().map(ItemKind::Modport),
"clocking" => self.parse_clocking(false).map(ItemKind::Clocking),
"default" if self.nth(1).is_kw("clocking") => {
self.bump();
self.skip();
self.parse_clocking(true).map(ItemKind::Clocking)
}
"default" if self.nth(1).is_kw("disable") => self.parse_default_disable_item(),
@@ -243,7 +243,7 @@ impl<'a> Parser<'a> {
Ok(ItemKind::PortDecl(d))
}
"genvar" => {
self.bump();
self.skip();
let mut names = vec![self.expect_name()?];
while self.eat_sym(",") {
names.push(self.expect_name()?);
@@ -258,15 +258,15 @@ impl<'a> Parser<'a> {
Ok(ItemKind::Always { kw, stmt })
}
"initial" => {
self.bump();
self.skip();
Ok(ItemKind::Initial(self.parse_stmt()?))
}
"final" => {
self.bump();
self.skip();
Ok(ItemKind::Final(self.parse_stmt()?))
}
"generate" => {
self.bump();
self.skip();
let mut items = Vec::new();
while !self.at_body_end("endgenerate") {
items.push(self.item_or_recover()?);
@@ -339,7 +339,7 @@ impl<'a> Parser<'a> {
}
}
"defparam" => {
self.bump();
self.skip();
let mut pairs = Vec::new();
loop {
let lhs = self.parse_expr()?;
@@ -492,7 +492,7 @@ impl<'a> Parser<'a> {
loop {
let star = self.cur().span;
let pkg = if allow_star_pkg && self.cur().is_sym("*") {
self.bump();
self.skip();
Name { text: "*".to_string(), span: star }
} else {
self.expect_name()?
@@ -578,7 +578,7 @@ impl<'a> Parser<'a> {
}
let span = self.cur().span;
let name = Name { text: self.bump().text, span };
self.bump();
self.skip();
Some(name)
}
@@ -603,7 +603,7 @@ impl<'a> Parser<'a> {
let then = self.parse_gen_block()?;
let els = if self.cur().is_kw("else") {
let meta = self.take_meta();
self.bump();
self.skip();
if self.cur().is_kw("if") {
Some(Box::new(GenElse::If(meta, Box::new(self.parse_gen_if()?))))
} else {
@@ -688,7 +688,7 @@ impl<'a> Parser<'a> {
// The gap between whatever came before and the `begin` belongs to
// the block — nothing else was written where it could attach.
let before_kw = self.take_gap();
self.bump();
self.skip();
let before_colon = self.gap_before(":");
let mut after_colon = Vec::new();
let label_name = if self.eat_sym(":") {
+18 -18
View File
@@ -22,7 +22,7 @@ impl<'a> Parser<'a> {
let kw = self.cur().text.clone();
match kw.as_str() {
"begin" => {
self.bump();
self.skip();
let (label_comments, label_name) = self.parse_label_with()?;
let (label, label_span) = split_label(label_name);
let mut stmts = Vec::new();
@@ -45,7 +45,7 @@ impl<'a> Parser<'a> {
})
}
"fork" => {
self.bump();
self.skip();
let (label_comments, label_name) = self.parse_label_with()?;
let (label, label_span) = split_label(label_name);
let mut stmts = Vec::new();
@@ -88,7 +88,7 @@ impl<'a> Parser<'a> {
"case" | "casex" | "casez" => self.parse_case_stmt(None),
"for" => self.parse_for_stmt(),
"while" => {
self.bump();
self.skip();
self.expect_sym("(")?;
let cond = self.cond_or_recover()?;
let recovered = cond.is_error();
@@ -96,7 +96,7 @@ impl<'a> Parser<'a> {
Ok(StmtKind::While { cond, body: Box::new(self.body_after_recovery(recovered)?) })
}
"do" => {
self.bump();
self.skip();
let body = Box::new(self.parse_stmt()?);
self.expect_kw("while")?;
let mut comments =
@@ -110,7 +110,7 @@ impl<'a> Parser<'a> {
Ok(StmtKind::DoWhile { body, cond, comments: Box::new(comments) })
}
"repeat" => {
self.bump();
self.skip();
self.expect_sym("(")?;
let count = self.cond_or_recover()?;
let recovered = count.is_error();
@@ -118,11 +118,11 @@ impl<'a> Parser<'a> {
Ok(StmtKind::Repeat { count, body: Box::new(self.body_after_recovery(recovered)?) })
}
"forever" => {
self.bump();
self.skip();
Ok(StmtKind::Forever { body: Box::new(self.parse_stmt()?) })
}
"foreach" => {
self.bump();
self.skip();
let mut comments =
HeaderComments { after_kw: self.take_gap(), ..Default::default() };
self.expect_sym("(")?;
@@ -141,41 +141,41 @@ impl<'a> Parser<'a> {
})
}
"randcase" => {
self.bump();
self.skip();
let (items, dangling) = self.parse_case_body()?;
Ok(StmtKind::RandCase { items, dangling })
}
"return" => {
self.bump();
self.skip();
let after_kw = self.take_gap();
let expr = if self.cur().is_sym(";") { None } else { Some(self.parse_expr()?) };
self.expect_stmt_semi()?;
Ok(StmtKind::Return { after_kw, expr })
}
"break" => {
self.bump();
self.skip();
self.expect_stmt_semi()?;
Ok(StmtKind::Break)
}
"continue" => {
self.bump();
self.skip();
self.expect_stmt_semi()?;
Ok(StmtKind::Continue)
}
"disable" => {
self.bump();
self.skip();
// `disable fork;` kills every process the enclosing `fork`
// started; `fork` is a keyword, not a block name.
if self.cur().is_kw("fork") {
let name_span = self.cur().span;
self.bump();
self.skip();
self.expect_stmt_semi()?;
return Ok(StmtKind::Disable { name: "fork".to_string(), name_span });
}
let start = self.here();
let mut name = self.expect_ident()?;
while self.cur().is_sym(".") {
self.bump();
self.skip();
name.push('.');
name.push_str(&self.expect_ident()?);
}
@@ -184,11 +184,11 @@ impl<'a> Parser<'a> {
Ok(StmtKind::Disable { name, name_span })
}
"wait" => {
self.bump();
self.skip();
// `wait fork;` waits for the enclosing `fork`'s children
// (IEEE 1800 §9.6.1); `fork` is a keyword, not a condition.
if self.cur().is_kw("fork") {
self.bump();
self.skip();
self.expect_stmt_semi()?;
return Ok(StmtKind::WaitFork);
}
@@ -217,7 +217,7 @@ impl<'a> Parser<'a> {
Ok(StmtKind::Assert { kw, cond, then, els })
}
"force" => {
self.bump();
self.skip();
let lhs = self.parse_unary()?;
self.expect_sym("=")?;
let rhs = self.parse_expr()?;
@@ -290,7 +290,7 @@ impl<'a> Parser<'a> {
/// is parsed as usual. The init entries read before the failure are kept
/// — they are what declares the loop variable the body uses.
fn parse_for_stmt(&mut self) -> PResult<StmtKind> {
self.bump();
self.skip();
let mut comments = ForComments { after_kw: self.take_gap(), ..Default::default() };
self.expect_sym("(")?;
comments.after_open = self.take_gap();
+2 -2
View File
@@ -431,7 +431,7 @@ impl<'a> Parser<'a> {
let mut scope: Vec<ScopeSeg> = Vec::new();
while self.cur().is_sym("::") {
let before_sep = self.take_gap();
self.bump();
self.skip();
let after_sep = self.take_gap();
let next = self.expect_name()?;
scope.push(ScopeSeg { name, before_sep, after_sep });
@@ -474,7 +474,7 @@ impl<'a> Parser<'a> {
let start = self.here();
let mut name = self.expect_ident()?;
while self.cur().is_sym("::") {
self.bump();
self.skip();
let segment = self.expect_ident()?;
Self::push_scope_segment(&mut name, &segment);
}
+5 -5
View File
@@ -327,7 +327,7 @@ impl<'a> Parser<'a> {
return Ok(None);
}
let before_dir = self.take_gap();
self.bump();
self.skip();
let after_dir = self.take_gap();
Ok(Some(ClockingDefault { before_dir, after_dir, skew: self.parse_clocking_skew()? }))
}
@@ -387,7 +387,7 @@ impl<'a> Parser<'a> {
if !self.cur().is_sym("#") {
return Ok(out);
}
self.bump();
self.skip();
out.after_hash = self.take_gap();
self.expect_sym("(")?;
let mark = self.diags_mark();
@@ -438,7 +438,7 @@ impl<'a> Parser<'a> {
return Ok((Box::default(), None));
}
let before = self.take_gap();
self.bump();
self.skip();
let after = self.take_gap();
let value = parse(self)?;
Ok((Box::new(BinaryComments { before, after }), Some(value)))
@@ -507,7 +507,7 @@ impl<'a> Parser<'a> {
if !self.cur().is_sym("(") {
return Ok((PortList::None, Vec::new(), Vec::new()));
}
self.bump();
self.skip();
let mark = self.diags_mark();
// Directives before the first port. Harvested here rather than in the
// loop below because both the ANSI/non-ANSI decision and the
@@ -517,7 +517,7 @@ impl<'a> Parser<'a> {
if self.cur().is_sym(")") {
// `module m (/* c */);` — the comments stay between the parens.
let dangling = self.take_dangling();
self.bump();
self.skip();
return Ok((PortList::Empty, dangling, directives));
}
let ansi = {
+13 -13
View File
@@ -31,7 +31,7 @@ impl<'a> Parser<'a> {
}
TokenKind::Ident | TokenKind::SystemIdent => {
if self.at_shallow_copy() {
self.bump(); // new
self.skip(); // new
let src = self.parse_postfix()?;
return Ok(self.expr_at(start, ExprKind::New(Box::new(src))));
}
@@ -53,9 +53,9 @@ impl<'a> Parser<'a> {
let ty = self.expr_at(ty_start, ExprKind::Ident(ty_text));
let mut comments =
CastComments { before_tick: self.take_gap(), ..Default::default() };
self.bump(); // '
self.skip(); // '
comments.after_tick = self.take_gap();
self.bump(); // (
self.skip(); // (
comments.after_open = self.take_gap();
let inner = self.parse_expr()?;
comments.before_close = self.gap_before(")");
@@ -85,14 +85,14 @@ impl<'a> Parser<'a> {
// work through the existing expression grammar, and lucisv
// checks legality nowhere else either.
"$" => {
self.bump();
self.skip();
Ok(self.expr_at(start, ExprKind::Ident("$".to_string())))
}
"(" => {
// Comments written just inside the parens stay there;
// anything else would move them across a token.
let mut before = self.take_trailing_here();
self.bump();
self.skip();
before.append(&mut self.take_leading_here());
let mark = self.pending_trailing.len();
let inner_start = self.here();
@@ -106,7 +106,7 @@ impl<'a> Parser<'a> {
))
}
"{" => {
self.bump();
self.skip();
if self.cur().is_sym("<<") || self.cur().is_sym(">>") {
return self.parse_stream_concat(start);
}
@@ -114,13 +114,13 @@ impl<'a> Parser<'a> {
// `{}` — the empty queue/dynamic-array literal
// (`q = {};`). Illegal as a Verilog concatenation,
// but lucisv is not a legality checker.
self.bump();
self.skip();
return Ok(self.expr_at(start, ExprKind::Concat(Vec::new())));
}
let first = self.parse_expr_item()?;
if self.cur().is_sym("{") {
// Replication {N{a, b}}
self.bump();
self.skip();
let inner_first = self.parse_expr_item()?;
let inner = self.parse_expr_list(inner_first, "}")?;
self.expect_sym("}")?;
@@ -241,7 +241,7 @@ impl<'a> Parser<'a> {
/// (`ty'{...}`) keeps the type outside the pattern's span, in the `Cast`
/// node that wraps it.
pub(super) fn parse_assign_pattern(&mut self, start: u32) -> PResult<Expr> {
self.bump(); // '{
self.skip(); // '{
if self.at_assign_pattern_repl() {
return self.parse_assign_pattern_repl(start);
}
@@ -251,7 +251,7 @@ impl<'a> Parser<'a> {
let item_start = self.here();
let mut meta = self.take_meta();
let key_or_val = if self.cur().is_kw("default") {
self.bump();
self.skip();
self.expr_at(item_start, ExprKind::Ident("default".to_string()))
} else {
self.parse_expr_or_type()?
@@ -352,7 +352,7 @@ impl<'a> Parser<'a> {
/// the `.` and the next token is an identifier.
pub(super) fn parse_named_arg(&mut self) -> PResult<Expr> {
let start = self.here();
self.bump(); // .
self.skip(); // .
let after_dot = self.take_gap();
let Name { text: name, span: name_span } = self.expect_name()?;
let before_open = self.take_before_open("(");
@@ -365,7 +365,7 @@ impl<'a> Parser<'a> {
// between the parens, exactly as an empty connection does. The
// span covers the `( )` pair.
let comments = self.take_around(mark);
self.bump();
self.skip();
(self.expr_at(paren_start, ExprKind::Empty(comments)), Vec::new())
} else {
after_open = self.take_gap();
@@ -403,7 +403,7 @@ impl<'a> Parser<'a> {
pub(super) fn parse_value_range(&mut self) -> PResult<Expr> {
let start = self.here();
let mut comments = SegmentComments { before_open: self.take_gap(), ..Default::default() };
self.bump(); // [
self.skip(); // [
comments.after_open = self.take_gap();
let lo = self.parse_expr()?;
comments.before_op = self.gap_before(":");
@@ -52,7 +52,7 @@ impl<'a> Parser<'a> {
// The gap in front of the `|` belongs to the alternative it opens,
// so it prints on the bar's own side of the previous one.
let before_bar = self.take_gap();
self.bump();
self.skip();
alternatives.push(self.parse_alternative(before_bar)?);
}
let span = self.span_from(start);
@@ -107,8 +107,8 @@ impl<'a> Parser<'a> {
let mut weight = None;
if self.at_weight_op() {
before_weight = self.take_gap();
self.bump(); // :
self.bump(); // =
self.skip(); // :
self.skip(); // =
weight = Some(self.parse_weight()?);
}
Ok(Alternative { before_bar, after_bar, items, before_weight, weight })
@@ -170,7 +170,7 @@ impl<'a> Parser<'a> {
return self.parse_rs_if();
}
if t.is_kw("repeat") {
self.bump();
self.skip();
let after_kw = self.take_before_open("(");
self.expect_sym("(")?;
let count = self.parse_expr()?;
@@ -240,7 +240,7 @@ impl<'a> Parser<'a> {
// A `default` arm may write no `:` at all (§18.17.4).
let has_colon = self.cur().is_sym(":");
if has_colon {
self.bump();
self.skip();
} else if !is_default {
return self.error("expected `:` in a randsequence case arm");
}
@@ -271,7 +271,7 @@ impl<'a> Parser<'a> {
let after_rand = self.take_gap();
self.expect_kw("join")?;
let weight = if self.cur().is_sym("(") {
self.bump();
self.skip();
let e = self.parse_expr()?;
self.expect_sym(")")?;
Some(e)
@@ -292,7 +292,7 @@ impl<'a> Parser<'a> {
let has_parens = self.cur().is_sym("(");
let mut args = Vec::new();
if has_parens {
self.bump();
self.skip();
if !self.cur().is_sym(")") {
let first = self.parse_expr_item()?;
args = self.parse_expr_list(first, ")")?;
+4 -4
View File
@@ -102,7 +102,7 @@ impl<'a> Parser<'a> {
/// error node.
pub(super) fn expect_closer(&mut self, kw: &str) -> PResult<()> {
if self.cur().is_kw(kw) {
self.bump();
self.skip();
return Ok(());
}
if self.tolerant {
@@ -150,7 +150,7 @@ impl<'a> Parser<'a> {
return;
}
if t.is_sym(";") {
self.bump();
self.skip();
return;
}
}
@@ -159,7 +159,7 @@ impl<'a> Parser<'a> {
} else if open > 0 && (t.is_sym(")") || t.is_sym("]") || t.is_sym("}")) {
open -= 1;
}
self.bump();
self.skip();
}
}
@@ -171,7 +171,7 @@ impl<'a> Parser<'a> {
if self.pos == start_pos {
// The failed construct consumed nothing, so skipping might not
// either; take one token to guarantee the enclosing loop advances.
self.bump();
self.skip();
}
self.skip_to_sync();
// Comments inside the skipped range are part of the raw text below.
@@ -227,7 +227,7 @@ impl<'a> Parser<'a> {
if self.pos == start_pos && !self.cur().is_sym(")") {
// The header consumed nothing and the skip below may not either;
// take one token so the statement cannot be re-read forever.
self.bump();
self.skip();
}
self.skip_inside_brackets(true);
// As in `recover`: comments inside the skipped range are bytes of the
@@ -247,7 +247,7 @@ impl<'a> Parser<'a> {
// Nothing was consumed and nothing below will be: the list loop
// neither ends here nor eats a separator, so take one token to
// guarantee it advances.
self.bump();
self.skip();
} else if self.at_open_bracket() {
// The element gave up standing *on* a bracket, which is therefore
// one it opened and never closed — the `(` of a half-typed
@@ -258,7 +258,7 @@ impl<'a> Parser<'a> {
// the body would be swallowed looking for a `)` that was never
// written. Taken here, the skip starts inside it at the list's own
// level and stops at the next line as it does everywhere else.
self.bump();
self.skip();
}
self.skip_inside_brackets(false);
let _ = self.take_dangling();
@@ -310,7 +310,7 @@ impl<'a> Parser<'a> {
} else if closes {
open -= 1;
}
self.bump();
self.skip();
}
}
+1 -1
View File
@@ -274,7 +274,7 @@ impl<'a> Parser<'a> {
// already moved — are dropped by `verbatim_since`.
self.pos = mark.pos;
while self.pos < end_pos && !self.at_eof() {
self.bump();
self.skip();
}
self.verbatim_since(start, col)
}
+12 -12
View File
@@ -125,11 +125,11 @@ impl<'a> Parser<'a> {
return Ok(StmtKind::Directive(self.take_raw_text()));
}
if t.is_sym(";") {
self.bump();
self.skip();
return Ok(StmtKind::Null);
}
if t.is_sym("#") {
self.bump();
self.skip();
let after_hash = self.take_gap();
let delay = self.parse_delay_value()?;
let stmt = if self.eat_stmt_semi() { None } else { Some(Box::new(self.parse_stmt()?)) };
@@ -139,7 +139,7 @@ impl<'a> Parser<'a> {
});
}
if t.is_sym("@") {
self.bump();
self.skip();
let sens = self.parse_sens_list()?;
let stmt = if self.eat_stmt_semi() { None } else { Some(Box::new(self.parse_stmt()?)) };
return Ok(StmtKind::Timing { control: TimingControl::Event(sens), stmt });
@@ -204,7 +204,7 @@ impl<'a> Parser<'a> {
// keyword's left; the then-branch has already taken its own
// trailing comment.
else_comments = self.take_dangling();
self.bump();
self.skip();
Some(Box::new(self.parse_stmt()?))
} else {
None
@@ -306,7 +306,7 @@ impl<'a> Parser<'a> {
if let Some(last) = vars.last_mut() {
last.after = self.take_gap();
}
self.bump();
self.skip();
vars.push(self.parse_foreach_var()?);
}
}
@@ -343,7 +343,7 @@ impl<'a> Parser<'a> {
if self.cur().kind == TokenKind::Symbol && (ASSIGN_OPS.contains(&op.as_str()) || op == "<=")
{
let before = self.take_around(mark);
self.bump();
self.skip();
let after = self.take_gap();
let rhs = self.parse_expr()?;
Ok(ForStep::Assign(SimpleAssign {
@@ -377,16 +377,16 @@ impl<'a> Parser<'a> {
// it (`x[6:0] /* opcode */ = v;`); left in the pending buffers
// they would be lost and the safety net would refuse the file.
let op_comments = self.take_around(mark);
self.bump();
self.skip();
let rhs_comments = self.take_around(mark);
let timing = if self.cur().is_sym("#") {
self.bump();
self.skip();
Some(TimingControl::Delay {
after_hash: self.take_gap(),
expr: self.parse_delay_value()?,
})
} else if self.cur().is_sym("@") {
self.bump();
self.skip();
Some(TimingControl::Event(self.parse_sens_list()?))
} else {
None
@@ -430,7 +430,7 @@ impl<'a> Parser<'a> {
if self.cur().is_sym("*") {
// `@*` without parens — the gap after the `@` is the `*`'s own
// `before` slot, which the formatter prints in the same place.
self.bump();
self.skip();
return Ok(SensList::Star { before: after_at, after: Vec::new() });
}
if self.cur().kind == TokenKind::Ident {
@@ -449,10 +449,10 @@ impl<'a> Parser<'a> {
// to whatever node comes next.
let mut before = after_at;
before.append(&mut self.take_trailing_here());
self.bump(); // (
self.skip(); // (
before.append(&mut self.take_leading_here());
let mut after = self.take_trailing_here();
self.bump(); // *
self.skip(); // *
after.append(&mut self.take_leading_here());
self.expect_sym(")")?;
return Ok(SensList::Star { before, after });
+8 -8
View File
@@ -218,7 +218,7 @@ impl<'a> Parser<'a> {
self.link()?;
let before = self.take_around(mark);
for _ in 0..tokens {
self.bump();
self.skip();
}
let after = self.take_around(mark);
let rhs = self.parse_prop_expr(Self::right_operand_prec(prec, right))?;
@@ -316,7 +316,7 @@ impl<'a> Parser<'a> {
let mut count = None;
let mut after_count = Vec::new();
if counted && self.cur().is_sym("[") {
self.bump();
self.skip();
let after_open = self.take_gap();
count = Some(Box::new(SvaRange { after_open, ..self.parse_sva_bounds()? }));
after_count = self.take_gap();
@@ -367,7 +367,7 @@ impl<'a> Parser<'a> {
let mut els = None;
if self.cur().is_kw("else") {
before_else = self.take_gap();
self.bump();
self.skip();
after_else = self.take_gap();
els = Some(self.parse_prop_expr(0)?);
}
@@ -421,7 +421,7 @@ impl<'a> Parser<'a> {
let mut labels = Vec::new();
let is_default = self.cur().is_kw("default");
if is_default {
self.bump();
self.skip();
} else {
loop {
labels.push(self.parse_expr_item()?);
@@ -463,7 +463,7 @@ impl<'a> Parser<'a> {
while self.at_repeat_bracket() {
self.link()?;
let before_open = self.take_gap();
self.bump(); // [
self.skip(); // [
let after_open = self.take_gap();
// `[+]` writes no operator of its own: its `+` is the bound.
let (op, after_op) = if self.cur().is_sym("+") {
@@ -493,7 +493,7 @@ impl<'a> Parser<'a> {
range.lo = Some(self.parse_expr()?);
if self.cur().is_sym(":") {
range.before_colon = self.take_gap();
self.bump();
self.skip();
range.after_colon = self.take_gap();
range.hi = Some(self.parse_expr()?);
}
@@ -509,7 +509,7 @@ impl<'a> Parser<'a> {
self.expect_sym("##")?;
let after_hash = self.take_gap();
if self.cur().is_sym("[") {
self.bump();
self.skip();
let after_open = self.take_gap();
let range = Box::new(SvaRange { after_open, ..self.parse_sva_bounds()? });
return Ok(CycleDelay { after_hash, expr: None, range: Some(range) });
@@ -707,7 +707,7 @@ impl<'a> Parser<'a> {
let mut items = Vec::new();
while self.cur().is_sym(",") {
let before_comma = self.take_gap();
self.bump();
self.skip();
let start = self.here();
let meta = self.take_meta();
let lhs = self.parse_expr()?;
+5 -5
View File
@@ -227,12 +227,12 @@ impl<'a> Parser<'a> {
if !self.cur().is_sym("(") {
return Ok(TfPorts::default());
}
self.bump();
self.skip();
if self.cur().is_sym(")") {
// Only what was written *inside* the empty `()`, as an empty
// argument list of a call keeps.
let dangling = self.take_gap();
self.bump();
self.skip();
return Ok(TfPorts { args, dangling });
}
let mark = self.diags_mark();
@@ -272,9 +272,9 @@ impl<'a> Parser<'a> {
// `ibex/vendor/lowrisc_ip/dv/sv/dv_utils/dv_utils_pkg.sv:104`.
// Two keywords, so the gap between them is a slot of its own —
// no other direction has an inside.
self.bump();
self.skip();
after_const = self.take_gap();
self.bump();
self.skip();
Some("const ref".to_string())
} else if t.is_kw("input") || t.is_kw("output") || t.is_kw("inout") || t.is_kw("ref") {
Some(self.bump().text)
@@ -298,7 +298,7 @@ impl<'a> Parser<'a> {
let mut eq_comments = BinaryComments::default();
let default = if self.cur().is_sym("=") {
eq_comments.before = self.take_gap();
self.bump();
self.skip();
eq_comments.after = self.take_gap();
Some(self.parse_expr()?)
} else {
+7 -7
View File
@@ -38,7 +38,7 @@ impl<'a> Parser<'a> {
} else if t.is_kw(&open) {
depth += 1;
}
self.bump();
self.skip();
}
self.expect_closer(close)?;
self.parse_label()?;
@@ -52,7 +52,7 @@ impl<'a> Parser<'a> {
pub(super) fn parse_opaque_line(&mut self) -> PResult<RawText> {
let start = self.here();
let col = self.cur().col;
self.bump();
self.skip();
self.skip_to_semi()?;
Ok(self.verbatim_since(start, col))
}
@@ -94,7 +94,7 @@ impl<'a> Parser<'a> {
/// than as a nested assignment. How many there are, and whether they are
/// legal lvalues, is a checker's business.
pub(super) fn parse_alias(&mut self) -> PResult<ItemKind> {
self.bump(); // alias
self.skip(); // alias
let mut nets = vec![self.parse_expr()?];
while self.eat_sym("=") {
nets.push(self.parse_expr()?);
@@ -154,7 +154,7 @@ impl<'a> Parser<'a> {
pub(super) fn parse_expect_statement(&mut self) -> PResult<RawText> {
let start = self.here();
let col = self.cur().col;
self.bump(); // expect
self.skip(); // expect
self.expect_sym("(")?;
self.skip_balanced("(", ")")?;
self.skip_action_block()?;
@@ -176,7 +176,7 @@ impl<'a> Parser<'a> {
} else if t.is_sym(close) {
depth -= 1;
}
self.bump();
self.skip();
}
Ok(())
}
@@ -215,12 +215,12 @@ impl<'a> Parser<'a> {
"[" => ("[", "]"),
_ => ("{", "}"),
};
self.bump();
self.skip();
self.skip_balanced(open, close)?;
} else if self.eat_sym(";") {
return Ok(());
} else {
self.bump();
self.skip();
}
}
}
@@ -199,6 +199,49 @@ fn a_name_declared_in_two_files_stays_on_the_slow_road() {
assert!(rename(&sources, &path, at, "renamed_thing").is_err(), "and the workspace refuses it");
}
/// TODO §63.1 QA. A `bind`'s connection expressions resolve in the *target's*
/// scope, which a single buffer never holds — so both shapes must defer, and
/// the fixture is swept to prove neither is ever an *invented* refusal.
const AES_FOR_BIND: &str = "module aes (input logic clk_i, output logic idle_o);\n \
logic entropy_masking_req;\n aes_core u_aes_core (.clk_i(clk_i));\n \
assign idle_o = entropy_masking_req;\nendmodule : aes\n";
const AES_CORE_FOR_BIND: &str =
"module aes_core (input logic clk_i);\n logic seed_en;\n assign seed_en = clk_i;\nendmodule : aes_core\n";
const RESEED_IF_FOR_BIND: &str =
"module aes_reseed_if (input logic entropy_masking_req, input logic seed_en);\nendmodule : aes_reseed_if\n";
const AES_BIND: &str = "module aes_bind;\n bind aes aes_reseed_if u_aes_reseed_if (\n \
.entropy_masking_req(entropy_masking_req),\n .seed_en(u_aes_core.seed_en)\n );\nendmodule\n";
#[test]
fn a_binds_connection_expressions_defer_rather_than_invent_a_refusal() {
// Before this lane a bare-name connection carried a one-segment external
// candidate (deferred already) but a hierarchical tail carried *no*
// reference at all — `symbol_at` finds no declaration either, so the
// preflight fell to `NOTHING_HERE`, a refusal the workspace does not
// agree with (it resolves and edits the tail). The oracle's own
// `(Err, Ok)` branch panics on exactly that shape, so a plain sweep is the
// proof: nothing here may ever be an invented refusal.
let files = [
("aes.sv", AES_FOR_BIND),
("aes_core.sv", AES_CORE_FOR_BIND),
("aes_reseed_if.sv", RESEED_IF_FOR_BIND),
("aes_bind.sv", AES_BIND),
];
let (_, deferred) = rename_oracle(&files, "aes_bind.sv");
assert!(deferred > 0, "every connection expression in a bind file defers to the workspace");
// And named exactly, at the hierarchical tail's own byte: this is the one
// Handshakes calls out as changed — `NOTHING_HERE` before, `Ok(())` now.
let semantics = analyze(&parse_source_tolerant(AES_BIND).0, AES_BIND);
let at =
AES_BIND.find("u_aes_core.seed_en").expect("the tail") as u32 + "u_aes_core.".len() as u32;
assert!(
rename_preflight(&semantics, at, "renamed_thing").is_ok(),
"the preflight must stand aside for a bind's hierarchical tail, which only the \
workspace can root at the bind target"
);
}
#[test]
fn renaming_a_symbol_to_the_name_it_already_has_is_refused_from_the_buffer() {
let files = [("sub.sv", SUB), ("top.sv", TOP)];
+719
View File
@@ -0,0 +1,719 @@
//! A `bind` directive's own occurrences of a renamed name (TODO §63.1).
//!
//! `bind aes aes_reseed_if u_x (.entropy_masking_req(entropy_masking_req));`
//! writes the target module's internal net down in a file that instantiates
//! nothing in the chain. IEEE 1800 §23.11 evaluates such a connection in the
//! **target's** scope, so the name is a use of `aes`'s net and a rename must
//! edit it — or say out loud that it could not. Silence is a wrong answer: the
//! design no longer elaborates after the rename.
//!
//! Every test here is one of the shapes §63.1 lists, driven through the public
//! `rename` over a little in-memory workspace: the bare-name connection, the
//! positional one, the two-level hierarchical tail, a `: u_x` instance-list
//! target, a hierarchical target path, a `bind` inside a generate block, and
//! the one the engine must *not* resolve — a target module the workspace does
//! not hold, which is warned about and never edited.
use std::path::{Path, PathBuf};
use vlog_refactor::{rename, rename_traced, rename_traced_with, RefactorEdit, RenameTrace};
/// A workspace of `(file name, text)` pairs, rooted at a fake directory.
fn workspace(files: &[(&str, &str)]) -> Vec<(PathBuf, String)> {
files.iter().map(|(name, text)| (PathBuf::from("/rtl").join(name), text.to_string())).collect()
}
fn path(name: &str) -> PathBuf {
PathBuf::from("/rtl").join(name)
}
/// The offset of the first whole-word `name` at or after `prefix`.
fn at(text: &str, prefix: &str, name: &str) -> u32 {
let from = match prefix.is_empty() {
true => 0,
false => {
text.find(prefix).unwrap_or_else(|| panic!("`{prefix}` is not in the text"))
+ prefix.len()
}
};
let is_word = |b: Option<&u8>| b.is_some_and(|b| b.is_ascii_alphanumeric() || *b == b'_');
let bytes = text.as_bytes();
let mut search = from;
while let Some(hit) = text.get(search..).and_then(|s| s.find(name)) {
let start = search + hit;
let end = start + name.len();
if !is_word(start.checked_sub(1).and_then(|i| bytes.get(i))) && !is_word(bytes.get(end)) {
return start as u32;
}
search = start + 1;
}
panic!("`{name}` does not occur after `{prefix}`");
}
/// Apply a refactoring's edits for one file.
fn apply(text: &str, edit: &RefactorEdit, file: &Path) -> String {
let mut out = String::new();
let mut cursor = 0usize;
for e in edit.edits_for(file) {
out.push_str(&text[cursor..e.range.start as usize]);
out.push_str(&e.new_text);
cursor = e.range.end as usize;
}
out.push_str(&text[cursor..]);
out
}
// ----------------------------------------------------------------------
// the little AES the fixtures bind into
// ----------------------------------------------------------------------
/// The target module: it declares the net every fixture renames, and it
/// instantiates the core the two-level tail walks through.
const AES: &str = "\
module aes (input logic clk_i, output logic idle_o);
logic entropy_masking_req;
aes_core u_aes_core (.clk_i(clk_i));
assign idle_o = entropy_masking_req;
endmodule : aes
";
const AES_CORE: &str = "\
module aes_core (input logic clk_i);
aes_prng_clearing u_aes_prng_clearing (.clk_i(clk_i));
endmodule : aes_core
";
const AES_PRNG: &str = "\
module aes_prng_clearing (input logic clk_i);
logic seed_en;
assign seed_en = clk_i;
endmodule : aes_prng_clearing
";
/// The checker a `bind` binds in. Its ports are deliberately spelled like the
/// names being renamed, so a fixture also proves the `.port` half is left
/// alone: it names *this* module's port, not the target's net.
const RESEED_IF: &str = "\
module aes_reseed_if (input logic entropy_masking_req, input logic seed_en);
endmodule : aes_reseed_if
";
/// The RTL half of every fixture's workspace.
fn rtl(bind_file: &str) -> Vec<(PathBuf, String)> {
workspace(&[
("aes.sv", AES),
("aes_core.sv", AES_CORE),
("aes_prng_clearing.sv", AES_PRNG),
("aes_reseed_if.sv", RESEED_IF),
("aes_bind.sv", bind_file),
])
}
/// Rename `name` (declared in `decl_file`, at the first whole-word occurrence
/// after `prefix`) to `new_name`, and return the bind file's new text together
/// with the rename's warnings.
fn rename_with_bind(
bind_file: &str,
decl_file: &str,
prefix: &str,
name: &str,
new_name: &str,
) -> (String, Vec<String>) {
let files = rtl(bind_file);
let text = files
.iter()
.find(|(p, _)| *p == path(decl_file))
.map(|(_, t)| t.clone())
.expect("the declaring file is in the workspace");
let edit = rename(&files, &path(decl_file), at(&text, prefix, name), new_name)
.unwrap_or_else(|e| panic!("the rename was refused: {e}"));
(apply(bind_file, &edit, &path("aes_bind.sv")), edit.warnings.clone())
}
// ----------------------------------------------------------------------
// the shapes that must be edited
// ----------------------------------------------------------------------
#[test]
fn a_bare_name_in_a_bind_connection_is_renamed() {
let bind = "\
module aes_bind;
bind aes aes_reseed_if u_aes_reseed_if (
.entropy_masking_req(entropy_masking_req)
);
endmodule
";
let (after, warnings) =
rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
assert_eq!(
after,
"\
module aes_bind;
bind aes aes_reseed_if u_aes_reseed_if (
.entropy_masking_req(masking_req)
);
endmodule
",
"the expression half names the target's net; the `.port` half names the checker's port"
);
assert!(warnings.is_empty(), "nothing was left unaccounted for: {warnings:?}");
}
#[test]
fn a_positional_connection_in_a_bind_is_renamed() {
let bind = "\
module aes_bind;
bind aes aes_reseed_if u_aes_reseed_if (entropy_masking_req, 1'b0);
endmodule
";
let (after, _) =
rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
assert_eq!(
after,
"\
module aes_bind;
bind aes aes_reseed_if u_aes_reseed_if (masking_req, 1'b0);
endmodule
"
);
}
#[test]
fn a_two_level_hierarchical_tail_in_a_bind_is_renamed() {
let bind = "\
module aes_bind;
bind aes aes_reseed_if u_aes_reseed_if (
.seed_en(u_aes_core.u_aes_prng_clearing.seed_en)
);
endmodule
";
let (after, warnings) =
rename_with_bind(bind, "aes_prng_clearing.sv", "logic", "seed_en", "reseed_en");
assert_eq!(
after,
"\
module aes_bind;
bind aes aes_reseed_if u_aes_reseed_if (
.seed_en(u_aes_core.u_aes_prng_clearing.reseed_en)
);
endmodule
",
"the tail is rooted at the bind target and walks two instances to the declaration"
);
assert!(warnings.is_empty(), "nothing was left unaccounted for: {warnings:?}");
}
#[test]
fn an_instance_list_target_still_names_the_target_module_scope() {
let bind = "\
module aes_bind;
bind aes : u_aes aes_reseed_if u_aes_reseed_if (
.entropy_masking_req(entropy_masking_req)
);
endmodule
";
let (after, _) =
rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
assert!(
after.contains(".entropy_masking_req(masking_req)"),
"`bind aes : u_aes` still binds into `aes`'s scope: {after}"
);
}
#[test]
fn a_bind_inside_a_generate_block_is_renamed() {
let bind = "\
module aes_bind;
if (1) begin : gen_prng_bind
bind aes aes_reseed_if u_aes_reseed_if (
.entropy_masking_req(entropy_masking_req)
);
end
endmodule
";
let (after, _) =
rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
assert!(
after.contains(".entropy_masking_req(masking_req)"),
"a generate block changes where the directive is written, not what it binds into: {after}"
);
}
#[test]
fn a_hierarchical_target_path_is_followed_through_the_instance_it_names() {
let tb = "\
module tb;
aes u_aes (.clk_i(1'b0), .idle_o());
endmodule : tb
";
let bind = "\
module aes_bind;
bind tb.u_aes aes_reseed_if u_aes_reseed_if (
.entropy_masking_req(entropy_masking_req)
);
endmodule
";
let mut files = rtl(bind);
files.push((path("tb.sv"), tb.to_string()));
let edit =
rename(&files, &path("aes.sv"), at(AES, "logic", "entropy_masking_req"), "masking_req")
.expect("renames");
assert_eq!(
apply(bind, &edit, &path("aes_bind.sv")),
"\
module aes_bind;
bind tb.u_aes aes_reseed_if u_aes_reseed_if (
.entropy_masking_req(masking_req)
);
endmodule
",
"`tb.u_aes` is one instance hop the index can take, so the connection resolves"
);
}
// ----------------------------------------------------------------------
// the shape the engine must not resolve
// ----------------------------------------------------------------------
#[test]
fn a_bind_into_a_module_the_workspace_does_not_hold_is_warned_about_never_edited() {
let bind = "\
module aes_bind;
bind aes_shadow aes_reseed_if u_aes_reseed_if (
.entropy_masking_req(entropy_masking_req)
);
endmodule
";
let (after, warnings) =
rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
assert_eq!(after, bind, "nothing in the bind file was edited");
assert!(
warnings.iter().any(|w| w.contains("aes_bind.sv")
&& w.contains("aes_shadow::entropy_masking_req")
&& w.contains("could not be resolved")),
"the miss is said out loud, with the file and the unit that was searched: {warnings:?}"
);
}
// ----------------------------------------------------------------------
// the edited bind file is an ordinary file to everything downstream
// ----------------------------------------------------------------------
// A regression guard rather than a flipped fixture: the collision is an
// ordinary same-file one (`aes.sv` already declares `masking_req`), so
// `check::verify` refused it before the bind file was understood at all
// (it passes at 2675131 unmodified — QA §63.1, finding 1). What it pins is
// that the refusal survives the bind file joining the edited set.
#[test]
fn a_new_name_the_bind_target_already_declares_is_refused() {
let aes = "\
module aes (input logic clk_i, output logic idle_o);
logic entropy_masking_req;
logic masking_req;
assign idle_o = entropy_masking_req & masking_req;
endmodule : aes
";
let bind = "\
module aes_bind;
bind aes aes_reseed_if u_aes_reseed_if (
.entropy_masking_req(entropy_masking_req)
);
endmodule
";
let files =
workspace(&[("aes.sv", aes), ("aes_reseed_if.sv", RESEED_IF), ("aes_bind.sv", bind)]);
let refusal =
rename(&files, &path("aes.sv"), at(aes, "logic", "entropy_masking_req"), "masking_req")
.expect_err("the new name is already taken in the scope the bind reaches into");
assert!(refusal.contains("masking_req"), "the refusal names the collision: {refusal}");
}
#[test]
fn renaming_a_bind_connection_back_restores_the_file_byte_for_byte() {
let bind = "\
module aes_bind;
bind aes aes_reseed_if u_aes_reseed_if (
.entropy_masking_req(entropy_masking_req),
.seed_en (u_aes_core.u_aes_prng_clearing.seed_en)
);
endmodule
";
let (once, _) = rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
assert_ne!(once, bind, "the first rename moved the bind file");
// The same workspace with both edits applied, renamed back: the engine
// resolves the new spelling exactly as it resolved the old one, so the
// bind file returns to the text it started with.
let aes_after = AES.replace("entropy_masking_req", "masking_req");
let files = workspace(&[
("aes.sv", &aes_after),
("aes_core.sv", AES_CORE),
("aes_prng_clearing.sv", AES_PRNG),
("aes_reseed_if.sv", RESEED_IF),
("aes_bind.sv", &once),
]);
let back = rename(
&files,
&path("aes.sv"),
at(&aes_after, "logic", "masking_req"),
"entropy_masking_req",
)
.expect("renames back");
assert_eq!(apply(&once, &back, &path("aes_bind.sv")), bind);
}
// ----------------------------------------------------------------------
// QA attack fixtures (TODO §63.1, task 3): shapes not in the dev's seven
// plus two, each aimed at a specific way the fix could be half right.
// ----------------------------------------------------------------------
#[test]
fn a_bind_connections_bare_name_naming_the_targets_port_is_still_renamed() {
// `in_bind_target`'s widened surface is `Connection` records first, then
// `Hierarchical`-only ones (`workspace/hierarchy.rs::member`) — so a port
// (which was already reachable through the narrow surface) must still
// resolve exactly as it did before this lane, through the same fallback
// that answers a net. `clk_i` is `aes`'s own port, connected bare in the
// `bind`; the `.port` half names the checker's unrelated port of the same
// name and must stay put.
let bind = "\
module aes_bind;
bind aes aes_reseed_if u_aes_reseed_if (
.entropy_masking_req(clk_i)
);
endmodule
";
let (after, warnings) = rename_with_bind(bind, "aes.sv", "input logic", "clk_i", "clk_ix");
assert_eq!(
after,
"\
module aes_bind;
bind aes aes_reseed_if u_aes_reseed_if (
.entropy_masking_req(clk_ix)
);
endmodule
",
"the expression half names `aes`'s port; the `.port` half is the checker's own, untouched"
);
assert!(warnings.is_empty(), "nothing was left unaccounted for: {warnings:?}");
}
#[test]
fn a_bind_connection_resolves_in_the_target_not_a_same_named_decoy_in_the_writing_scope() {
// The writing module — normally empty — now declares its own
// `entropy_masking_req`, spelling the same name `aes` does. If the
// connection ever fell back to the scope the directive is *written* in
// (finding 2's bug, for a bare name rather than a hierarchical tail),
// this decoy is exactly what it would capture instead of `aes`'s net.
let bind = "\
module aes_bind;
logic entropy_masking_req;
bind aes aes_reseed_if u_aes_reseed_if (
.entropy_masking_req(entropy_masking_req)
);
endmodule
";
let (after, warnings) =
rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
assert_eq!(
after,
"\
module aes_bind;
logic entropy_masking_req;
bind aes aes_reseed_if u_aes_reseed_if (
.entropy_masking_req(masking_req)
);
endmodule
",
"the connection is `aes`'s net, never `aes_bind`'s own decoy of the same name, \
which must still read `entropy_masking_req` after the rename"
);
assert!(warnings.is_empty(), "nothing was left unaccounted for: {warnings:?}");
}
#[test]
fn a_new_name_the_two_level_tails_terminal_scope_already_declares_is_refused() {
// The bare-name path's collision refusal
// (`a_new_name_the_bind_target_already_declares_is_refused`) exercises
// only `in_bind_target`. This is the same shape one link further down the
// spine — the tail rooted at the bind target and walked through
// `bind_member`/`member_at`/`descend` — so a collision at the *end* of a
// two-level tail must refuse exactly as readily, with no gap specific to
// the new code path.
let aes_prng = "\
module aes_prng_clearing (input logic clk_i);
logic seed_en;
logic reseed_en;
assign seed_en = clk_i;
endmodule : aes_prng_clearing
";
let bind = "\
module aes_bind;
bind aes aes_reseed_if u_aes_reseed_if (
.seed_en(u_aes_core.u_aes_prng_clearing.seed_en)
);
endmodule
";
let files = workspace(&[
("aes.sv", AES),
("aes_core.sv", AES_CORE),
("aes_prng_clearing.sv", aes_prng),
("aes_reseed_if.sv", RESEED_IF),
("aes_bind.sv", bind),
]);
let refusal = rename(
&files,
&path("aes_prng_clearing.sv"),
at(aes_prng, "logic", "seed_en"),
"reseed_en",
)
.expect_err("`reseed_en` already exists in the tail's terminal scope");
assert!(refusal.contains("reseed_en"), "the refusal names the collision: {refusal}");
}
#[test]
fn an_escaped_identifier_bind_target_is_still_resolved() {
// `\aes.escaped ` is one identifier (an escaped identifier ends at
// whitespace, IEEE 1800 §5.6.2), spelling a name a plain identifier
// cannot. `bind_target_path` joins `b.target`'s segments verbatim, so
// this is a one-segment path exactly like `bind aes …` — the escaping is
// the parser's problem, not the resolver's.
let aes_escaped = "\
module \\aes.escaped (input logic clk_i, output logic idle_o);
logic entropy_masking_req;
assign idle_o = entropy_masking_req;
endmodule
";
let bind = "\
module aes_bind;
bind \\aes.escaped aes_reseed_if u_aes_reseed_if (
.entropy_masking_req(entropy_masking_req)
);
endmodule
";
let files = workspace(&[
("aes.sv", aes_escaped),
("aes_reseed_if.sv", RESEED_IF),
("aes_bind.sv", bind),
]);
let edit = rename(
&files,
&path("aes.sv"),
at(aes_escaped, "logic", "entropy_masking_req"),
"masking_req",
)
.unwrap_or_else(|e| panic!("the rename was refused: {e}"));
let after = apply(bind, &edit, &path("aes_bind.sv"));
assert_eq!(
after,
"\
module aes_bind;
bind \\aes.escaped aes_reseed_if u_aes_reseed_if (
.entropy_masking_req(masking_req)
);
endmodule
",
"the escaped target's connection still resolves and is edited: {edit:?}"
);
}
#[test]
fn a_bind_with_no_connections_naming_the_renamed_signal_is_untouched() {
// An empty connection list plus a `defparam` — a shape with nothing for
// any connection-surface rung to walk. Nothing here spells the renamed
// name, so the file must come back byte for byte and warn about nothing.
let bind = "\
module aes_bind;
bind aes aes_reseed_if u_aes_reseed_if ();
defparam u_aes_reseed_if.SOME_PARAM = 1;
endmodule
";
let (after, warnings) =
rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
assert_eq!(after, bind, "no connection in this bind file spells the renamed name");
assert!(warnings.is_empty(), "nothing was left unaccounted for: {warnings:?}");
}
#[test]
fn a_bind_target_reached_through_a_generate_block_is_warned_about_never_guessed() {
// `bind tb.gen[0].u_aes …`: the middle hop is a generate block, which the
// index has no record of at all (an indexed segment "keeps only its
// name", per `bind_target_path`'s doc comment) — so the path is one the
// index cannot walk, and the contract is a warning, never a silent miss
// and never a guess at which `u_aes` is meant.
let tb = "\
module tb;
if (1) begin : gen
aes u_aes (.clk_i(1'b0), .idle_o());
end
endmodule : tb
";
let bind = "\
module aes_bind;
bind tb.gen[0].u_aes aes_reseed_if u_aes_reseed_if (
.entropy_masking_req(entropy_masking_req)
);
endmodule
";
let mut files = rtl(bind);
files.push((path("tb.sv"), tb.to_string()));
let edit =
rename(&files, &path("aes.sv"), at(AES, "logic", "entropy_masking_req"), "masking_req")
.expect("the rename over the rest of the design still succeeds");
assert_eq!(
apply(bind, &edit, &path("aes_bind.sv")),
bind,
"a path through a generate block is never guessed at: {edit:?}"
);
assert!(
edit.warnings
.iter()
.any(|w| w.contains("aes_bind.sv") && w.contains("could not be resolved")),
"the miss is said out loud rather than silently dropped: {:?}",
edit.warnings
);
}
// ----------------------------------------------------------------------
// the real tree (TODO §63.1, the three QA renames)
// ----------------------------------------------------------------------
/// §61.5's QA renames, run against a real checkout: `WidthPRDSBox` (a package
/// parameter used bare through `module aes_sbox import aes_pkg::*;`),
/// `entropy_masking_req` (the bare-name `bind` connection this lane is about)
/// and `seed_en` (the two-level tail in the same `bind` file). Each is asked
/// three ways — with no index records, with every record, and with every
/// second one — and the three must answer identically; the two `bind` ones
/// must edit `aes_bind.sv`.
///
/// `#[ignore]`d, and skipped unless `LUCISV_BIND_ROOT` names a tree (it is
/// **read** and never written). Run it with
/// `LUCISV_BIND_ROOT=$HOME/repo/opentitan tools/guard.sh -m 8 -t 1800 -- \
/// cargo test -p vlog_refactor --test rename_bind -- --ignored --nocapture`.
#[test]
#[ignore]
fn the_three_qa_renames_agree_across_reuse_modes_and_edit_the_bind_file() {
let Ok(root) = std::env::var("LUCISV_BIND_ROOT") else {
eprintln!("LUCISV_BIND_ROOT unset — skipping");
return;
};
let root = PathBuf::from(root);
if !root.is_dir() {
eprintln!("{} is not a directory — skipping", root.display());
return;
}
let mut files = Vec::new();
collect(&root, &mut files);
files.sort();
let sources: Vec<(PathBuf, String)> =
files.iter().filter_map(|p| Some((p.clone(), std::fs::read_to_string(p).ok()?))).collect();
assert!(!sources.is_empty(), "the tree holds no Verilog");
println!("{} files read from {}", sources.len(), root.display());
// (file, the text the cursor is placed after, the name, the new name,
// whether `aes_bind.sv` must be among the edited files)
let cases: [(&str, &str, &str, &str, bool); 3] = [
(
"aes_pkg.sv",
"parameter int unsigned WidthPRDSBox",
"WidthPRDSBox",
"WidthPRDSBoxX",
false,
),
("aes.sv", "entropy_clearing_req, ", "entropy_masking_req", "masking_req_x", true),
("aes_prng_clearing.sv", "logic seed_en", "seed_en", "seed_en_x", true),
];
for (file, prefix, name, new_name, bind_edited) in cases {
let Some((path, text)) =
sources.iter().find(|(p, _)| p.file_name().is_some_and(|n| n == file))
else {
eprintln!("{file} not in this tree — skipping that case");
continue;
};
let offset = at(text, prefix, name);
let mut plain = RenameTrace::default();
let none = rename_traced(&sources, path, offset, new_name, &mut plain);
let all = Records::of(&sources, false);
let mut every = RenameTrace::default();
let full = rename_traced_with(&sources, path, offset, new_name, &all, &mut every);
let half = Records::of(&sources, true);
let mut mixed = RenameTrace::default();
let some = rename_traced_with(&sources, path, offset, new_name, &half, &mut mixed);
let shape = |r: &Result<vlog_refactor::RefactorEdit, String>| match r {
Ok(edit) => Ok((edit.edits.clone(), edit.warnings.clone())),
Err(e) => Err(e.clone()),
};
assert_eq!(shape(&none), shape(&full), "{name}: every record changed the answer");
assert_eq!(shape(&none), shape(&some), "{name}: half the records changed the answer");
let edit = none.unwrap_or_else(|e| panic!("{name} was refused: {e}"));
let touched: Vec<String> = edit
.edits
.iter()
.filter_map(|(p, _)| p.file_name().map(|n| n.to_string_lossy().into_owned()))
.collect();
println!(
"{name} -> {new_name}: {} files, {} edits, {} warnings; parses {} / {} / {}",
edit.edits.len(),
edit.edits.iter().map(|(_, e)| e.len()).sum::<usize>(),
edit.warnings.len(),
plain.parses,
every.parses,
mixed.parses
);
for (p, edits) in &edit.edits {
println!(" {} x{}", p.display(), edits.len());
}
for w in &edit.warnings {
println!(" warn: {w}");
}
assert_eq!(
touched.iter().any(|n| n == "aes_bind.sv"),
bind_edited,
"{name}: aes_bind.sv among {touched:?}"
);
}
}
fn collect(dir: &Path, out: &mut Vec<PathBuf>) {
let Ok(entries) = std::fs::read_dir(dir) else { return };
for entry in entries.flatten() {
let path = entry.path();
if path.is_dir() {
collect(&path, out);
} else if matches!(path.extension().and_then(|e| e.to_str()), Some("sv" | "svh")) {
out.push(path);
}
}
}
/// Every source's index record, or every second one — the mixture a real
/// rename gets from a partly warm store.
struct Records {
known: Vec<(PathBuf, String, vlog_semantic::FileFacts)>,
}
impl Records {
fn of(sources: &[(PathBuf, String)], half: bool) -> Records {
let known = sources
.iter()
.enumerate()
.filter(|(i, _)| !half || i % 2 == 0)
.map(|(_, (path, text))| {
(path.clone(), text.clone(), vlog_semantic::FileFacts::of(path.clone(), text))
})
.collect();
Records { known }
}
}
impl vlog_refactor::KnownFacts for Records {
fn facts_for(&self, path: &Path, text: &str) -> Option<vlog_semantic::FileFacts> {
self.known
.iter()
.find(|(held, bytes, _)| held == path && bytes == text)
.map(|(_, _, facts)| facts.clone())
}
}
+35 -5
View File
@@ -333,14 +333,18 @@ impl<'a> Binder<'a> {
/// `bind prim_fifo_sync …` names the declaration a `go to definition`
/// should jump to. A hierarchical *instance* path (`top.u_dut.u_core`,
/// `top.gen[0].u_core`) names a place in an elaborated hierarchy that no
/// single file knows, so it records nothing at all: the alternative is a
/// guess, and a guess here is a wrong answer.
/// single file knows, so it records **no reference of its own**: the
/// alternative is a guess, and a guess here is a wrong answer. It is
/// still the scope the connections elaborate in, and
/// [`bind_target_path`] is that scope written the way the index reads a
/// path.
/// * the **instantiated module**, exactly as before, so a bind still makes
/// the bound module a dependency of this file.
/// * each connection: the `.port` half against the module being bound in
/// (an ordinary [`Target::Port`], the same one a plain instantiation
/// uses), and the expression half in the target's scope
/// ([`Target::BindScope`]).
/// uses), and the expression half in the target's scope — a bare name
/// through [`Target::BindScope`], a hierarchical path through
/// [`Target::BindMember`].
///
/// The instance name is still **not** declared here: it belongs to the
/// target scope, and declaring it in this one would put a name in a scope
@@ -357,7 +361,7 @@ impl<'a> Binder<'a> {
let i = &b.inst;
let ns = self.exact_or_empty(i.module_span, &i.module);
self.use_name(scope, &i.module, ns, Target::Module);
let previous = std::mem::replace(&mut self.bind_target, head.map(|h| h.name.clone()));
let previous = std::mem::replace(&mut self.bind_target, bind_target_path(b));
for c in i.params.iter().flatten().filter_map(ListElem::ok) {
self.bind_connection(c, &i.module, scope);
}
@@ -588,3 +592,29 @@ impl<'a> Binder<'a> {
None
}
}
/// The scope a `bind`'s connection expressions are elaborated in, spelled the
/// way the workspace's member tables read a path: one `::` per segment.
///
/// A lone segment is the target module or interface, and `aes` is the unit the
/// index answers `aes::entropy_masking_req` in. A hierarchical path is the
/// same question one hop at a time — `tb.u_aes` is `tb::u_aes`, which
/// `fold_path` walks by asking `tb` for the declared type of its instance
/// `u_aes` — so the path resolves whenever the index holds every hop and is
/// *said out loud* when it does not, instead of silently resolving the
/// connection in the scope the directive is written in, which is not the
/// scope it elaborates in.
///
/// An indexed segment (`gen[0]`) keeps only its name: the index has no record
/// of a generate block, so such a path answers nothing either way, and a
/// spelling the user can recognize is what the warning needs.
fn bind_target_path(b: &BindDirective) -> Option<String> {
let mut out = String::new();
for seg in &b.target {
if !out.is_empty() {
out.push_str("::");
}
out.push_str(&seg.name);
}
(!out.is_empty()).then_some(out)
}
+14
View File
@@ -103,6 +103,14 @@ pub(crate) enum Target {
/// answers first and the scope the directive is written in second — the
/// [`Target::InlineConstraint`] shape, with the same refusal to guess.
BindScope { target: String },
/// A **hierarchical path** written in the expression half of a `bind`
/// directive's connection: `bind aes chk u (.s(u_core.u_prng.seed_en));`.
/// The spine is rooted in the target's scope exactly as a bare name is, so
/// `head` is looked up there (and not in the scope the directive is
/// written in, which is a bind module declaring nothing at all) and each
/// of `mids` walks one link further — the [`Target::MemberOf`] walk, with
/// its start moved from the writing scope to the target's.
BindMember { target: String, head: String, mids: Vec<String> },
/// The `x` of `this.x`: the enclosing class's scope only.
ThisMember,
/// The `x` of `super.x`: always the base class's business.
@@ -312,6 +320,12 @@ impl<'a> Binder<'a> {
// else. A name written with a head of its own already carries the
// right target and is left alone.
(None, Some(scope), Target::Lexical) => Target::BindScope { target: scope.clone() },
// And the same rule for a hierarchical path in one: its head is a
// name in the target's scope, so the whole spine is rooted there
// rather than in the scope the directive is written in.
(None, Some(scope), Target::MemberOf { head, mids }) => {
Target::BindMember { target: scope.clone(), head: head.clone(), mids: mids.clone() }
}
_ => target,
};
self.pending.push(Pending { name: name.to_string(), name_span, scope, target });
+12 -1
View File
@@ -145,7 +145,18 @@ use crate::workspace::{
/// u_x.sig;`) as though the tail resolved to nothing — for exactly the files
/// it had cached, which is the half-right answer every one of these bumps
/// exists to prevent. See `docs/features/hierarchical-tail/README.md`.
pub const FACTS_FORMAT: u32 = 19;
/// 19 → 20 (2026-09-11, rename-bind-occurrences): no new field, but a
/// **different answer in the same fields** — a `bind`'s connection expression
/// is now recorded against the *hierarchical* surface of the target scope and
/// under the `target::name` path spelling, where it used to carry the
/// connection surface and a path with no name on it. So a module's internal
/// net named in `bind aes chk u (.req(entropy_masking_req))` is a reference
/// where it resolved to nothing before. A store written by a 0.53.0 build
/// would answer definition, find-references and the rename of such a name as
/// though the `bind` file did not mention it — for exactly the files it had
/// cached, which is the half-right answer every one of these bumps exists to
/// prevent. See `docs/features/rename-bind-occurrences/README.md`.
pub const FACTS_FORMAT: u32 = 20;
impl FileFacts {
/// These facts as one line's worth of fields, tab-separated.
+106 -29
View File
@@ -75,6 +75,9 @@ pub(crate) fn resolve(scopes: &[Scope], symbols: &[Symbol], p: &Pending) -> Opti
}
return found;
}
Target::BindMember { target, head, mids } => {
return bind_member(scopes, symbols, target, head, mids, &p.name)
}
Target::ThisMember => this_member(scopes, symbols, p.scope, &p.name),
Target::SuperMember => super_member(scopes, p.scope),
})
@@ -87,9 +90,18 @@ pub(crate) fn resolve(scopes: &[Scope], symbols: &[Symbol], p: &Pending) -> Opti
/// `None`, never `NotFound`: a module opens a scope per generate block, so a
/// connection may legitimately name something the module's *own* scope does
/// not hold, and "absent from this scope" is not "absent". The target
/// declared somewhere else is the very question [`Target::Port`] asks of the
/// workspace — "is `name` a member of this module?" — in the same
/// one-segment path spelling `follow_one` reads.
/// declared somewhere else is the same question a hierarchical tail asks of
/// the workspace — "is `name` a member of this module?" — in the
/// `unit::name` path spelling `follow_one` reads.
///
/// The surface is the **hierarchical** one (IEEE 1800 §23.6): a bind's
/// connection may name any of the target's declarations, its internal nets
/// and variables included, which is exactly what `bind aes chk u
/// (.req(entropy_masking_req))` does and what the connection surface — ports
/// and parameters only — cannot answer. Asking the narrow surface is what
/// made such a connection resolve to nothing, and a `name`-less path is what
/// kept the miss silent: the warning scan names the unit a candidate was
/// searched in by splitting the path at its `::`.
fn in_bind_target(
scopes: &[Scope],
symbols: &[Symbol],
@@ -99,12 +111,45 @@ fn in_bind_target(
match owning_scope(scopes, symbols, target, is_instantiable) {
Some(scope) => scopes.get(scope.0 as usize)?.lookup_local(name).map(Resolution::Resolved),
None => Some(Resolution::ExternalCandidate {
paths: vec![target.to_string()],
surface: Surface::Connection,
paths: vec![format!("{target}::{name}")],
surface: Surface::Hierarchical,
}),
}
}
/// A hierarchical path written in a `bind`'s connection, rooted where the
/// directive elaborates rather than where it is written.
///
/// `bind aes chk u (.s(u_aes_core.u_aes_prng_clearing.seed_en))` is
/// [`member_of`]'s walk with one substitution: the head starts in `aes`'s
/// scope instead of the writing scope's lexical chain. So `head` is simply
/// one more link of the spine, and the target is where the spine begins — its
/// own scope when this file declares the target, and otherwise the unit the
/// workspace answers hierarchical members of.
///
/// `None` — no reference at all — wherever [`member_of`] would record none:
/// a link this file declares as something with no members to search, or a
/// name genuinely absent from a scope this file holds whole.
fn bind_member(
scopes: &[Scope],
symbols: &[Symbol],
target: &str,
head: &str,
mids: &[String],
name: &str,
) -> Option<Resolution> {
let mut here = match owning_scope(scopes, symbols, target, is_instantiable) {
Some(scope) => MemberSite::Scope(scope),
None => MemberSite::Unit { path: target.to_string(), surface: Surface::Hierarchical },
};
for link in std::iter::once(head).chain(mids.iter().map(String::as_str)) {
here = descend(scopes, symbols, here, link)?;
}
// Never the `InheritedCandidate` shape: that is a class's business, and
// the head of this spine is a place in the design hierarchy.
member_at(scopes, symbols, here, name, false)
}
/// A name looked up **only** in the scope it is written in, never outward: a
/// modport's port list and a clocking block's signal list, both of which name
/// members of the interface (or module) they are written in and nothing else.
@@ -177,16 +222,34 @@ fn member_of(
mids: &[String],
name: &str,
) -> Option<Resolution> {
match member_site(scopes, symbols, from, head, mids)? {
let site = member_site(scopes, symbols, from, head, mids)?;
member_at(scopes, symbols, site, name, mids.is_empty())
}
/// The **tail** of a spine: `name` looked up in the site the links before it
/// landed on.
///
/// `direct` says whether this is a plain `head.member` — the one shape that
/// may report an inherited candidate, because for a longer chain the base is
/// the owner of an earlier link, not of this name, and claiming it here would
/// send the overlay's inheritance chase after the wrong class.
///
/// Shared with [`bind_member`], which walks the same links from a different
/// start: two spellings of this lookup would eventually answer one name two
/// ways.
fn member_at(
scopes: &[Scope],
symbols: &[Symbol],
site: MemberSite,
name: &str,
direct: bool,
) -> Option<Resolution> {
match site {
MemberSite::Scope(scope) => match member_in_chain(scopes, symbols, scope, name) {
Ok(id) => Some(Resolution::Resolved(id)),
// The chain leaves this file: the base, plus the path the
// workspace's member table answers it by. Only a **direct**
// `head.member` reports the base — for a longer chain the base is
// the owner of an earlier link, not of this name, and claiming it
// here would send the overlay's inheritance chase after the wrong
// class.
Err(Some(base)) if mids.is_empty() => Some(Resolution::InheritedCandidate {
// workspace's member table answers it by.
Err(Some(base)) if direct => Some(Resolution::InheritedCandidate {
paths: vec![format!("{}::{name}", last_segment(&base))],
base,
}),
@@ -234,27 +297,41 @@ pub(crate) fn member_site(
) -> Option<MemberSite> {
let mut here = head_site(scopes, symbols, from, head)?;
for mid in mids {
here = match here {
MemberSite::Scope(scope) => match member_in_chain(scopes, symbols, scope, mid) {
Ok(id) => link_type(scopes, symbols, id)?,
// The chain leaves this file at a base class: everything from
// here on is one composed path for the workspace to walk.
Err(Some(base)) => MemberSite::Unit {
path: format!("{}::{mid}", last_segment(&base)),
surface: Surface::Connection,
},
Err(None) => return None,
},
// Already outside this file — each further name is one more
// segment of the path `follow_one` walks member by member.
MemberSite::Unit { path, surface } => {
MemberSite::Unit { path: format!("{path}::{mid}"), surface }
}
};
here = descend(scopes, symbols, here, mid)?;
}
Some(here)
}
/// One more link of a spine: where `here`'s member `link` puts the cursor.
///
/// Shared with [`bind_member`] for the same reason [`member_at`] is — a
/// second spelling of the hop would eventually walk somewhere the first does
/// not.
fn descend(
scopes: &[Scope],
symbols: &[Symbol],
here: MemberSite,
link: &str,
) -> Option<MemberSite> {
match here {
MemberSite::Scope(scope) => match member_in_chain(scopes, symbols, scope, link) {
Ok(id) => link_type(scopes, symbols, id),
// The chain leaves this file at a base class: everything from
// here on is one composed path for the workspace to walk.
Err(Some(base)) => Some(MemberSite::Unit {
path: format!("{}::{link}", last_segment(&base)),
surface: Surface::Connection,
}),
Err(None) => None,
},
// Already outside this file — each further name is one more segment
// of the path `follow_one` walks member by member.
MemberSite::Unit { path, surface } => {
Some(MemberSite::Unit { path: format!("{path}::{link}"), surface })
}
}
}
/// Where the *first* segment of a spine puts the cursor.
fn head_site(
scopes: &[Scope],
+16 -7
View File
@@ -347,13 +347,22 @@ fn facts_from_analysis(
}
// The **connection** surface only. A `Local` posting exists so that a
// declaration another file can point at carries its own file's uses
// without that file being re-read, and every consumer of the postings
// that matters here — the rename, which re-analyses the declaring file
// anyway — already has them. Posting a module's every internal net use
// would multiply the reference table by the size of an RTL body for an
// answer nothing reads; the hierarchical surface is what a *cross-file*
// tail resolves through, and that half is an `External` fact below.
// See `docs/features/hierarchical-tail/README.md`, "what did not widen".
// without that file being re-read. Posting a module's every internal net
// use would multiply the reference table by the size of an RTL body; the
// hierarchical surface is what a *cross-file* tail resolves through, and
// that half is an `External` fact below.
//
// Two consumers read the postings for a hierarchical-only declaration,
// and each supplies the missing local half by re-analysing that one file:
// a rename (`vlog_refactor`), which re-analyses the declaring file
// anyway, and — since §64.1 — `lucisv_server`'s
// `nav::declaring_file_uses`, which parses exactly the declaring file
// when it is closed and a `references` request arrived from a cross-file
// use. So the narrow table costs one file's parse on one request shape,
// paid by the caller that needs it, instead of a reference table sized by
// every RTL body in the workspace. See
// `docs/features/hierarchical-tail/README.md`, "what did not widen", and
// `docs/features/references-hierarchical-surface/README.md`.
// Which kind lands on which surface is `hierarchy::surface_of`, the one
// rule this filter and the member tables both read (§49's QA asked for
// the pointer).
+20 -4
View File
@@ -128,10 +128,26 @@ The `propagate-ports` engine reads `member`/`members_of` and is untouched.
- **Reference postings.** `facts_from_analysis` records a `Local` posting only
for a use whose declaration is on the **connection** surface. Posting a
module's every internal-net use would multiply the reference table by the
size of an RTL body for an answer nothing reads: the only consumer is a
rename, which re-analyses the declaring file anyway. The *cross-file* half —
the tail in the other file — is an `External` fact, and that is what makes
the rename work.
size of an RTL body. The *cross-file* half — the tail in the other file —
is an `External` fact, and that is what makes the rename work.
**Amended 2026-09-12 (§64.1).** This bullet used to end "for an answer
nothing reads: the only consumer is a rename, which re-analyses the
declaring file anyway". There are two consumers now, and the sentence is
true again only with the second one named: `textDocument/references` reads
the postings too, and since §64.1 it answers for a hierarchical-only
declaration. It is served the way the rename is —
`lucisv_server`'s `nav::declaring_file_uses` parses **exactly the declaring
file, exactly once**, and only when that file has no open buffer and the
request came in from a cross-file use; an open buffer's own uses come from
the live overlay as they always did. Measured on opentitan: `references`
from `u_entropy_src_main_sm.state_q` with `entropy_src_main_sm.sv` closed
costs 1.0–1.5 ms against the 0.1–0.2 ms of the incomplete answer it
replaces, and every connection-surface row of the `nav` harness is
unchanged in both result count and time. So the decision stands, with its
cost now written down: one file's parse on one request shape, instead of a
reference table sized by every RTL body in the workspace. See
`docs/features/references-hierarchical-surface/README.md`.
- **`workspace/symbol`.** An internal net is still not a workspace symbol: the
request answers what a user can name from outside, and a design with 20 000
modules has hundreds of thousands of internal signals.
@@ -142,6 +142,17 @@ The character cap counts `char`s and cuts on a boundary.
## Work log
### 2026-09-12 — dev (§64.1: `spells_exactly` is now `pub(crate)`)
Visibility only, no behaviour change here. `nav.rs` needed the same
agreement check for a closed file's *span* that this feature applies to a
closed file's *snippet* — after §64.1 an index-time `references` span can be
rendered against bytes that moved — and QA's lesson above (a fixed-length
span still spelling the old name as a **prefix** of a longer identifier) is
exactly the case a second copy of the check would have got wrong. So
`hover::spells_exactly` is shared rather than duplicated; see
`docs/features/references-hierarchical-surface/README.md`.
### 2026-08-27 — dev
- Read the brief, `hover.rs`, `nav.rs`, `state.rs` and `convert.rs`. Confirmed
@@ -0,0 +1,654 @@
# perf-first-after-edit
TODO §63.2 — N1 of the 0.52.0 review (`docs/performance_052_review.md`,
item 3 and next action 3).
## Goal
The first request after a one-character edit in a 40 267-line generated
file cost **113.6 ms** on 0.52.0, against 0.23 ms for the same request
repeated on an unchanged buffer. The lint snapshot (review round §R1a)
cannot help a fresh revision: what remains is the debounced `Document`
rebuild `answer_request` performs before any handler runs, the
diagnostics publish that lints the new revision, and the menu's own
stages. This round splits that flush into the stages a reader can act on,
then makes the **fresh-revision work itself cheaper** — no cache of
anything across revisions — with the AST, the diagnostics and the menu
byte-identical. Target: ≥ 15 % off the cell, stretch < 95 ms, the
unchanged-repeat cell and the other `offeredit`/`offerkinds` rows within
noise, peak RSS not up.
## Assumptions
- The pinmux cell is the worst realistic shape, not the typical one: a
1 237 143-byte generated register file, 193 816 tokens, one buffer
open, workspace scope, 3 975 files indexed. Everything here is measured
on it; a 400-line hand-written file pays the same work in microseconds.
- `Document::new` is a pure function of (text, index): the same text
against the same index must give the same tokens, tree, defines,
semantics, external resolutions and line index. Every change in this
round is checked against that, file by file, over the corpus and
opentitan (see Parity).
- `vlog_parser::tokenize` is all-or-nothing and its output is a value,
not a rendering: two builds agree on token kind, text, line, column,
span, `blank_before` and every attached comment, or they differ.
- The measurement machine is shared with nothing else while a phase runs
(`tools/perf/README.md`'s rules), and every number below is a median.
## Handshakes
- **`lucisv_server ──▶ vlog_parser`** — unamended. `tokenize`,
`parse_tolerant` and `parse_source_tolerant` keep their signatures;
`Document::new` calls them exactly as before. No public `vlog_parser`
item changed name, type or behaviour, so nothing this lane did is a
contract change for the formatter, linter, refactor or CLI either.
**Nothing is owed to the lead here.**
- **`verbose-timing ◀──▶ tools/perf`** — *amended, and this needs a
`docs/topo.md` line the lead owns.* The `timing: codeaction …` line
(`crate::lint_trace`) grows a **third top-level group**, `rebuild{…}`,
beside `flush{…}` and `action{…}`: `lex`, `parse`, `defines`,
`analyze`, `external`, `lines`, `publish` (ms each) and `documents`
(how many `Document`s the flush built). Groups stay siblings — never
nested — because `tools/perf/phases_p2.py`'s `GROUP` regex flattens one
level only; `phases_r1.py` therefore picks the new fields up with no
change, as `trace_rebuild_*` row fields. Pinned by
`lint_trace::tests::the_rebuild_group_names_every_stage_beside_the_other_two`.
- **`docs/perf/README.md`** — not this lane's file. The entry it wants is
in "For `docs/perf/README.md`" below, for the lead to paste.
### Requested `docs/topo.md` amendments (the lead's file)
1. The `verbose-timing ◀──▶ …` handshake row (§2.7): add that the
`timing: codeaction` line carries a third group, `rebuild{…}`, whose
fields are the flush's `Document`-rebuild stages, and that the three
groups are siblings by contract (the harness flattens one level).
2. The `lucisv_server/src/state.rs` file row: `Document::new`'s six
derivations are individually traced through `crate::lint_trace`, so a
stage added to or removed from that constructor wants a `Rebuild`
variant beside it.
## Status / TODO
- [x] the flush split in `lint_trace` (`Rebuild`, `Rebuilt`, `rebuild()`,
`saw_document()`), the `rebuild{…}` group on the trace line, and
the 0.53.0 numbers taken **before** any behaviour changed
- [x] change 1 — the lexer's two phases fused (no `Vec<RawTok>`)
- [x] change 2 — `Parser::skip`, the non-cloning `bump` for the 217 call
sites that threw the token away
- [x] change 3 — the operator table's first-byte test
- [x] parity: token stream + parse diagnostics + whole AST + symbol table
digested per file over 4 807 files (corpus + opentitan), 0 differ;
`format --stdout` byte-identical over corpus (860) and over
opentitan (3 947); diagnostics and the all-family menu on the
pinmux buffer identical before and after
- [x] paired `offeredit` / `offerkinds` / `flush` / `diagnostics` /
`rss` against a 0.53.0 server built from 1b8723c, order alternated
— **−19.2 % on the cell, the ≥ 15 % gate met and the < 95 ms
stretch met at 88.3 ms**
- [x] QA
## Work log
### 2026-09-12 — measure first: the flush split
`crate::lint_trace` already split a traced request into
flush / config / build / lint / fence / serialize. The flush was one
number (`flush{wall=…}`), so "the dirty-buffer stage dominates" was as
far as the 0.52.0 review could attribute the cell. Added:
- `Rebuild` (7 stages: `lex`, `parse`, `defines`, `analyze`, `external`,
`lines`, `publish`), `Rebuilt` (their milliseconds plus a `documents`
count) and `rebuild(stage, work)` / `saw_document()` — the same
thread-local, one-`Cell`-read-when-off discipline the module documents,
and *not* routed through `IN_FLUSH`: a rebuild belongs to the rebuild
whichever half of the request runs it.
- `crates/lucisv_server/src/state/mod.rs:119` — `Document::new`'s six
derivations each wrapped at the call.
- `crates/lucisv_server/src/server/diagnostics.rs:57` — the publish
inside `flush_dirty` wrapped as the seventh, so the flush group's
`config`/`build`/`lint`/`fence` are readable as *inside* it.
- `Trace::line()` prints `rebuild{…}` as a **sibling** of `flush{…}` and
`action{…}`; `Trace::is_empty` counts it, so a request that only
rebuilt still logs a line.
`tools/perf` needed no code change: `phases_r1.py` parses the whole line
through `phases_p2.parse_trace`, which flattens any top-level `name{…}`
group, so the seven stages arrive as `trace_rebuild_*` fields on every
`actionprofile` row. `tools/perf/README.md`'s `actionprofile` row now
says so.
**The 0.53.0 numbers** (HEAD 1b8723c plus this instrumentation and
nothing else; `actionprofile`, pinmux-comment, "first codeAction after a
didChange", three tries; evidence
`~/.cache/lucisv-perf/63-2/split-0530.jsonl`):
| | ms |
|---|---:|
| wire latency | 122.6 / 123.0 / 101.4 |
| **flush wall** | **100.0** |
| ├ `rebuild lex` | **29.1** |
| ├ `rebuild parse` (the token clone is inside it) | **25.6** |
| ├ `rebuild publish` | 22.2 — of which `flush lint` 22.0 |
| ├ `rebuild analyze` | 10.1 |
| ├ `rebuild external` | 4.8 |
| ├ `rebuild lines` / `defines` | 0.6 / 0.5 |
| └ unattributed (dropping the previous revision) | ~7 |
| handler's own stages (`action{…}`) | 0.23 — `snapshot=hit` |
(This is the single run taken before anything changed. The same cell was
re-taken **paired and order-alternated** against the finished candidate
at the end of the round — 110.2 / 110.7 ms, flush wall 102.7 / 107.4 —
see "The paired result"; the stage shares agree, the absolute wire time
of this first run sat on a busier machine.)
Two of the review's candidates were answered by the split before
anything was built:
- **A second lint of the same revision: there is none.** `action` reads
`snapshot=hit` and `lint=0.00ms` on every try — the publish's pass is
the menu's pass, which is what review round §R1a bought.
- **A second analysis: there is none either.** `lint::context` already
lends `doc.semantics` to the linter (`with_semantics`), so the lint
pass does not re-`analyze` the tree.
So the cell is the rebuild, and the rebuild is **lex + parse** (54.7 ms
of the 100).
### 2026-09-12 — where the rebuild's milliseconds are
A standalone harness over exactly `Document::new`'s calls
(`scratchpad/63-2/micro`, 15 iterations, median; built against the
reference tree and against the working tree, same compiler, same file)
separates the clone from the parse, which the in-server stage cannot:
| | 0.53.0 (1b8723c) | after all three changes |
|---|---:|---:|
| `tokenize` | 27.79 | **11.59** |
| `tokens.clone()` | 4.44 | 3.92 |
| `parse_tolerant` | 17.47 | **16.33** |
| `collect_defines` | 0.45 | 0.42 |
| `analyze` | 9.79 | 9.40 |
| `LineIndex::new` | 0.56 | 0.59 |
| dropping the products | 6.27 | 6.40 |
| **total** | **66.8** | **48.6** |
193 816 tokens, `size_of::<Token>()` 120 bytes.
### 2026-09-12 — change 1: the lexer's two phases, fused
`crates/vlog_parser/src/lexer.rs` — `tokenize` lexed the whole file into
a `Vec<RawTok>` and then walked it to attach comments. Attachment reads
only the raw token in hand and the token last pushed, so the two loops
fuse into one without touching the result: `attach` / `attach_trailing`
are the same code as the second loop, called per raw token. The
intermediate vector for this file was 193 816 × 56 bytes of allocation,
growth copying and teardown. `tokens` is also given a capacity guess
(`estimated_tokens`, six bytes a token, capped at 2²⁰) — the growth
doubling reached 262 144 slots for this file anyway, so the guess costs
no memory it was not already taking.
The `blank_before` `if` whose two arms were the same expression is now
one expression, and `tokens.last_mut().unwrap()` is a `let … else`
(library paths take no `unwrap`).
**Measured** (same harness): `tokenize` 27.8 → **24.7 ms**.
*File size, for the lead:* `lexer.rs` is one of the two files the
2026-09-07 measurement left over 600 production lines (763). This round
leaves it at **770** — the fusion replaced the second loop with
`attach` / `attach_trailing` rather than adding a responsibility, and the
+7 is the doc comments on them. Splitting the lexer's two halves into
two modules would undo exactly the "one sentence" the fusion restored
(*it turns source text into the token stream, comments attached*), so the
lines were left where they are; the ruling is the lead's.
### 2026-09-12 — change 2: `Parser::skip`
`crates/vlog_parser/src/parser/cursor.rs` — `bump()` clones the token
(its `text` is a `String`, so an allocation) and hands it back; **217 of
its ~296 call sites threw the value away on the same line**. `skip()` is
`bump()` for those callers: same comment plumbing (the leading bucket and
the trailing comment are cloned into the pending lists, exactly as
`bump()` moved them out of its own copy), same cursor step, same
`self.tokens` left untouched — so a speculative parse's rewind finds the
stream exactly as it would have. The 217 sites were rewritten
mechanically; `eat_sym` / `eat_kw` are two of them.
**Measured**: `parse_tolerant` 17.5 → **16.0 ms**. (Modest: the 181
`expect_sym`/`expect_kw` calls whose token is also discarded still clone.
Left alone deliberately — a second pair of entry points for ~1 ms is not
worth the API.)
### 2026-09-12 — change 3: the operator table's first-byte test
`crates/vlog_parser/src/lexer.rs` — every token that was not a comment,
directive, attribute, string, escaped/system identifier, number or
identifier fell into `for op in OPERATORS { if self.starts_with(op) … }`:
**44 slice comparisons for every `;`, `(`, `)`, `,`, `.`, `[`, `]`** in
the file, which in a generated register file is most of the tokens. One
byte compare in front of the slice compare rejects every operator that
cannot start here. Longest-first order is untouched, `starts_with` still
decides, so the token stream cannot move.
**Measured**: `tokenize` 24.7 → **11.6 ms** — the single largest win of
the round, and a third of the whole cell.
### 2026-09-12 — one flaky test of my own, found and fixed
`lint_trace::tests::a_trace_holding_only_a_rebuild_is_not_empty` failed
once in six runs of `cargo test -p lucisv_server`: it armed a trace, ran
an **empty** closure under `rebuild(Rebuild::Analyze, …)` and asserted
the trace was not empty — but a closure that does nothing can measure
0.00 ms, which leaves the group equal to `Rebuilt::default()`. The
assertion was wrong, not the code: what says a rebuild happened is
`saw_document()`, which `Document::new` always calls, not a duration.
The test now calls it, and the reason is written above the test (this is
also why no test here asserts a millisecond — timing lives in the
harness). Six further runs of the module and two full workspace runs
green. The change is inside `#[cfg(test)]`, so the release binary the
paired numbers were taken with is the shipped code unchanged.
### Not taken, and why
- **The token-stream clone into `parse_tolerant`** (3.9 ms). The parser
*mutates* its token vector — `take_meta`, `take_dangling`, `take_gap`,
`take_leading_here`, `take_trailing_here` move comments out of it — so
a vector handed over and taken back is a comment-stripped vector, and
`Document::tokens` is read for comments by semantic tokens
(`tokens.rs:181`) and by the linter (`vlog_linter/src/context.rs:534`).
Handing it over would drop comments from highlighting and from the
rules that read them. Making the parser stop mutating the stream is a
real refactor of the comment plumbing for 3.9 ms; filed, not done.
- **`analyze` (9.4 ms) and `resolve_external` (5.5 ms)**: not opened.
The file ownership allows `vlog_semantic` "only for a measured stage",
and after the three changes above the gate is met with margin; a
fourth change would have bought risk, not a verdict.
- **Dropping the previous revision's products (6.3 ms)** happens inside
`set_document` on the request path. Moving it off the path means a
thread or a deferred queue in a single-threaded server; not for this
round.
## The paired result
Two binaries: the reference is `cargo build --release` of **1b8723c**
(0.53.0 plus §63.1) in a `git archive` scratch tree, the candidate is the
working tree. Same compiler, same harness, same opentitan at
`0098135…` with its three pre-existing modified files. Each phase run
**four times — ref, candidate, candidate, ref** — so an order effect or
a machine drift shows as a spread between a version's own two rounds.
One warm index store per binary. Three tries a row, median of the tries,
both rounds quoted. Evidence: `~/.cache/lucisv-perf/63-2/paired.jsonl`
(`paired.sh` is the runner), load 4.8 → 4.1 across the run.
| phase · row | 0.53.0 (a / b) | candidate (a / b) | verdict |
|---|---:|---:|---|
| **`offeredit` pinmux-comment, first offer after didChange** | **110.95 / 107.54** | **88.31 / 88.36** | **−19.2 %** — gate met, stretch (< 95) met |
| `offeredit` pinmux-comment, repeated offer, unchanged buffer | 0.27 / 0.32 | 0.22 / 0.19 | unchanged (noise) |
| `offeredit` aes-reg-instance, first offer after didChange | 5.23 / 8.10 | 6.54 / 6.24 | unchanged (inside the version's own spread) |
| `offeredit` aes-reg-instance, repeated offer | 3.39 / 4.22 | 3.48 / 3.18 | unchanged |
| `offeredit` tb-comment, first offer after didChange | 1.18 / 1.57 | 2.05 / 0.89 | unchanged |
| `offeredit` tb-comment, repeated offer | 0.22 / 0.28 | 0.32 / 0.23 | unchanged |
| `flush` didChange flush (foldingRange barrier) | 1.33 / 1.51 | 0.85 / 1.38 | unchanged |
| `diagnostics` publish after didChange (≈150 ms debounce) | 162.16 / 157.20 | 160.88 / 159.66 | unchanged |
| `offerkinds` — all 35 rows (5 cursors × 7 families) | 0.03 – 6.00 | 0.04 – 4.95 | every row inside its own version's a/b spread; the two rows above 1 ms (`aes-reg-instance` all-family 3.42/6.00 → 4.95/4.57 and `…ports` 2.99/3.73 → 2.92/2.83) do not move |
**Memory** (`rss`, three fresh processes a cell, KiB):
| cell | 0.53.0 | candidate |
|---|---:|---:|
| RSS after the workspace scan, cold cache | 505 968 / 508 048 / 505 824 · 501 200 / 501 232 / 505 312 | **478 992 / 479 584 / 480 720 · 480 848 / 479 344 / 479 488** |
| RSS after the workspace scan, warm cache | 428 480 / 429 104 / 425 312 · 427 392 / 430 720 / 427 968 | 427 872 / 428 160 / 426 928 · 427 056 / 427 888 / 427 632 |
| index store on disk | 45 468 | 45 468 |
Peak RSS is **not up**: warm is flat, and the cold scan — 3 975 files
lexed and parsed — is **~25 MiB lower**, which is the `Vec<RawTok>` the
fused lexer no longer builds.
**The flush split, paired** (`actionprofile`, pinmux-comment, first
codeAction after a didChange; the same four-run order; the trace is the
last try's, evidence `split-paired.jsonl`):
| | 0.53.0 + trace (a / b) | candidate (a / b) |
|---|---:|---:|
| wire latency, median of 3 | 110.2 / 110.7 | **89.1 / 89.1** |
| flush wall | 102.7 / 107.4 | **82.2 / 87.5** |
| ├ `lex` | 29.3 / 29.9 | **11.6 / 14.1** |
| ├ `parse` (clone inside) | 25.8 / 30.3 | 23.3 / 26.3 |
| ├ `publish` (of which `lint`) | 23.6 (23.4) / 23.2 (23.0) | 23.9 (23.7) / 23.3 (23.1) |
| ├ `analyze` | 10.7 / 11.3 | 10.4 / 10.7 |
| ├ `external` | 4.8 / 4.7 | 4.7 / 4.7 |
| └ `lines` / `defines` | 0.6 / 0.4 | 0.7 / 0.4 |
| handler (`action`) | `snapshot=hit` | `snapshot=hit` |
## Parity
Nothing below is an assertion about intent; each is a comparison of two
builds' outputs over real files.
1. **The token stream, the parse diagnostics, the whole AST and the
symbol table, file by file.** A digest per file over every token's
kind, text, line, column, span start/end, `blank_before` and every
leading/trailing comment, then over `{:?}` of the diagnostics, of the
`SourceFile` and of `analyze`'s symbols. Run with the same tool built
against the reference tree and against the working tree, over
**4 807 files** (860 corpus + 3 947 opentitan): **0 lines differ**
(`digest-ref.txt` / `digest-new.txt`, `digest.diff` empty).
2. **`format --stdout`, corpus.** 860 files, sha256 per file, reference
binary vs candidate: **0 differ** (`fmt-ref.txt` / `fmt-new.txt`).
3. **`format --stdout`, opentitan.** The whole tree in one run, both
binaries: the same sha256 over the concatenated output
(`2c363ec2eb8395…`) and byte-identical stderr.
4. **Diagnostics and the menu, on the buffer this round is about.**
`parity_menu.py` opens each of the three cursors' files, asks for the
all-family menu and each of the seven `context.only` families —
recording every action's **title, kind and edit payload** — collects
the published diagnostics, then does it twice more after a
`didChange`: once with a harmless comment appended and once with a
revision that deliberately introduces lint findings (a tab, a 140-
character line, a trailing space), so the comparison is not two empty
lists. 87 lines including 12 diagnostics and the fix-all edits:
**identical** (`parity-ref.txt` / `parity-new.txt`).
5. **Suites.** `cargo test --workspace --locked` through the guard:
reference **4 403 passed, 0 failed, 46 ignored**; candidate **4 406
passed, 0 failed, 46 ignored** — +3, the new `lint_trace` tests. The
parser snapshot and idempotency suites are inside that run
(`vlog_parser` 380 + 22 span tests, `vlog_formatter` 226 + fixtures),
green on their own too. `cargo fmt --all -- --check` and
`cargo clippy --all-targets --locked` clean. No guard kill anywhere in
the round.
6. **opentitan untouched.** `git -C ~/repo/opentitan status --porcelain`
before and after every phase lists exactly the three pre-existing
modified files (`hw/ip/aes/dv/tb/tb.sv`,
`hw/top_darjeeling/ip/ast/rtl/ast.sv`,
`hw/top_earlgrey/ip/ast/rtl/ast.sv`) and nothing else.
### Re-deriving it
Everything is under `~/.cache/lucisv-perf/63-2/`: both server binaries
(`server-ref-0.53.0`, `server-step1-trace` — the reference plus the
instrumentation only —, `server-step2-lexparse`), both CLIs
(`lucisv-ref`, `lucisv-new`), the reference tree (`ref-1b8723c/`), the
runners (`run.sh`, `paired.sh`, `split.sh`, `fmtgate.sh`,
`parity_menu.py`), the file lists and every `.jsonl` / `.txt` named
above, plus the stage micro-harness's sources — `micro/` (path
dependencies on the working tree) and `micro-ref/` (on `ref-1b8723c/`).
Both are plain `cargo` crates with no third-party code; `micro`'s
`main.rs` is the per-stage median table and its `bin/digest.rs` is the
per-file digest of parity check 1.
## For `docs/perf/README.md` (the lead's file)
> **2026-09-12 — the first request after an edit (TODO §63.2, N1 of the
> 0.52.0 review).** The 40 267-line pinmux cell — one-character
> `didChange`, then the all-family `codeAction` menu — **109 → 88 ms
> paired (−19.2 %)**, the unchanged-repeat cell and every other
> `offeredit`/`offerkinds`/`flush`/`diagnostics` row within noise, cold
> scan RSS ~25 MiB lower and warm RSS flat. The flush is now split in
> the `timing: codeaction` line (`rebuild{lex parse defines analyze
> external lines publish documents}`), which is what named the cost:
> **lex 29 ms and parse 26 ms of a 100 ms flush**, and *no* second lint
> and *no* second analysis of the revision (the snapshot and
> `with_semantics` already had those). Three changes, all in
> `vlog_parser`: the lexer's two phases fused (the intermediate
> `Vec<RawTok>` is gone; 27.8 → 24.7 ms), `Parser::skip` for the 217
> `bump()` sites that discarded the token (17.5 → 16.0 ms), and a
> first-byte test in front of the 44-entry operator table (24.7 →
> **11.6 ms** — the single largest win). Token stream, parse
> diagnostics, AST and symbol table digested per file over 4 807 files:
> 0 differ; `format --stdout` byte-identical over corpus and opentitan;
> diagnostics and menus identical on the edited buffer.
> **Filed, not fixed:** the token clone into `parse_tolerant` (3.9 ms —
> the parser mutates the stream it is given, so it cannot be handed
> over while `Document::tokens` is read for comments), `analyze`
> (9.4 ms), `resolve_external` (4.7 ms), and the ~6 ms spent dropping
> the previous revision's products on the request path.
## QA log
### 2026-09-12 — TODO §63.2 verified: PASS
Verified the flush split, the three lexer/parser changes, and the lead's
`attach_trailing` edit. Everything below was re-derived independently
(own tools, own binaries, own re-run of the dev's evidence), not read off
the dev's numbers. Scratch work: `/private/tmp/.../scratchpad/63-2-qa/`
(a fresh clone of 1b8723c at `old_lucisv/`, a paired-QA benchmark run at
`paired-qa/`).
**Gates** (all through `tools/guard.sh -m 8 -t 1800`, no guard kill
anywhere):
- `cargo test --workspace`: **4 422 passed, 0 failed** (run alone, no
concurrent cargo invocation — an earlier attempt run *concurrently*
with another `cargo test`/`cargo build` in the same tree hit a stale
doctest rlib once; that is a target-dir race from running two cargo
processes at once, not a code defect, and does not reproduce solo).
4 406 (the dev's count) + 16 tests this round added (13 in
`vlog_parser::lexer::tests`, 2 in `lucisv_server::state::tests`, 1 in
`lucisv_server::lint_trace::tests`) = 4 422.
- `cargo clippy --all-targets --workspace`: clean, 0 warnings.
- `cargo fmt --all -- --check`: clean.
**Fuzzers** (`docs/topo.md`'s `comment-slots` row names four; the SVA
fuzzer is `sva-bodies`'s): `cargo test -p vlog_formatter --test
verification a_comment_in_every_` — covergroup, fragment, constraint,
RTL, SVA, **5/5 pass, still at their pinned gap counts** (329/153/395/
419-class/705). No formatter or comment-slot code was touched by this
round, so this is a regression check, not new coverage — it stayed at
zero.
**`skip` vs `bump`, mechanically, not by reading the diff**: a script
diffed old and new `crates/vlog_parser/src/parser/*.rs` and asserted
every hunk is `bump()` → `skip()` and nothing else (line-for-line, same
whitespace). Result: **every one of 178 hunks matches that shape**, and
every removed line is a bare `self.bump();` statement (verified
separately — `grep '^-' | grep -v 'self\.bump();'` on the parser diff
returns nothing but the lexer's unrelated deleted lines and the two
`eat_sym`/`eat_kw` bodies, both bare-statement too). Cross-checked: 252
`Parser::bump()` call sites existed in `parser/` at 1b8723c, 74 remain
(all `.bump().text` or similar — value used, correctly untouched),
252 − 74 = 178, matching exactly.
- **Finding (non-blocking, doc-only): the "217 call sites" claim in the
Work log and TODO.md §63.2 does not match the diff.** The diff converts
**178** call sites (176 direct + the 2 inside `eat_sym`/`eat_kw`), not
217. `~296` (Work log) is real — it is the *textual* `.bump()` count
across all of `vlog_parser/src` including `RawLexer::bump` (a
different, unrelated function) — but 217 does not correspond to any
count I could reproduce from the tree at 1b8723c or from the diff. Not
a safety issue (every conversion that *did* happen is a verified-safe
shape, and no unused-result `self.bump();` statement remains anywhere
in `parser/`), but the number should read 178 wherever it is quoted
again (the Work log, TODO.md §63.2, and the `docs/perf/README.md` paste
in this file all repeat it). Left the dated Work log entries as the
historical record; not editing them.
- **Finding (fixed directly, typo-class): the operator table has 42
entries, not 44.** Counted `OPERATORS` in `lexer.rs` by hand and by
script: 42. The inline code comment said "44 spellings" — fixed to 42
(`crates/vlog_parser/src/lexer.rs`, the comment above the first-byte
test). The Work log prose and TODO.md still say 44; same disposition as
above — noted, not rewritten.
**Comment-attachment attacks on the fused lexer** (item 4): built
`tokenize` from 1b8723c in a fresh clone (`old_lucisv/`) and from the
working tree as two throwaway `examples/qa_token_digest.rs` /
`qa_dump_one.rs` binaries (removed after use — not part of this diff).
- **Whole corpus + opentitan, re-derived independently**: token stream +
parse-tree + diagnostics digest (a hash of `{:?}` output, not read from
the dev's cached digest files) over the same **4 807-file list** the
dev used (`~/.cache/lucisv-perf/63-2/files-all.txt`): **0 lines
differ**.
- **The ten named attack shapes** (comment first in file; two comments
before any token; trailing comment at EOF; two block comments merging
on one line; a blank line between a comment and its token; CRLF; a
block comment spanning lines before a same-line token; a comment
between a macro invocation and its arguments; a file that is only
comments; an empty file): dumped full `Debug` token streams for all
ten from both builds — byte-identical hashes and, for the trickier
three (merge, macro-comment, multi-line block), eyeballed the raw
`Debug` output for sanity. Pinned as **ten new tests** in
`crates/vlog_parser/src/lexer.rs`'s `mod tests` (search
`TODO §63.2 QA`), all passing.
- The lead's `attach_trailing` edit (returns the comment instead of
dropping it when there is no previous token): confirmed the branch is
unreachable through `tokenize` today (`attach` only calls
`attach_trailing` when `same_line_as_prev` is true, which already
requires `!tokens.is_empty()`), so it changes nothing observable yet
and is a correct hardening of invariant 3 for whichever future caller
removes that guard. Compiles clean, no test regressed.
**Operator table** (item 5): three new tests in `lexer.rs`.
- `every_operator_s_first_byte_is_a_single_ascii_byte` — all 42 entries.
- `the_operator_table_has_no_duplicate_or_empty_entries`.
- `every_operator_followed_by_every_other_operator_still_lexes_without_a_gap`
— all 42×42 = 1 764 concatenations, asserted to round-trip with no gap.
Cross-checked the same 1 764 pairs against 1b8723c with the throwaway
digest tool: **0 differ**.
**Idempotency and snapshots** (item 6): `cargo test -p vlog_formatter`
green as part of the full workspace run above (`fixtures_match_snapshots
_and_are_idempotent` passes). `tools/corpus_check.sh corpus -b
target/release/lucisv`: 814/820 parse & format, 0 verification errors, 0
crashes, and the outcome column is **byte-for-byte identical to the
tracked `corpus-check-results.tsv`** for all 820 files. `format --stdout`
byte-identity: **corpus, 0 differ** (stdout and stderr both, against
`~/.cache/lucisv-baselines/lucisv-0.53.0`); **opentitan `hw/ip`
(1 807 files), 0 differ**, same 4 parse errors both binaries, run through
the guard. `git -C ~/repo/opentitan status --porcelain` before and after:
only the three pre-existing files, every time.
**sha256 / rebuild check** (item 7 precondition): a fresh
`cargo build --release` of the working tree's `lucisv` CLI matches
`~/.cache/lucisv-perf/63-2/lucisv-new` byte for byte
(`fabd3432…bdfcfaf`) — the lead's edit landed before that binary was
built. **`lucisv-server` does *not* match**: `server-step2-lexparse`
(built 01:23) is `b0b09544…`, a fresh build of the current tree is
`694287ea…`. The lead's edit landed between the two builds (01:23 →
01:25), so the server binary used for the dev's own paired run predates
it. Per the brief, rebuilt the candidate and re-ran the paired benchmark
against the fresh binary rather than trusting the cached one.
**Paired re-take** (item 7), `paired-qa.sh` (same shape as the dev's
`paired.sh`, ref/new alternated, 3 tries, one warm store per binary),
against the freshly built candidate `lucisv-server` (694287ea…) and the
reference rebuilt from 1b8723c and hash-verified against
`server-ref-0.53.0` (6b1b5245…, matches):
| cell | ref (a/b) | candidate (a/b) | change |
|---|---:|---:|---|
| `offeredit` pinmux-comment, first after didChange (median of 3) | 112.31 / 110.63 | 90.35 / 92.57 | **−19.6% / −16.3%**, gate (≥15%) met both rounds, stretch (<95ms) met |
| `offeredit` aes-reg-instance, first after didChange | 6.32–7.82 | 2.94–8.05 | inside noise, matches dev's characterization |
| `offeredit` tb-comment, first after didChange | 0.56–3.94 | 0.56–3.08 | inside noise |
| `offerkinds`, 35 rows | 0.03–6.0 ms | 0.03–5.0 ms | no row moved out of range |
| RSS cold | 502.7–505.2 MiB | 478.6–483.1 MiB | lower, matches "cold ~25 MiB lower" |
| RSS warm | 427.4–429.4 MiB | 426.9–429.3 MiB | flat |
This run was **not** on an idle machine (a `cargo test --workspace` was
running concurrently in the background for part of it), which is why the
absolute ms are a little higher than the dev's own quieter-machine
numbers — the percentage reduction and every qualitative claim
(noise-level `offerkinds`/other cursors, RSS direction) hold anyway, so
the gate is met with margin either way.
Also re-ran `parity_menu.py` (item covering TODO.md's "an edit that
moves a fence" attack, plus the lex-failure and `define`-table attacks
below) against the freshly built ref/candidate pair: **87 lines, 0
differ**, same as the dev's own run — the LINTY edit's fence/lint-finding
path is unaffected.
**TODO.md's three named parity attacks** — a buffer that fails to lex, a
`` `define `` edit that changes the macro table, an edit that moves a
fence:
1. **Lex failure**: new test
`a_buffer_that_fails_to_lex_still_records_every_rebuild_stage`
(`state/mod.rs`) — an unterminated string literal, confirms `tokens`
stays empty, a diagnostic is produced, `Rebuild::Lex` is still
recorded (the failed attempt is real work), and every other stage
(`defines`/`analyze`/`external`/`lines`/`publish`) still runs over the
empty tree exactly as the un-instrumented code always did.
2. **`define` edit**: new test
`a_define_edit_changes_the_macro_table_the_rebuild_reports_on` —
two `Document::new` calls with different macros, confirms the second
document's table has no trace of the first's macro (no cross-document
staleness introduced by wrapping `collect_defines` in `rebuild`).
3. **Fence-moving edit**: covered by the `parity_menu.py` re-run above
(the LINTY revision is exactly this — a new lint finding changes what
the fence/diagnostics path reports for the revision).
**`lint_trace` arithmetic — sabotaged, as asked** (item 8): nested
`rebuild{…}` inside `flush{…}` in `Trace::line()` and reran the dev's
pinning test, `the_rebuild_group_names_every_stage_beside_the_other_two`.
**It did not fail.** That test extracts the rebuild body by splitting on
the literal string `"rebuild{"` and the *next* `}`, which finds a clean
body whether or not another `}` follows — the extra brace the nesting
adds sits outside the slice the test inspects. Checked what actually
happens to a consumer against `tools/perf/phases_p2.py`'s real regex
(`([a-z_]+)\{([^{}]*)\}`, which cannot cross an inner `{`): run against
the sabotaged line, `GROUP.findall` matched only `rebuild` and `action`
— **the whole `flush` group silently fails to match**, and
`flush_wall`/`flush_buffers`/`flush_parses` and every `flush.fields()`
key vanish from that row with no error anywhere. So the existing pin
does not actually enforce the sibling-group contract it documents.
Added `the_three_top_level_groups_are_flat_never_nested` to
`lint_trace.rs`'s test module, which reads the line the way the regex
does (each group must reach its own `}` before another `{` opens) —
confirmed it **fails** against the sabotaged code and **passes** after
reverting the sabotage; the sabotage itself is reverted (`git diff` of
`lint_trace.rs` no longer shows it). This is the one finding I'd call a
real gap rather than a documentation slip, though it is a `tools/perf`
tooling-correctness issue, not a formatter-invariant one (no corpus/
opentitan output is affected), so it does not block this round; filed as
a fix-directly-and-note per CLAUDE.md's QA rule since the fix is a test
addition, not a redesign.
**Not independently re-verified**: the dev's own `flush`/`diagnostics`
paired cells (only `offeredit`/`offerkinds`/`rss` were named in my brief
for item 7); the micro-harness per-stage table (`tokenize` 27.79→11.59ms
etc.) — trusted as reported, since the stage split itself is exercised
by the corpus-wide digest and the paired re-take above.
**Verdict: PASS.** No corpus, opentitan, snapshot, idempotency or
comment-preservation regression found anywhere; the two real findings
are a documentation/count inaccuracy (217→178, 44→42, the latter fixed)
and a test-strength gap in the sibling-group pin (fixed with a new test
that actually catches the nesting failure mode). Gate met with an
independently-measured margin on a busier machine than the dev's own
run.
## Review
**Lead review, 2026-09-12 — accepted.** The lane did what the brief
asked in the order it asked: the flush split came first and it settled
two of the review's candidates without code (no second lint, no second
analysis), then named the two stages that mattered — lex and parse, 55 of
a 100 ms flush. The three changes are all in `vlog_parser` and all
behaviour-preserving by construction: the lexer fusion is a reordering of
the same attachment loop (the fused `attach` reads only the raw token in
hand and the token last pushed, which is all the old loop ever read),
`Parser::skip` is `bump` minus the clone with the same comment plumbing,
and the first-byte test in front of the operator table is a filter in
front of an unchanged `starts_with`. The proof is the one that matters for
a lexer change: token stream, diagnostics, AST and symbols digested per
file over 4 807 files with 0 differing, re-derived by QA from a rebuilt
1b8723c, plus the five gap fuzzers at their pinned counts and every
byte-identity gate. Gate met at −19.2 % (dev) and −19.6 % / −16.3 % (QA's
re-take on a busier machine), stretch met.
One edit is the lead's, and QA covered it: `attach_trailing` now hands an
orphan comment back to `pending` instead of returning silently — the
branch is unreachable while `same_line_as_prev` requires a token, and it
stays a rule rather than a hope (invariant 3).
Rulings on QA's findings:
- **Counts** (217 call sites and 44 operators in the Work log; 178 and
42 in the tree): the Work log stands as a dated record; the lead's own
entry in `docs/perf/README.md`, TODO §63.2 and the topo row carry the
verified numbers.
- **The nesting guard**: the dev's pin string-split the line and missed a
nested group; QA's `the_three_top_level_groups_are_flat_never_nested`
runs the real regex and catches the sabotage. Accepted as the pin.
Deferred with the dev's reasons and filed in TODO's loop-3 list: the
token clone into `parse_tolerant` (the parser mutates the stream it is
given), `analyze`, `resolve_external`, and dropping the previous revision
on the request path. `lexer.rs` at 770 production lines is noted: the
fusion removed a responsibility rather than adding one.
File diff suppressed because it is too large. Load diff
+56 -7
View File
@@ -22,13 +22,35 @@ predicate, and three handlers.
- **The workspace index is the authority on what can be named from another
file.** `nav::leaves_this_file` decides whether a references request walks
the workspace by asking `WorkspaceIndex::units` / `::member` about the name
under the cursor — not by re-deriving `is_unit`/`is_exported`, which are
private to `vlog_semantic` and would be language knowledge in the protocol
layer. Consequence: a declaration the index has not seen yet (a buffer
edited but not saved, when the file is new) is answered in-file until the
next rebuild. That is the same staleness window every other cross-file
answer already has, documented in `docs/features/lucisv-server/README.md`.
the workspace by asking `WorkspaceIndex::units` / `::member_in(…,
Surface::Hierarchical)` about the name under the cursor — not by re-deriving
`is_unit`/`is_exported`, which are private to `vlog_semantic` and would be
language knowledge in the protocol layer. **The surface matters** (amended
2026-09-12, §64.1): the question is which declarations a *use* in another
file can reach, and a hierarchical path may name anything a module declares
(IEEE 1800 §23.6) where a connection list may name only its ports and
parameters (§23.3). Asking `::member` — the connection surface — was what
made `assign w = u_x.sig;` in another file invisible to `references` while
a rename was already editing it. The connection answer is the first, whole
part of the hierarchical one, so nothing else moved; see
`docs/features/references-hierarchical-surface/README.md`. Consequence: a
declaration the index has not seen yet (a buffer edited but not saved, when
the file is new) is answered in-file until the next rebuild. That is the
same staleness window every other cross-file answer already has, documented
in `docs/features/lucisv-server/README.md`.
- **A stale index can omit a location; it can never point at a wrong one**
(added 2026-09-12, §64.1 rework, QA findings 1–3). Until then this feature's
staleness story stopped at the sentence above, which undersold it: a span
recorded at index time and rendered against a **closed** file's current
bytes — a `references_to` posting, or the `include_declaration` fallback —
had no agreement check, so an external edit to that file (another tool,
`git checkout`, a build step: none of the five events that drop a cached
view) could put a true-looking `Location` on a line that no longer holds the
name. `nav::closed_locations` now applies `hover::spells_exactly` to every
closed-file span before emitting it and drops the ones that no longer spell
the target's name — the same guarantee `hover-declarations` gives a snippet.
Open buffers are not guarded and pay nothing: their spans come from the very
text they are rendered against.
- **A references answer is an indexed lookup.** Each `FileFacts` record stores
compact facts for references to externally reachable declarations. The
finished `WorkspaceIndex` resolves those facts once into declaration-to-use
@@ -230,6 +252,33 @@ decision.
## Work log
### 2026-09-12 — dev (TODO §64.1: the gate asks the hierarchical surface)
`leaves_this_file` and `indexed_def_in_file` — this feature's two index
questions — asked `WorkspaceIndex::member`, the **connection** surface. Since
`hierarchical-tail` (0.45.0) a module's net, variable and instance live on the
**hierarchical** surface only, so both functions judged such a declaration
unable to leave its file: `references` from the declaration fell to the
single-file answer and never saw a cross-file `u_x.sig` tail or a `bind`
connection expression, and a request that *did* go cross-file could not
re-identify the declaring buffer's own in-file uses. Both now ask
`member_in(owner, name, Surface::Hierarchical)`. Every connection-surface
answer is byte-identical (the connection records come first and whole from
that read); the `nav` harness rows are unchanged in count and within noise in
time. The closed-declaring-file half of the completeness problem, the new
`nav::declaring_file_uses`, the fixture sweep and the attack cases are all
written up in `docs/features/references-hierarchical-surface/README.md`, which
is this change's feature README. `documentHighlight`'s "a document answer even
for a cross-file name" assumption was untouched and is now pinned from both
ends (`definition_and_document_highlight_over_a_hierarchical_tail_are_unchanged`).
**Rework the same day**, on QA's findings 1–3: the closed-file path reads each
closed file exactly once per request, with `text_of` rather than the
`file_view` cache, and every index-time span about a closed file is guarded by
`hover::spells_exactly` before it is rendered. That is the new Assumptions
bullet above; the derivation and the flipped QA tests are in
`docs/features/references-hierarchical-surface/README.md`.
### 2026-08-28 — documentHighlight answered nothing on a cross-file name
**The report.** `performance.md` §7: `documentHighlight` returned 0 results at
@@ -0,0 +1,596 @@
# rename-bind-occurrences — a `bind` file's own occurrence of a renamed name
TODO §63.1, from §61.5's QA finding `task_834abda3`
(`docs/features/perf5r-scope-reuse/README.md`, QA log item 6). Reference tree
`2675131`, branch `master`.
## Goal
Renaming `entropy_masking_req` — a net declared in opentitan's
`hw/ip/aes/rtl/aes.sv` — edited `aes.sv` and left
`hw/ip/aes/dv/sva/aes_bind.sv`'s `.entropy_masking_req(entropy_masking_req)`
alone, **without a word**. Renaming `seed_en` (declared in
`aes_prng_clearing.sv`) left the same file's two-level tail
`u_aes_core.u_aes_prng_clearing.seed_en` alone, also without a word — while
§49's hierarchical tail from an ordinary instantiating file
(`u_entropy_src_main_sm.state_q` in `entropy_src_core.sv`) was edited. The
whole-scope engine is the refusal authority, so a silent miss is a wrong
answer: after such a rename the design no longer elaborates.
The contract this lane reaches: an occurrence in a `bind` directive's
connection is **edited** when the engine resolves it to the renamed
declaration — a bare name in the bind target's scope, or a hierarchical path
rooted at that target — through the same rungs an instantiating file's
occurrences use; **warned about**, with file and line, when the engine cannot
resolve it; **never silent**.
## What dropped the bind file
Selection was not the culprit and the rungs were not short. Two **engine**
steps were, and both are in `vlog_semantic`:
1. **`resolve::in_bind_target` asked the wrong member surface.** A bare name
in a `bind`'s connection expression already carried
`Target::BindScope { target }` (bind-semantics, 2026-09-02). When the
target module is declared in another file — which is every real bind — the
resolver handed the workspace
`ExternalCandidate { paths: ["aes"], surface: Surface::Connection }`. A
module's **connection** surface is its ports, parameters, properties and
sequences (`workspace/hierarchy.rs::surface_of`); its nets, variables and
instances live on the **hierarchical** surface. So
`member_chain(index, "aes", "entropy_masking_req", Connection)` answered
nothing, the overlay recorded `StillUnresolved`, and
`Scope::collect_occurrences` — which edits exactly the references the
overlay resolved to the target declaration — skipped it.
The same single-segment path is why it was *silent* as well as unedited.
`warnings::unresolved_unit` names the unit a candidate was searched in by
splitting the recorded path at its `::`; a path of `"aes"` has none, so the
`unresolved_candidate_warnings` scan had no unit to report and said
nothing. (The `unaccounted` scan could not cover it either: that one runs
only over files the rename actually edited.)
2. **A hierarchical tail in a `bind` was resolved from the scope the
directive is *written* in.** `u_aes_core.u_aes_prng_clearing.seed_en`
reaches the resolver as `Target::MemberOf { head: "u_aes_core", mids:
["u_aes_prng_clearing"] }`, and `resolve::head_site` looks the head up on
the writing scope's lexical chain. A bind module declares nothing, so the
head resolved to nothing, `member_site` returned `None` — *no reference at
all*, not even an unresolved one — and every later link was dropped with
it. Nothing to edit, and nothing for any warning scan to see.
The probe that settled it (run at `2675131`, the five-file fixture of
`crates/vlog_refactor/tests/rename_bind.rs`, printing every reference of the
bind file with its resolution and its overlay answer):
```
2: "entropy_masking_req" ExternalCandidate { paths: ["aes_reseed_if"], Connection } -> Resolved(Port) <- the `.port` half
3: "entropy_masking_req" ExternalCandidate { paths: ["aes"], Connection } -> StillUnresolved <- the expression half
5: "u_aes_core" ExternalCandidate { paths: ["aes"], Connection } -> StillUnresolved <- the tail's head
<- and no reference at all
for `u_aes_prng_clearing`
or for `seed_en`
```
**The selection rungs were checked and are sound.** `aes_bind.sv` is wanted by
`Workspace::rename_sources_traced`'s `Rung::Reference`: `fan_out_of` puts the
declaration's container (`aes`, from `index.hierarchical_declarations`) into
`containers`, then asks `want_declaration` for every `units("aes")`, whose
`references_to` postings include the `bind aes …` head — a
`Target::Module` reference the binder has always recorded. So no rung was
added, `module_select::hierarchical_users` is untouched, and
`WorkspaceIndex::files_mentioning` was not needed. This is confirmed
end-to-end by the three opentitan renames under all three reuse modes (Work
log, 2026-09-11).
## Assumptions
- **IEEE 1800-2017 §23.11 / §23.6.** A `bind`'s connection expressions
elaborate in the *target* scope, and a hierarchical path may name anything
the scope it walks into declares — not only what a connection list could
name. The whole fix is that second half: a bind connection is a
hierarchical reach, so it is asked of the hierarchical surface.
- **The target's own scope answers before the writing scope**, and only a
miss the target settles falls back. That ordering is bind-semantics'
(2026-09-02) and is unchanged here; this lane changes *which* surface the
target is asked about and *how* a path is spelled, never the order.
- **A hierarchical target path is a place the index can often reach.**
`bind tb.u_aes chk u (…)` is `tb::u_aes` — one `member_unit_in` hop over
`tb`'s instance `u_aes`, which is exactly what `external::fold_path`
already does for `pkt_t::hdr::addr`. Where the index cannot take a hop (a
generate index, `gen[0]`, has no record at all) the path answers nothing
and the miss is reported rather than guessed at.
- The `.port` half of a `bind` connection still names the **bound** module's
port and is untouched. Every fixture here renames a name that is spelled on
both halves, so a fix that edited both would fail loudly.
- A bind file is an ordinary edited file to `check/after.rs`: it is absorbed
into the after-index and its after-print is compared like any other. No
change was needed there and none was made.
## Handshakes
**`vlog_refactor ──▶ vlog_semantic` (amended, additive in the AST, wider in
the answer).** The rename engine reads the same `Resolution`/
`ExternalResolutions` it always did; what changed is what the resolver
produces for a `bind` connection:
| | before | after |
|---|---|---|
| bare name, target elsewhere | `ExternalCandidate { paths: ["aes"], Connection }` | `ExternalCandidate { paths: ["aes::name"], Hierarchical }` |
| bare name, target in this file | `Resolved` / `None` | unchanged |
| hierarchical tail in a bind | *no reference recorded* | `Target::BindMember` → `Resolved`, or `ExternalCandidate { paths: ["aes::u_core::…::name"], Hierarchical }` |
| multi-segment bind target | connections resolved in the **writing** scope | resolved in the target scope, spelled `tb::u_aes` |
The path spelling is the `unit::name` one `external::follow_one` already
reads, so no workspace-layer code changed: `follow_one` folds the hops and
`member_chain` does the lookup, exactly as for a `u_x.sig` tail.
**`lucisv_server ──▶ vlog_refactor` — unchanged.** `rename_traced_with`,
`rename_preflight` and the source selectors keep their signatures and their
answers. Refusal parity with `rename_preflight` stays one-directional and in
the safe direction: a cursor on a bind file's hierarchical tail used to have
no reference at all, so the preflight refused it with `NOTHING_HERE`; it now
carries an external candidate, which the preflight *defers* (`Ok(())`). The
preflight refuses strictly less than before and never more.
**Topology rows the lead must edit** (`docs/topo.md` is not this lane's
file):
1. `§2.9-15` / the `bind-semantics ◀──▶ workspace-index / index-persistence`
handshake row: **`FACTS_FORMAT` 19 → 20** (2026-09-11). No new field — the
same fields carry a different answer: a bind connection's recorded path is
now `target::name` on the hierarchical surface, so a 0.53.0 store would
answer definition, find-references and this rename as though the bind file
did not mention the name. The store rebuilds once. The bump's own
paragraph is in `crates/vlog_semantic/src/facts.rs`.
2. The `vlog_refactor ──▶ vlog_semantic` row: a bind's connection expression
is a reference on the target's **hierarchical** surface, and a bind's
hierarchical path is rooted at the target (`Target::BindMember`), so
`references`, `definition`, `hover` and `rename` all answer over bind
files where they answered nothing before.
3. `§2.9-33`'s closing note stands unamended: the rung it closed
(`module_sources_reaching`) is not what this lane needed, and
`module_select.rs` is untouched.
**Files edited outside this lane's stated list, flagged rather than silent**
(§63.1 named `vlog_semantic/src/{resolve.rs,workspace/}` "only if a resolver
rung is genuinely missing"; these three are in `vlog_semantic/src` but not in
that list):
- `crates/vlog_semantic/src/bind/mod.rs` — the new `Target::BindMember`
variant and one more arm in the single funnel (`use_member`) that already
redirects a bind connection's bare names. The tail case cannot be fixed in
`resolve.rs` alone: the resolver has no way to learn the bind target of a
`Target::MemberOf`, because the pending use does not carry it.
- `crates/vlog_semantic/src/bind/item.rs` — `bind_bind` now sets the bind
target for a multi-segment target path too, through the new
`bind_target_path` (the `::`-joined spelling the index reads). It still
records **no reference** for such a path, as before.
- `crates/vlog_semantic/src/facts.rs` — the `FACTS_FORMAT` bump above. Not
bumping it would leave a stale store answering thinner, which is the exact
failure every earlier bump exists to prevent.
## Status / TODO
- [x] the reproduction pinned first — `crates/vlog_refactor/tests/rename_bind.rs`,
seven fixtures (bare-name connection, positional connection, two-level
tail, `: u_x` instance-list target, hierarchical target path, `bind`
inside `if (…) begin : gen … end`, and a bind whose target module is not
in the workspace). All seven asserted today's silent miss at `2675131`
before a line of the fix was written, and all seven flipped with it.
- [x] the fix: `Target::BindMember` + the hierarchical surface + the
`target::name` path spelling; unresolvable occurrences reported through
the sentence `unresolved_candidate_warnings` already uses; the step
that dropped `aes_bind.sv` named above.
- [x] parity: `renamewarn` and the paired phases (`renametrace`,
`tailrename`, `rename`, `refactor`) against the `2675131` baseline —
28 (phase, row) keys, every difference a `bind` file's new edit or
warning and listed above; the eight rename shapes within noise, the
tail rename 326.2 ms median (gate ≤ 330).
- [x] the three QA renames over the real opentitan tree, all three reuse
modes: identical answers, `aes_bind.sv` edited in both bind cases.
- [x] a fixture row for the shape: `tools/perf/phases_p2.py`'s `RENAMES`
gains `bind: entropy_masking_req -> masking_req_x` (and
`phases_r3b.py`'s `WARNED` gains `bind`), so the harness measures this
lane's shape from now on.
- [x] QA
## Work log
**2026-09-11 (dev), the reproduction.** Seven fixtures in
`crates/vlog_refactor/tests/rename_bind.rs`, over a five-file in-memory
workspace shaped like the real one (`aes` declaring the net and instantiating
`aes_core`, which instantiates `aes_prng_clearing`; `aes_reseed_if` as the
bound checker, with ports deliberately spelled like the renamed names so a fix
that edited the `.port` half would fail loudly; and the bind file). All seven
failed at `2675131` exactly as §61.5's QA described — no edit, no warning. The
probe quoted above was run from the same fixture and is what named the two
engine steps.
**2026-09-11 (dev), the fix.**
- `crates/vlog_semantic/src/resolve.rs`
- `in_bind_target` records `paths: ["{target}::{name}"]` on
`Surface::Hierarchical` instead of `paths: ["{target}"]` on
`Surface::Connection`. This is both halves of finding 1: the surface makes
the lookup find a module's internal net, and the `::` gives the warning
scan a unit to name when it does not.
- new `bind_member`: the spine of a bind's hierarchical path, rooted at the
target — the target's own scope when this file declares it, else the
target as the unit the workspace answers hierarchical members of — with
`head` as simply one more link.
- `member_of`'s tail lookup and `member_site`'s per-link hop are lifted to
`member_at` and `descend` so that `bind_member` walks *the same* code. A
second spelling of either would eventually answer one name two ways. The
`direct` flag carries the one thing the split would otherwise lose: only a
plain `head.member` may report an `InheritedCandidate`.
- `crates/vlog_semantic/src/bind/mod.rs` — `Target::BindMember { target,
head, mids }`, produced by one more arm of the existing `use_member` funnel
(the same place `Target::Lexical` already became `Target::BindScope`).
- `crates/vlog_semantic/src/bind/item.rs` — `bind_target_path`, and
`bind_bind` setting the bind target from it. A multi-segment target
(`tb.u_aes`) used to leave `bind_target` unset, which silently resolved its
connections in the writing scope; it is now `tb::u_aes`, a path the index
either walks or reports.
- `crates/vlog_semantic/src/facts.rs` — `FACTS_FORMAT` 19 → 20, with its
paragraph.
Nothing in `crates/vlog_refactor/src` needed to change: the warning sentence
the contract asks for is the one `unresolved_candidate_warnings` already
emits, and it starts firing for bind files as soon as the recorded path has a
unit in it.
Two more fixtures beside the seven: a new name the bind target already
declares is refused, and a rename applied and then reversed restores the bind
file **byte for byte** (the new resolution is stable under its own edit).
`check/after.rs` is untouched and needed nothing: an edited bind file is
absorbed into the after-index and re-printed like any other edited file.
**2026-09-11/12 (dev), the three QA renames on the real tree.**
`the_three_qa_renames_agree_across_reuse_modes_and_edit_the_bind_file`
(`#[ignore]`d, `crates/vlog_refactor/tests/rename_bind.rs`), over the real
opentitan checkout — 3 975 `.sv`/`.svh` files, read and never written —
through `rename_traced` / `rename_traced_with`, each rename asked three ways
(no records, every record, every second record). **Identical edits and
identical warnings in all three modes, all three renames**, and the two bind
cases now edit `aes_bind.sv`:
| rename | files | edits | warnings | `aes_bind.sv` | parses (none / all / half) |
|---|---|---|---|---|---|
| `WidthPRDSBox` → `WidthPRDSBoxX` | 6 | 32 | 3 | — (correctly) | 3 980 / 13 / 1 997 |
| `entropy_masking_req` → `masking_req_x` | 2 | 6 | 9 | **×2** | 3 976 / 10 / 1 993 |
| `seed_en` → `seed_en_x` | 2 | 4 | 1 | **×1** | 3 976 / 38 / 2 005 |
The two `aes_bind.sv` edits for `entropy_masking_req` are the expression
halves of the two `bind aes …` directives (the second inside
`if (\`EN_MASKING) begin : gen_prng_bind`); the four `.entropy_masking_req(`
**port** halves are correctly left alone, because they name
`aes_reseed_if`/`aes_masking_reseed_if`'s ports. The one `seed_en` edit is the
two-level tail `u_aes_core.u_aes_prng_clearing.seed_en`.
`git -C ~/repo/opentitan status --porcelain` after every run: the three known
files and nothing else.
**2026-09-12 (dev), the parity measurement.** Two release `lucisv-server`
binaries — the baseline built from `2675131` in a scratch worktree (the
0.53.0 preserved binary is the CLI, not a server), the candidate from this
tree — over the real opentitan tree, through `tools/guard.sh -m 8 -t 1800`,
order alternated. Phases `renametrace`, `tailrename`, `rename`, `refactor`
(three tries each, four sessions per binary on `renametrace`) plus
`renamewarn`. Raw evidence, both binaries, the run script and the comparison
script are preserved in `~/.cache/lucisv-perf/63-1/` (its own README lists
them and quotes the reproduction).
*Answers.* 28 (phase, row) keys compared field by field on `fingerprint`,
`status`, `message`, `result_count`, `edits`, `files`, `created` and
`titles`. **Every difference is a `bind` file's new edit or warning, and
there is nothing else:**
| where | difference |
|---|---|
| `renametrace` `bind: entropy_masking_req` (the new fixture row) | `files` 1 → 2, `edits` 4 → 6, `titles` gains `aes_bind.sv`; `fingerprint` moves with them |
| `renamewarn` `tail: state_q` | **+1 sentence**: `state_q` at `aes_bind.sv:58` could not be resolved — `aes::u_aes_core::u_aes_cipher_core::gen_masks::u_aes_prng_masking::u_prim_bivium::state_q`. The path goes through the generate block `gen_masks`, which the index has no record of, so the miss is *reported* where it used to be silent |
| `renamewarn` `common port: clk_i` | **+2 sentences** — `top_darjeeling_bind.sv:22` and `top_earlgrey_bind.sv:25`, both `<top>_pd_aon::u_pwrmgr::clk_i`; and **one re-worded**: `hw/ip/rom_ctrl/dv/tb/tb.sv:83`, a `.clk_i (clk_i)` inside `bind dut.gen_fsm_scramble_enabled.u_checker_fsm.u_compare …`, said `uvm_pkg::clk_i` and now says the bind target's own path. Warned before, warned after; **no edit moved** |
| everything else | identical, including `ordinary: aes`, `conflict`, `new name many uses spell`, `duplicate module`, `no symbol`, all fifteen `refactor` rows and both `rename` rows |
Warning-sentence totals: base 1 758, candidate 1 764 — and 1 758 − 8 (the new
`bind:` row's own sentences) = **1 750**, the count §61.5 measured, so the
pre-existing four renames' sentence set is the same set it was.
*Timings* (median of four sessions per binary, orders alternated):
| row | base | candidate | Δ |
|---|---|---|---|
| `tail: state_q -> state_q_x` | 321.9 | **326.2** | +1.3 % |
| `tailrename` (the dedicated phase) | 322.9 | 322.6 | −0.1 % |
| `common port: clk_i -> clk_ix` | 2 885.3 | 2 908.1 | +0.8 % |
| `conflict: state_q -> state_d` | 269.5 | 271.6 | +0.8 % |
| `duplicate module: rstmgr_por` | 724.2 | 740.6 | +2.3 % |
| `new name many uses spell` | 2 281.6 | 2 297.6 | +0.7 % |
| `ordinary: aes -> aes_renamed` | 91.6 | 91.6 | 0.0 % |
| `unique internal: cipher_alert` | 18.2 | 17.9 | −1.9 % |
| `no symbol: whole scope then refuse` | 0.19 | 0.23 | (+0.04 ms) |
| `bind:` (new row) | 22.6 | 24.2 | +1.6 ms, inside both binaries' own spread |
The eight original shapes are within noise and **the tail rename's median is
326.2 ms, under the 330 ms gate** (322.6 ms on the dedicated `tailrename`
phase). The first round's two apparent outliers — `duplicate module` +28 %
and `tail` +4.4 % — were each a single noisy session (`duplicate module`
sampled 1 300/1 401 ms once and 719/748/733 in the other three); the second,
order-alternated round is what the table above is taken from, and the noisy
samples are left in the raw file rather than dropped.
**2026-09-12 (dev), the gates.** `cargo fmt --all -- --check` clean;
`cargo clippy --all-targets --workspace` clean through the guard, with no new
`#[allow]`; `cargo test --workspace` through the guard **4 395 passed, 0
failed, 46 ignored**. The lane's only test additions are the ten in
`crates/vlog_refactor/tests/rename_bind.rs` (nine plus one `#[ignore]`d) and
none were removed or renamed, so the count before the lane was 4 386 / 45.
`git -C ~/repo/opentitan status --porcelain` lists the three known files and
nothing else, checked after every phase and at the end.
*The one behaviour this measurement was watching for.* Making a multi-segment
bind target a real scope means a bare name in such a connection no longer
falls back to the scope the directive is *written* in. The whole opentitan
tree produces exactly one instance of that — `rom_ctrl`'s `tb.sv:83` above —
and it was an unresolved warning before and is an unresolved warning now. No
edit was lost anywhere in 28 rows.
## QA log
**2026-09-12 (QA). Verdict: PASS.** Gates, the dev's ten fixtures re-run at
`2675131`, six new attack fixtures, one preflight-parity fixture, one
wire-level LSP fixture, an independent re-derivation of the parity evidence
and the three opentitan renames, and the corpus/opentitan byte-identity
gates. Two findings, neither blocking (§63.1's contract holds and nothing the
fix touches misbehaves); both are noted below and neither's file is in
§63.1's stated list.
**1. Gates**, all through `tools/guard.sh -m 8 -t 1800`, no guard kill: `cargo
test --workspace` **4 403 passed, 0 failed, 46 ignored** (4 395 the dev
reported, +6 attack fixtures in `rename_bind.rs`, +1 wire-level fixture in
`nav.rs`, +1 preflight-parity fixture in `preflight_oracle.rs`); `cargo
clippy --all-targets --workspace` clean, no new `#[allow]`; `cargo fmt --all
-- --check` clean.
**2. The dev's ten fixtures, re-run against a fresh clone of `2675131`**
(`crates/vlog_refactor/tests/rename_bind.rs` copied in, nothing else
changed): **8 of 9 non-`#[ignore]`d fixtures fail at baseline exactly as
claimed**, and flip green on this tree. The tenth,
`a_new_name_the_bind_target_already_declares_is_refused`, **passes at
baseline unmodified** — finding 1 below. The `#[ignore]`d real-tree fixture
is inert without `LUCISV_BIND_ROOT` at both revisions, so it proves nothing
either way by itself; verified directly instead (item 6).
**3. Six new attack fixtures added to `rename_bind.rs`**, each run at both
this tree and the `2675131` clone:
- `a_bind_connections_bare_name_naming_the_targets_port_is_still_renamed`
(task 3a) — a bind connection bare-naming the target's **port** (`clk_i`)
is still renamed, and the checker's own `.port` half of the same name is
untouched. Passes at both revisions (`hierarchy::member`'s connection-first
read means a port was never at risk from the surface widening) — a
regression guard, not a reproduction.
- `a_bind_connection_resolves_in_the_target_not_a_same_named_decoy_in_the_writing_scope`
(task 3b) — the writing module declares its own `entropy_masking_req`; the
connection must still resolve `aes`'s net, not the decoy. **Fails at
baseline** (same finding-1 cause: `in_bind_target` asked the connection
surface for a net and found nothing, silently), passes here.
- `a_new_name_the_two_level_tails_terminal_scope_already_declares_is_refused`
(task 3c) — the bare-name path's collision refusal exercised one link
further down the spine, through `bind_member`/`member_at`/`descend` rather
than `in_bind_target`. Passes at both revisions: the same same-scope
refusal `check::verify`'s watched-files/resolution-identity pass already
applies (see finding 1) covers the new code path exactly as it covers the
old one — no gap specific to `bind_member`. On `rename_preflight`'s
one-directional parity: unaffected either way, since the collision refusal
is `check::verify`'s (workspace-only), never a `rename_preflight` refusal.
- `an_escaped_identifier_bind_target_is_still_resolved` (task 3d) — `bind
\aes.escaped …`. **Fails at baseline** (silently: no edit, no warning —
the escaped target is a single segment, same finding-1 cause), passes
here.
- `a_bind_with_no_connections_naming_the_renamed_signal_is_untouched`
(task 3e) — empty connection list plus a `defparam`. Passes at both
revisions; confirms the funnel does not misfire on a connection list with
nothing in it.
- `a_bind_target_reached_through_a_generate_block_is_warned_about_never_guessed`
(task 3f) — `bind tb.gen[0].u_aes …`. **Fails at baseline** (silently — the
multi-segment target left `bind_target` unset, finding 2's bug), passes
here with a warning naming the file and the unresolved path. The real
opentitan tree has exactly this shape
(`hw/ip/rom_ctrl/rtl/rom_ctrl.sv:365`, `begin : gen_fsm_scramble_enabled`,
bound from `tb.sv:83`) — see item 5.
**4. `rename_preflight` one-directional parity (task 3c's second half).**
Added `a_binds_connection_expressions_defer_rather_than_invent_a_refusal` to
`crates/vlog_refactor/tests/preflight_oracle.rs` (the existing per-byte
equality oracle between `rename_preflight` and the whole-workspace `rename`,
which previously had no `bind` fixture at all): sweeps every byte of a bind
file with both a bare-name and a two-level-tail connection, asserting the
oracle's own invariant (a preflight refusal must never be one the workspace
disagrees with) holds throughout, then names the exact byte Handshakes calls
out — the tail's `seed_en` — and asserts `rename_preflight` returns `Ok(())`
there. **Fails at the `2675131` clone** (`NOTHING_HERE` — no reference was
recorded there before this lane, so `symbol_at` also finds nothing) and
passes here, confirming the Handshakes table's claim precisely: refuses
strictly less than before, never more.
**5. The rom_ctrl re-worded sentence, read against the real file.**
`hw/ip/rom_ctrl/dv/tb/tb.sv:83` is `.clk_i (clk_i)` inside `bind
dut.gen_fsm_scramble_enabled.u_checker_fsm.u_compare rom_ctrl_compare_bound_if
#(...) u_bound_if (...)`; `gen_fsm_scramble_enabled` is confirmed a generate
block (`rom_ctrl.sv:365`, `if (!SecDisableScrambling) begin :
gen_fsm_scramble_enabled`). Base's sentence named `uvm_pkg::clk_i` — a
nonsensical search path, the writing scope's `import uvm_pkg::*` leaking in
through finding 2's bug — candidate's names
`dut::gen_fsm_scramble_enabled::u_checker_fsm::u_compare::clk_i`, the real
attempted path, correctly reported as unresolved because the index has no
record of a generate block. The re-wording is correct; both are warnings, no
edit moved, matching the dev's characterization exactly.
**6. Parity evidence re-derived directly from `~/.cache/lucisv-perf/63-1/`**
(read-only): `python3 compare.py paired.jsonl` reproduces **28 (phase, row)
keys, 4 field mismatches, all four confined to the `bind:
entropy_masking_req` row** (fingerprint/edits/files/titles — the new edit
itself), matching the dev's table verbatim. `compare.py`'s own timing column
prints `-` for every row — a script bug (it expects `ms` as a scalar; the
harness records it as a list of per-try samples) — so timings were
recomputed directly from the raw `ms` arrays: tail rename 322.5 ms (base) →
327.3 ms (cand), **under the 330 ms gate**, everything else within noise,
matching the dev's table within sampling variance. `warn.jsonl`: raw
sentence totals reproduce **1 758 → 1 764** exactly; the raw counts carry a
2× duplication (the harness's own artifact — every distinct sentence appears
twice, confirmed by exact-value-multiplicity histograms on the `common port`
row), and the **deduplicated** picture is 3 new distinct sentences (tail +1,
common port +2, matching the dev's per-row breakdown) plus the one reworded
sentence verified in item 5. `opentitan.status` after each phase: the three
known files, nothing else, confirmed six times over.
**7. The three opentitan renames, re-run directly** (not just the evidence
file): `LUCISV_BIND_ROOT=$HOME/repo/opentitan tools/guard.sh -m 8 -t 1800 --
cargo test --release -p vlog_refactor --test rename_bind -- --ignored
--nocapture`. Exact match to the dev's table: `WidthPRDSBox` 6 files/32
edits/3 warnings, parses 3980/13/1997; `entropy_masking_req` 2 files/6
edits/9 warnings, parses 3976/10/1993, `aes_bind.sv` edited ×2; `seed_en` 2
files/4 edits/1 warning, parses 3976/38/2005, `aes_bind.sv` edited ×1. The
in-test assertions (all three reuse modes agree; `.entropy_masking_req(`
port halves untouched) held. `git -C ~/repo/opentitan status --porcelain`
before and after: only the three known files, verified.
**8. Corpus and opentitan byte-identity gates**, both binaries built
`--release --locked` (candidate from this tree, baseline from a fresh
`2675131` clone): `tools/corpus_check.sh` — **identical outcome tables**
between both binaries (10 ok-unchanged / 804 would-reformat / 6 parse-error /
0 verification-error / 0 crash, exit 0 both). `target/release/lucisv --check`
over `/Users/guoliangchen/repo/opentitan/hw/ip` (1 805 `.sv`/`.svh` files):
**identical per-file exit-code classification both binaries** (30 clean /
1 771 would-reformat / 4 parse-error / 0 crash) — stronger than that,
`lucisv --stdout` on every file hashed (SHA-256) with both binaries:
**byte-identical formatted output for all 1 805 files**, confirming the
formatter moved not at all, as expected (no `vlog_formatter` file is in the
diff). `git -C ~/repo/opentitan status --porcelain` after: only the three
known files.
**9. Definition/references/hover over a bind file (task 4).** Added
`a_binds_connection_expression_is_reachable_by_definition_not_yet_by_references`
to `crates/lucisv_server/src/nav.rs` (no prior wire-level bind or
hierarchical-tail test existed there; modelled on the existing
`a_port_is_reachable_from_a_connection_in_another_file`). `definition` from
the bind file's expression half correctly jumps to the target's net (never
to the checker's `.port` half of the same name) — the overlay carries the
resolved `Def` straight through. `references`, in **both** directions, does
**not** currently see it — finding 2 below, filed as a standalone,
out-of-scope issue rather than a §63.1 defect.
**10. `FACTS_FORMAT` 19 → 20 (task 3g).** No new test needed:
`crates/lucisv_server/src/index_cache.rs:835`,
`a_store_from_any_previous_facts_format_is_dropped_not_misread`, loops `for
format in 1..FACTS_FORMAT` rather than testing one hardcoded number (written
that way after a QA finding on the `detail_span` bump specifically so it
could not go stale), so it already covers 20 without any code change and
already ran green in the gate above.
---
### Finding 1 (low severity, not blocking) — a dev fixture that passes
unmodified at `2675131`
`crates/vlog_refactor/tests/rename_bind.rs`,
`a_new_name_the_bind_target_already_declares_is_refused`: renames
`entropy_masking_req` to `masking_req` where **`aes.sv` itself** — the file
being edited — already declares a sibling `logic masking_req;`. This is an
ordinary same-file naming collision (`check::verify`'s watched-files /
resolution-identity pass, `crates/vlog_refactor/src/check/mod.rs:41`),
refused independently of whether the bind file is understood at all — it
passes at `2675131` byte-for-byte, confirmed by re-running the copied test
file there. It is a legitimate collision-refusal check (and, per item 3
above, the same mechanism does extend correctly to the new
`bind_member`/`descend` code path — see the new
`a_new_name_the_two_level_tails_terminal_scope_already_declares_is_refused`),
but its Status/TODO line ("a new name the bind target already declares is
refused") and Work-log description overstate what it demonstrates: it does
not exercise the fix. No code change needed — it is a correct test of a
correct (pre-existing) behavior, just not of *this* behavior. Suggest
re-wording its doc comment in a future pass; not fixed here since editing
another dev's fixture text without a legitimate copy-edit reason is outside
"small unambiguous" territory.
### Finding 2 (out of scope, not blocking) — cross-file `references` cannot
see a hierarchical-surface-only declaration, `bind` or not
`crates/lucisv_server/src/nav.rs`: `leaves_this_file` (line ~170) and
`indexed_def_in_file` (line ~254, shared with `hover.rs` per its own doc
comment) both decide whether a declaration can be referenced from another
file by calling `WorkspaceIndex::member(unit, name)` — the **connection**
surface only (`workspace/index.rs:82`; ports and parameters). A module's net,
variable or instance lives on the **hierarchical** surface only
(`workspace/hierarchy.rs`, since 2026-09-05) and so both functions treat such
a declaration as incapable of leaving its file. Two concrete symptoms,
reproduced in the new `nav.rs` test (item 9):
- `references` from the *declaration* of a hierarchically-reached net
(`leaves_this_file` returns `false`) falls straight to the single-file
fallback and never sees a cross-file use, `bind` connection or ordinary
`u_x.sig` hierarchical tail alike.
- `references` from a *use* that does resolve cross-file (a `bind`
connection, `leaves_this_file` returns `true` because the live reference
already carries a resolved candidate) still cannot re-identify an **open
buffer's own in-file** use of the same declaration, because
`indexed_def_in_file` maps the live symbol back to its persisted `Def` the
same wrong way.
Confirmed **not** specific to `bind`: a throwaway probe
(`module leaf; logic sig; ... endmodule` / `module top; leaf u_leaf(); wire
w; assign w = u_leaf.sig; endmodule`, no bind involved) reproduces the exact
same gap and was removed after confirming it (not part of the committed
diff). This predates §63.1 by roughly two weeks (the hierarchical-surface
feature, 2026-09-05) and is not introduced by this lane's fix — the fix
correctly widens what the *resolver* and the *rename engine* see (confirmed
throughout this log); `nav.rs` is not in §63.1's stated file list
(`crates/lucisv_server/src/{rename.rs,rename_trace.rs,module_select.rs,
state/}` only) and was not touched by the dev. Filed as a standalone
follow-up rather than fixed here — the fix is a `WorkspaceIndex::member_in`
(with `Surface::Hierarchical`) swap in both call sites and needs its own
fixture sweep across `definition`/`references`/`hover`/`documentHighlight`,
which is more than a "small unambiguous fix."
## Review
**Lead review, 2026-09-12 — accepted.** The dev's diagnosis is the one
worth having: selection was never the problem, the resolver was — a bind
connection's bare name asked the target's *connection* surface (ports and
parameters), which cannot hold an internal net, and a hierarchical path in
a bind was rooted in the writing scope, which declares nothing. Both fixes
are the smallest true ones: the path spelling `target::name` on the
hierarchical surface reuses `follow_one` untouched, and `Target::BindMember`
walks `descend`/`member_at` lifted out of `member_of` rather than a second
spine walk (the lifting is a pure move; the `direct` flag preserves the
`InheritedCandidate` rule for `head.member` exactly). The three files edited
outside the stated list are accepted: the tail case is unfixable in
`resolve.rs` alone, and not bumping `FACTS_FORMAT` would ship a stale store
answering thinner — the exact failure the bump discipline exists for.
Parity is what the brief asked for: every one of the 28-key differences is a
bind file's new edit or warning, 1 758 − 8 = 1 750 reproduces §61.5's count,
the one re-worded sentence (rom_ctrl `tb.sv:83`, a multi-segment bind
target) is more correct than before, and the tail rename held under the
330 ms gate. QA's fresh-clone check that the fixtures fail at `2675131`
is the proof the fixtures are load-bearing.
Rulings on QA's findings:
- **Finding 1** (a fixture that passes at `2675131`): kept as a regression
guard, not a defect — the README's Work log may not claim it flipped.
The fixture stays; its doc comment is amended by the lead to say what
it actually pins (an ordinary same-file collision surviving a bind
edit).
- **Finding 2** (`nav.rs`'s `leaves_this_file`/`indexed_def_in_file` ask
the connection surface, so cross-file `references` misses every
hierarchical-surface-only declaration, bind or not): pre-existing since
the hierarchical-surface feature, outside this lane's files, correctly
not fixed here. Filed in TODO's loop-3 list as the next navigation item
(QA task `task_d8afe80f`); QA's wire-level test in `nav.rs` pins the
definition half now and documents the references half.
Topo rows amended by the lead: the `FACTS_FORMAT` line (**20**) and a new
`rename-bind-occurrences ◀──▶ workspace-index / index-persistence /
bind-semantics / refactor-rename` handshake row; §2.9-33 unchanged.
+73
View File
@@ -1350,3 +1350,76 @@ three are fixed in 0.53.0; no performance number moved.
the retained-analysis parse work and the 31 ms facts decode, the
whole-index merge per publication) are filed with the review's
baselines and deferred to loop 3.
### 2026-09-12 — loop 3, round 1 (TODO §63)
**§63.1 is a correctness lane, not a performance one**, recorded here
because its parity ran through this harness: a `bind` file's own
occurrence of a renamed name is now edited (resolvable) or warned about
(not), never silent — the resolver had asked the bind target's
*connection* surface for a bare name and rooted a bind's hierarchical
path in the writing scope (`FACTS_FORMAT` 19 → 20). `renamewarn` 1 758 →
1 764 sentences, 1 758 − 8 = 1 750 held; every one of the 28 paired keys
that moved is a bind file's new edit or warning; tail rename 326 ms
(gate ≤ 330). `docs/features/rename-bind-occurrences/README.md`.
**§63.2 — the first request after an edit (N1 of the 0.52.0 review).**
The 40 267-line pinmux cell — one-character `didChange`, then the
all-family `codeAction` menu — **109 → 88 ms paired (−19.2 % dev;
−19.6 % / −16.3 % on QA's re-take, order alternated)**; the
unchanged-repeat cell and every other `offeredit`/`offerkinds`/`flush`/
`diagnostics` row within noise; cold-scan RSS ~25 MiB lower, warm flat.
The flush is now split on the `timing: codeaction` line
(`rebuild{lex parse defines analyze external lines publish documents}`),
which is what named the cost: **lex 29 ms and parse 26 ms of a 100 ms
flush**, and *no* second lint and *no* second analysis of the revision
(the snapshot and `with_semantics` already had those). Three changes, all
in `vlog_parser`: the lexer's two phases fused (the intermediate
`Vec<RawTok>` gone; `tokenize` 27.8 → 24.7 ms), `Parser::skip` for the
178 `bump()` sites that discarded the token (`parse_tolerant` 17.5 →
16.0 ms), and a first-byte test in front of the 42-entry operator table
(`tokenize` 24.7 → **11.6 ms**, the single largest win). Token stream,
parse diagnostics, AST and symbol table digested per file over 4 807
files, re-derived by QA against a rebuilt 1b8723c: 0 differ; the five
gap fuzzers at their pinned counts; `format --stdout` byte-identical over
corpus and opentitan `hw/ip`; diagnostics and menus identical on the
edited buffer (87 lines). **Filed, not fixed** (TODO loop-3 list): the
token clone into `parse_tolerant` (3.9 ms — the parser mutates the
stream it is given, so it cannot be handed over while `Document::tokens`
is read for comments), `analyze` (9.4 ms), `resolve_external` (4.7 ms),
and ~6 ms dropping the previous revision's products on the request path.
`docs/features/perf-first-after-edit/README.md`; evidence
`~/.cache/lucisv-perf/63-2/`.
### 2026-09-12 — loop 3, round 2 (TODO §64)
**§64.1 is a correctness lane, not a performance one**, recorded here
because it moves one harness row on purpose. `textDocument/references`
now judges a declaration's cross-file reach on the **hierarchical**
surface (`nav::leaves_this_file` / `indexed_def_in_file` ask
`member_in(…, Surface::Hierarchical)` instead of `member`), so a module's
net, variable or instance — which a `bind` connection or a `u_x.sig`
tail names from another file — is answered workspace-wide instead of
silently in-file. Two costs, both measured on the real opentitan tree:
- **A local net's `references` in a 40 267-line open buffer** now walks
the indexed path (two map probes plus the name-prefiltered pass over
open buffers) instead of returning the in-file answer directly:
**1.22 → 1.54 ms median** (QA, throwaway worktree at 9d1eb16 for the
before). Accepted: the gate still saves the walk for every name the
index holds nowhere.
- **A cross-file request into a *closed* declaring file** (the shape that
used to answer incompletely) parses exactly that file once, fresh from
disk: 0.1–0.2 ms → **0.4–1.5 ms** on `state_q` from
`entropy_src_core.sv` with `entropy_src_main_sm.sv` shut — the price
of the in-file uses that answer used to omit. The index deliberately
posts no `Local` reference for a hierarchical-only member (the §49
ruling: a reference table sized by every RTL body for a rarely-asked
answer), so the one-file re-analysis is the same trade the rename
already makes.
Every connection-surface row of the `nav` harness is unchanged in result
count and within noise in time (`aes` 14 locations / 9 files, `.clk_i`
12 / 9). Every closed-file span is now guarded by `hover::spells_exactly`
before it is rendered — one slice compare per location, unmeasurable —
so a stale index can omit a location but never point at a wrong line
(QA findings 1–4). `docs/features/references-hierarchical-surface/README.md`.
+5 -4
View File
@@ -221,7 +221,7 @@ incremental update and `fingerprint`, `record` = the `FileFacts` read-off,
inheritance edge tables, incremental `update_file`/`remove_file`,
reference postings, `files_spelling`, batch `absorb`, declaration `DeclLines`,
`fingerprint`); `facts.rs` (`FileFacts` codec for the persistent cache;
`FACTS_FORMAT` is **19**);
`FACTS_FORMAT` is **20**);
`instantiations.rs`, `classes.rs` (the shared walks, lifted from the server
so the index census and the request handlers cannot drift); `imports.rs`
(`import_usage`, `import_scopes`, `unused_imports`, `Exports`, `PackageExports`)
@@ -569,6 +569,7 @@ promise:
| `constraint-bodies ◀──▶ class-semantics / class-member-access / index-persistence / semantic-lints` | handshake | **`FACTS_FORMAT` 10 → 11** (2026-09-02): `SymbolKind::Constraint` declared in the class scope (a stand-in `Class` scope for `constraint C::c`, the out-of-body-method mechanism reused); the body opens a scope under the class so every operand binds to the class's properties — rename from a `rand` field's declaration now rewrites its constraint uses, in-file and cross-file; `foreach` vars nest; `Target::InlineConstraint` resolves a `randomize() with { … }` operand against the randomized object's class first and the writing scope second. `Constraint` exported from `Class`. `signals.rs` reads constraint operands instead of routing the body to `opaque_spans` (a constraint reads, never drives). Corpus references +1 646, 84 % answered. Filed: a rename issued *from inside* an out-of-block constraint body whose class is elsewhere is refused by `vlog_refactor` (pre-existing — the same refusal `task C::m` bodies get). |
| `covergroup-bodies ◀──▶ class-semantics / class-member-access / index-persistence / semantic-lints` | handshake | **`FACTS_FORMAT` 11 → 12** (2026-09-02): `SymbolKind::{Covergroup, Coverpoint, Cross}` and `ScopeKind::Covergroup`; the covergroup opens a scope whose labelled coverpoints and crosses are symbols (an unlabelled coverpoint declares nothing), `sample()`/`(args)` parameters are visible in the body and nowhere else, every sampled expression, bin value and `iff` binds to the enclosing class's properties. `collect_members` recurses into a covergroup so `cg_inst.cp` resolves cross-file; `member_scope` accepts a `Covergroup` symbol. `signals.rs` reads coverpoint operands (a covergroup samples, never drives). Corpus references +1 139 with 1 135 answered. |
| `semantic-lints-on ◀──▶ workspace-index / index-persistence / linter-core / semantic-lints / completion-core / editor-settings` | handshake | **`FACTS_FORMAT` 12 → 13** (2026-09-02): `FileFacts::words`, a per-file sorted dedup'd identifier census from the token stream (macro/directive words included, comments and strings excluded by construction) — the one harvest `vlog_semantic::words` provides, which the server's completion word table is now built from instead of re-lexing every file at startup (scan −28 %). No inverted index: `files_mentioning`/`mentioned_outside` are a linear walk with a binary search per file, `files_spelling`'s own shape. `vlog_linter` gains `MentionOracle` (`LintContext::with_oracle`) and `Rule::needs_workspace()` + `workspace_rules()` beside an unchanged `default_rules()`: `unused-signal` and `undriven-net` say nothing when the oracle says the name is mentioned in another indexed file (the false-negative-safe direction), `multiply-driven` shares the gate but never reads it; the three are on whenever an oracle exists — the server always, the CLI when a multi-file job set is walked (a harvest pre-pass, +36 ms on the corpus over 10 cores, zero when the rules are ignored) — and off for a single file or stdin. The off switch shipped with it (§2.9-4). Store +14 % measured on both corpora; opentitan with the rules on reports 14 findings, spot-checked true. Filed: quick fixes ignore `lucisv.lint.*` (`code_action.rs`). |
| `rename-bind-occurrences ◀──▶ workspace-index / index-persistence / bind-semantics / refactor-rename` | handshake | **`FACTS_FORMAT` 19 → 20** (2026-09-11, TODO §63.1): no new field, a different answer in the same fields. A `bind` connection's expression half is a reference on the target's **hierarchical** surface under the `target::name` path (`resolve::in_bind_target` asked the connection surface — ports and parameters — so an internal net such as `bind aes chk u (.req(entropy_masking_req))` resolved to nothing and, with no name on the path, was never warned about); a hierarchical path in a bind connection is rooted at the bind target (`Target::BindMember { target, head, mids }`, one more arm of the `use_member` funnel, walking `descend`/`member_at` shared with `member_of`), and a multi-segment target (`bind tb.u_aes …`) is spelled `tb::u_aes` so `follow_one` folds it hop by hop. So definition, hover, references and rename answer over bind files where they answered nothing; `rename_preflight` refuses strictly less (a bind tail was `NOTHING_HERE`, now an external candidate it defers). A 0.53.0 store rebuilds once. Selection (`rename_sources_traced`'s `Reference` rung, `module_select.rs`) was never the gap; §2.9-33 stands. Known remainder: `nav.rs`'s `leaves_this_file`/`indexed_def_in_file` still ask the connection surface, so cross-file `references` misses hierarchical-surface-only declarations, bind or not (TODO loop-3 list). |
| `define-table ◀──▶ macro-expansion` | handshake | What began as free-to-change became contract at M14: params stored **as written**, `NAME()` = `Some(vec![])` — `expand.rs` counts arguments against them and declines on mismatch. |
### 2.6 Refactor lane (the M-plan)
@@ -620,14 +621,14 @@ engine-lane features are listed above; this table is the server-internal web.
| `hover-line-index ──▶ hover-declarations / port-detail-spans` | depends | `Def::lines` supplies indexed hover headings (including split-port detail lines); `Workspace::file_view` supplies the guarded snippet and the few non-indexed line lookups. `locate::location` shares that view, so a references list reads a closed file once rather than once per site. |
| `cancel-request ──▶ lsp-server pin` | depends | See §1.2; queue/burst exists because the pinned transport is a rendezvous channel. |
| `scan-interleave ──▶ cancel-request / work-done-progress` | depends | The same queue is polled between startup-scan files. `publish_scan` lands the index, completion and include batches before dispatch; `must_wait` holds requests queued behind any rescan-triggering message and preserves their order/cancels. Progress still counts the whole scan even when requests are answered before the bar comes down. |
| `verbose-timing ◀──▶ editor-packaging / scan-interleave / change-debounce` | handshake | `lucisv.verbose` is an extension-owned spawn setting: false means no arguments and no timing traffic; true means `lucisv-server --verbose`, and changing it restarts the client process. The server writes `MessageType::LOG` lines prefixed `timing:` for request/notification handlers, scan and widen lifecycles, dirty-buffer flushes, one-file reindexes, and requests held behind rescans. The request line precedes its response; notification lines follow their work. Instrumentation is silent by construction when off (one branch, no clock read or formatting), and it observes rather than changes scan/queue ordering. **Amended by perf5-p2 and perf5-p4 (2026-09-07/08):** the `timing: rename trace …` line and the three `timing: scan <n> … : key=value …` lines (`stages`, `counts`, `memory`) plus `timing: configuration answered in X ms` are `key=value` formatted and **are parsed** by `tools/perf/` (`renametrace`, `scanprofile`); their format is pinned by server tests, so the old "nobody parses these lines" assumption no longer holds for those five. `Workspace::begin_scan`/`begin_widen` take `trace: bool` (every pre-existing caller passes `false`), `take_scan_trace()` hands the finished trace to the server; `Candidates::sizes()`, `IncludeGraph::sizes()`, `IndexCache::{work, entry_count, encoded_bytes}` are read-only queries for the memory line; `Server::born` and the `Instant` on `Pending::Configuration` time the config round trip. |
| `verbose-timing ◀──▶ editor-packaging / scan-interleave / change-debounce` | handshake | `lucisv.verbose` is an extension-owned spawn setting: false means no arguments and no timing traffic; true means `lucisv-server --verbose`, and changing it restarts the client process. The server writes `MessageType::LOG` lines prefixed `timing:` for request/notification handlers, scan and widen lifecycles, dirty-buffer flushes, one-file reindexes, and requests held behind rescans. The request line precedes its response; notification lines follow their work. Instrumentation is silent by construction when off (one branch, no clock read or formatting), and it observes rather than changes scan/queue ordering. **Amended by perf5-p2 and perf5-p4 (2026-09-07/08):** the `timing: rename trace …` line and the three `timing: scan <n> … : key=value …` lines (`stages`, `counts`, `memory`) plus `timing: configuration answered in X ms` are `key=value` formatted and **are parsed** by `tools/perf/` (`renametrace`, `scanprofile`); their format is pinned by server tests, so the old "nobody parses these lines" assumption no longer holds for those five. `Workspace::begin_scan`/`begin_widen` take `trace: bool` (every pre-existing caller passes `false`), `take_scan_trace()` hands the finished trace to the server; `Candidates::sizes()`, `IncludeGraph::sizes()`, `IndexCache::{work, entry_count, encoded_bytes}` are read-only queries for the memory line; `Server::born` and the `Instant` on `Pending::Configuration` time the config round trip. **(2026-09-12, TODO §63.2)** the `timing: codeaction` line carries a third top-level group, `rebuild{lex parse defines analyze external lines publish documents}` — `Document::new`'s six derivations and the publish inside `flush_dirty`, traced through `crate::lint_trace` — beside `flush{…}` and `action{…}`; the three groups are **siblings by contract** (`tools/perf/phases_p2.py`'s regex flattens one level, and a nested group makes the whole `flush` group vanish from every row with no error), pinned by `lint_trace::tests::the_three_top_level_groups_are_flat_never_nested`. |
| `work-done-progress ──▶ indexing-ux` | depends (then) | w-d-p put up the bar; indexing-ux made it count (`IndexEvent` stream); index-persistence added `Cached`. |
| `large-file-mode ◀──▶ semantic-tokens-delta` | handshake | The windowed lexing serves `semanticTokens/range`; on a large buffer `full`/`full/delta` must answer an ERROR (`ServerCancelled`/`ContentModified`) or the client stops asking the range provider — two sides pinning one wire behavior. `Document::large` is structurally a full `Document` (all fields valid, empty) so no handler changes — the obligation lands on **future** handlers that read `doc.text` (dispatch-table test enforces). |
| `lsp-318-extras ──▶ range-formatting` | depends | `rangesFormatting` is a thin adapter over the same n-range `LineRanges` engine `--lines` uses; hand-rolled params because `lsp-types` 0.97 lacks 3.18. |
| `on-type-formatting ──▶ range-formatting, editor-scopes` | depends | `;` goes through `format::range_formatting` unchanged; `\n` answers indent only, computed from `pairs.rs`'s own keyword tables (three items widened to `pub(crate)`) — one reader's answer for "what opens a scope". |
| `interactive-latency ──▶ change-debounce, editor-scopes, selection-range, on-type-formatting, completion-core, inline-templates` | depends | Round 2 of the perf work (`docs/perf/README.md`). It measures the flush change-debounce coalesces and the round trip it defers, and it replaces one token *sweep* with one token *binary search* in `selection.rs`, `on_type.rs`, `completion.rs` and `inline.rs`. No answer moved — each swap is pinned against the sweep it replaced at every byte — so none of those five features' contracts changed; what they now share is `state.rs`'s two search primitives and the ordering property of `tokenize`'s output they rest on. |
| `interactive-latency ◀──▶ lucisv-server` | handshake | Two free functions, `first_token_reaching` and `first_token_from`, are published from `state.rs` beside `Document::token_at`; that is where the monotonicity argument every caller depends on is written down, and `state::tests::the_token_stream_rises_and_never_overlaps` is the test that fails first if `vlog_parser` ever breaks it. `tests/e2e.rs`'s `Live::finish` now returns its publish count (existing callers ignore it), and `perf::generated_module` has a copy in `tests/e2e.rs` — a binary crate's modules are unreachable from an integration test — which must stay the same shape as the original. |
| `references-nav ──▶ workspace-index / hover-line-index` | depends | Cross-file references resolve an indexed target first and consume declaration postings directly; same-file local references stay on `Semantics`. Locations use the shared `FileView`. `documentHighlight` now also follows the document's external overlay for names declared elsewhere, fixing the old “references works, highlight is empty” split without widening highlights beyond the current file. |
| `references-nav ──▶ workspace-index / hover-line-index` | depends | Cross-file references resolve an indexed target first and consume declaration postings directly; same-file local references stay on `Semantics`. Since §64.1 (2026-09-12) the two index questions (`leaves_this_file`, `indexed_def_in_file`) ask `member_in(…, Surface::Hierarchical)`, so a module's net/variable/instance named by a `bind` connection or a `u_x.sig` tail is answered workspace-wide; a hierarchical-only declaration in a *closed* file has no `Local` postings, so `nav::declaring_file_uses` parses exactly that file once per request. Every closed-file span and the open-buffer declaration fallback are guarded by `hover::spells_exactly` (now `pub(crate)`): a stale index may omit a location, never mislocate one. Locations for closed files are rendered from one `text_of` read per file per request (not the `FileView` cache, whose entry could differ from the same request's re-analysis). `documentHighlight` now also follows the document's external overlay for names declared elsewhere, fixing the old “references works, highlight is empty” split without widening highlights beyond the current file. |
| `selection-range / linked-editing ──▶ spans, name-spans` | depends | Pure arrangements of existing ranges; linked-editing's table documents exactly which constructs carry both spans (and which verbatim ones can't — `program`, property/sequence, covergroup). |
| `type-definition ──▶ nav / overlay-promotion / ansi-first-port` | depends + 2 delivered handshakes | Now literally `nav::definition` at the type name's offset; both of its filed requests landed (§2.2, §2.5). |
| `hierarchy ◀──▶ inlay-hints` | handshake (shared walk) | The instantiation walk was lifted out of `inlay.rs` into a shared module (now `vlog_semantic::instantiations`) rather than copied — the two answers cannot drift; inlay's 34 tests are the regression net. |
@@ -803,7 +804,7 @@ ownership explicitly.
| `vlog_formatter/src/fence.rs` | format-fences | range-formatting, shared-fence-filter, CLI `--fix` (`lucisv/src/lint.rs`), server quick fixes (`lucisv_server/src/lint.rs`) | `protected_regions`/`is_protected` are the **only** supported way to ask "may an automatic edit touch these bytes". One answer, **two** front ends — and `vlog_linter` is deliberately not one of them (it stays fence-blind; the filter lives in each front end). Class and statement scopes are supported by statement-fences (§2.9-3 delivered); `range::plan` must merge these protected spans with unselected runs. Port and case-label lists remain outside independent fence scopes. |
| `lucisv_server/src/pairs.rs` | editor-scopes | documentHighlight, missing-closer diagnostics, scopePairs rainbow, folding, completion gates, on-type indent, inline-templates, expand-selection (`selection.rs`) | The `RULES` table + no-closer guard list is shared truth. Any keyword added to/removed from `token.rs` requires re-checking it (a word that stops being a keyword silently stops being matched). |
| `lucisv_server/src/server/` | lucisv-server; amended by cancel-request, change-debounce, scan-interleave, index-scope, verbose-timing | every request/notification and every rebuild trigger | One ordered loop owns all mutable server state. A startup scan may publish a prefix and answer queued work between files; a request queued behind a rescan trigger is held until that rescan lands, and its cancel travels with it. Never make the distinction time-based: machine load must not change which index a request sees. Verbose timing may observe each wrapper/lifecycle but must be entirely silent when off and must not move protocol ordering. The queue thread only forwards protocol messages and must never parse. |
| `lucisv_server/src/state.rs` | lucisv-server; amended by filelist, index-scope, scan-interleave, indexing-ux, incremental-index, index-persistence, hover-line-index, large-file-mode, one-parse (`Document.tree`), editor-settings + folders-and-config (`set_client_settings`/`change_roots`), include-nav (the include graph), completion-core (candidates), file-watching, interactive-latency (`first_token_reaching`/`first_token_from`), refactor performance fan-outs | every handler | `Workspace` is immutable through request handlers except the interior-mutable four-entry/8 MiB `FileView` cache. The scope ladder (filelist > `index.scope: "workspace"` > folder-scope at shipped depth 2; a rootless session never climbs; it reads flat at depth 0 and walks descendants at positive depth (including the default 2)) and open-buffer overlay are contracts. `Scan` has whole/widen shapes but one step/finish path; index/candidate/include prefixes publish together. `module_sources`, `rename_sources`, and `include_sources` must remain supersets of what their engines can edit/refuse over; `rename_sources` falls back to `sources()` when an ambiguous posting prevents a proven bound. `update_one` and a completed scan must equal a fresh build (`fingerprint`). Handlers reading `doc.text` instead of tokens/tree must check `doc.large`. |
| `lucisv_server/src/state.rs` | lucisv-server; amended by filelist, index-scope, scan-interleave, indexing-ux, incremental-index, index-persistence, hover-line-index, large-file-mode, one-parse (`Document.tree`), editor-settings + folders-and-config (`set_client_settings`/`change_roots`), include-nav (the include graph), completion-core (candidates), file-watching, interactive-latency (`first_token_reaching`/`first_token_from`), refactor performance fan-outs | every handler | `Workspace` is immutable through request handlers except the interior-mutable four-entry/8 MiB `FileView` cache. The scope ladder (filelist > `index.scope: "workspace"` > folder-scope at shipped depth 2; a rootless session never climbs; it reads flat at depth 0 and walks descendants at positive depth (including the default 2)) and open-buffer overlay are contracts. `Scan` has whole/widen shapes but one step/finish path; index/candidate/include prefixes publish together. `module_sources`, `rename_sources`, and `include_sources` must remain supersets of what their engines can edit/refuse over; `rename_sources` falls back to `sources()` when an ambiguous posting prevents a proven bound. `update_one` and a completed scan must equal a fresh build (`fingerprint`). Handlers reading `doc.text` instead of tokens/tree must check `doc.large`. **(2026-09-12)** `Document::new`'s derivations are individually traced (`lint_trace::Rebuild`), so a stage added to or removed from that constructor wants a `Rebuild` variant beside it. |
| `lucisv_server/src/settings.rs` | editor-settings | folders-and-config, indexing-ux, index-scope, index-persistence, inline-templates, will-save-wait-until, filelist, large-file-mode | One parser for both doors (push and pull, via `from_section` re-wrapping). Every key drops garbage independently; defaults that are not "silence" (1 MiB cap, log on, persist on, 4 MiB large-file threshold) are hand-written in `Default`. `set_client_settings` returns whether a reindex is owed — new keys must decide that question explicitly. |
| `vlog_semantic/src/workspace/` (+ `facts.rs`) | workspace-index; extended by incremental-index, index-persistence, index-scope, hover-line-index, scan-interleave, member semantics, semantic-lints-on, bind-semantics, SVA bodies and refactor-rename performance | server state, hierarchy/lens/type-hierarchy, refactor, completion, semantic lints | Determinism (same inputs → same index, any order), the `paths` spelling coupling with `resolve.rs`, `FACTS_FORMAT` bumped on any codec change (current 19), edge/posting tables built by the same lifted walks the engines use. `DeclLines` must round-trip and participate in `fingerprint`; `absorb` must equal one build over the resulting record set; `files_spelling` must continue to include unresolved non-empty external/inherited paths or rename loses its dangling-use refusal; `FileFacts::words` is the shared project mention/completion census. |
| `vlog_refactor/src/rename/` | refactor-rename; shared by references-nav and the performance wave | server rename/prepareRename/references and port refactor verification | `Scope` remains the whole-scope authority and `collect_occurrences` the one rename/references walk. The fast `prepare_rename_here` answer/refusal and `rename_name_at` target are parity contracts, not alternate semantics. Any new refusal must be expressible on the fast path or force a deferral; any new occurrence shape must be reflected in the server fan-out or trigger its all-sources fallback. |
+21
View File
@@ -5,6 +5,27 @@ for you. The extension and its bundled language server share one version
number; the full engineering notes live in the
[project changelog](https://git.luci.ooo/lucio/lucisv/src/branch/master/CHANGELOG.md).
## 0.55.0 — 2026-09-17
- Find All References on a module's internal signal now lists every use
in other files — a `bind` connection or a `u_x.sig` hierarchical path
— from the declaration or from any use, and includes the declaring
file's own uses even when that file is not open. Hover shows the live
declaration line for such signals too.
- When a file changed on disk behind the editor's back, a reference
that no longer sits where the index remembers it is left out rather
than reported on the wrong line.
## 0.54.0 — 2026-09-12
- Rename now edits the `bind` files that name the renamed signal — bare
in a connection or through a hierarchical path — and warns about any
bind occurrence it cannot resolve instead of staying silent. Go to
definition, hover and references answer over bind files too. The index
rebuilds once after the update.
- The first code-action menu after an edit in a very large file is about
a fifth faster; nothing about the answers changed.
## 0.53.0 — 2026-09-09
- A workspace with a symlinked directory alias no longer shows two
+14 -1
View File
@@ -30,7 +30,7 @@ Install **lucisv — Verilog/SystemVerilog** from the VS Code Extensions view,
then open a Verilog or SystemVerilog file. There is no separate server or CLI
setup.
The current release is **0.53.0**. Its platform packages include both
The current release is **0.55.0**. Its platform packages include both
`lucisv-server` and the `lucisv` command-line tool:
| Package target | Machines |
@@ -374,6 +374,19 @@ Every nesting color is a proper VS Code theme color:
}
```
## Release 0.55.0 highlights
Version 0.55.0 makes Find All References see every cross-file use of a
module's internal signals — a `bind` connection or a `u_x.sig` path in
another file — and guarantees a stale index can omit a location but
never point at the wrong line.
## Release 0.54.0 highlights
Version 0.54.0 makes rename edit `bind` files (or warn, never stay
silent) and cuts the first request after an edit in a very large file by
about a fifth.
## Release 0.53.0 highlights
Version 0.53.0 fixes the startup scan indexing a symlink-aliased
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "lucisv",
"displayName": "lucisv — Verilog/SystemVerilog",
"description": "Fast Verilog/SystemVerilog formatting, linting, navigation, refactoring, semantic highlighting and RTL design intelligence.",
"version": "0.53.0",
"version": "0.55.0",
"publisher": "guoliangchen",
"author": "Guoliang Chen",
"license": "MIT",
+1 -1
View File
@@ -88,7 +88,7 @@ apart in `results.jsonl`; run each phase once per binary.
| `scanprofile` | §P4a | the startup breakdown, from the server's own `timing: scan <n> stages/counts/memory` lines: workspace cold and warm, the default scope, `scopeDepth 0`, and 1 / 10 / 100 open buffers. **One row per traced scan** — a session at a configured scope pays two (the startup scan runs at the default settings and the pulled scope asks for another), and adding them together would be wrong |
| `scanwait` | §P4a | §P0's first-useful-answer rows, re-run under `--verbose`, so the trace of the very session that answered sits in the row: when the first publish landed, how many publishes there were, how long the config round trip took |
| `scanserve` | §P4a | a `textDocument/definition` every 200 ms for as long as the scan is still saying anything: the mid-scan latency distribution, and `mismatched_answers` — non-empty answers that named somewhere the settled index does not, which must be 0 (the coherence contract of `docs/features/index-scope/README.md`) |
| `actionprofile` | §R1b | one `--verbose` session per cursor, four request shapes each — the first menu of the session, three repeats on the unchanged buffer, a definition queued behind it, and the first menu after each of three `didChange`s — with the server's own `timing: codeaction …` line parsed into `trace_*` fields. Two groups per line: `flush{…}` is the debounced `Document` rebuild and the diagnostics publish inside it, `action{…}` is the handler. A request that lints nothing logs no line, which is why the queued rows say how many the follower logged |
| `actionprofile` | §R1b | one `--verbose` session per cursor, four request shapes each — the first menu of the session, three repeats on the unchanged buffer, a definition queued behind it, and the first menu after each of three `didChange`s — with the server's own `timing: codeaction …` line parsed into `trace_*` fields. **Three** groups per line: `flush{…}` is the debounced `Document` rebuild and the diagnostics publish inside it, `rebuild{…}` splits that rebuild into the stages `Document::new` runs — `lex`, `parse`, `defines`, `analyze`, `external`, `lines` — plus the `publish` the flush does with the result and the `documents` it built (TODO §63.2), and `action{…}` is the handler. The groups are **siblings, never nested**: `phases_p2.parse_trace` flattens one level of `name{…}`, which is how all three arrive as `trace_flush_*` / `trace_rebuild_*` / `trace_action_*` row fields with no parser change. A request that lints nothing logs no line, which is why the queued rows say how many the follower logged |
| `ruleablation` | §R1b | *which* rules the pinmux quickfix menu's milliseconds are in: one warm session, `lucisv.lint.select` pushed to a single rule per row by `didChangeConfiguration` (a selection change rescans nothing), the unrestricted control taken first **and** last so session drift is visible rather than blamed on a rule |
| `snapshotrss` | §R1a | idle and peak RSS with 1 / 10 / 100 open buffers, each sent one quickfix-only `codeAction` so that every open document holds a lint snapshot — the memory bound of `docs/features/perf5r-lint-snapshot/README.md`. `rss_kib` / `peak_rss_kib`, never `ms` |
| `renamewarn` | §R3b | every `lucisv: ` warning sentence four renames say, in order, written into the row as `titles` and compared **line by line** between labels. `renametrace` hashes a rename's edits; its warnings are `window/logMessage` notifications and are in no fingerprint, so a reuse that kept every edit and dropped a sentence would otherwise pass |
+8
View File
@@ -102,6 +102,14 @@ RENAMES = [
sites.AES_CORE, "cipher_alert;", 1, 0, "clk_i", None),
("duplicate module: rstmgr_por -> rstmgr_por_x",
sites.RSTMGR, "rstmgr_por ", 1, 0, "rstmgr_por_x", None),
# TODO §63.1's shape: a net declared in `aes.sv` whose only other
# occurrence is the expression half of a `bind aes …` connection, in a
# file that instantiates nothing in the chain. Before 0.54.0 that
# occurrence was neither edited nor warned about, so this row's edit
# count is what the lane changed.
("bind: entropy_masking_req -> masking_req_x",
sites.AES, "entropy_clearing_req, entropy_masking_req;", 1,
len("entropy_clearing_req, "), "masking_req_x", sites.AES_BIND),
]
+1 -1
View File
@@ -25,7 +25,7 @@ from harness import ARGS, at, phase, record, samples, session, settled, sites
#: `(row, file, needle, occurrence, offset, new_name, also_open)` — the renames
#: that produce warnings, plus one that produces none as the control. Taken
#: from `phases_p2.RENAMES` so the two phases speak about the same requests.
WARNED = ["tail", "ordinary", "unique internal", "common port"]
WARNED = ["tail", "ordinary", "unique internal", "common port", "bind"]
@phase("renamewarn")