Repository navigation
Deduplicate repeated compiler and language-server code - #1637
Merged
Merged
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
sbillig
force-pushed
the
simplify-roi
branch
from
September 29, 2026 19:48
986e747 to
941be77
Compare
sbillig
force-pushed
the
simplify-roi
branch
from
September 29, 2026 19:53
941be77 to
c8220b6
Compare
`diagnostics.rs` spelled out a full `CompleteDiagnostic` literal for every variant, including the 71 whose only label is a primary one with no notes. Those now call the existing `primary_diag` helper, which takes `impl Into<String>` so a `format!` result can be passed without a detour through `&str`.
Every `walk_*` function wrapped its child visit in a braced closure holding one statement, often with a `let` binding used exactly once. Both collapse to an expression closure, so the walk functions now read as a list of child spans rather than a wall of blocks.
`reachable_input` and `reachable_region` carried byte-identical copies of the capability loop: freshen, retarget abstract contract roots, union the region, collect loan parents. The only real difference is that the input path projects through a `RegionPath` first, so that becomes an `Option` argument on a shared `fold_reachable`.
`setup_service` and `setup_ws_service` repeated the same 43-entry handler chain, differing only in which `Initialize` handler they use and whether they observe `FileChange`. The common chain moves into `register_shared_handlers` and the fallback-router wiring into `with_streaming_fallback`, so the two connection kinds can no longer drift apart.
`convert_dependency` spelled out the same "resolve the path inside the checkout, rebuild the git description, report on failure" block three times, once per dependency location, and each of those was duplicated again for the named and unnamed cases. That work moves into `checkout_description`, which reports and yields `None` so callers can use `?`, and `remote_descriptor`, which picks between `RemoteByName` and `Remote`. Each arm now computes a descriptor and shares one recording tail, which takes the function from roughly 200 lines and five levels of nesting to 95 lines and three.
`document_symbols` and `workspace_symbols` each carried their own copy of the item-to-`(SymbolKind, String)` match, so a new item kind had to be added in two places. The named kinds move to `util::named_item_symbol`, which folds the eight near-identical arms into one by pulling the keyword out of the `format!`. `document_symbols` keeps its own arms for `impl` and `impl trait`, the two kinds that have no name of their own and that the workspace handler deliberately skips.
sbillig
force-pushed
the
simplify-roi
branch
from
September 30, 2026 02:53
c8220b6 to
1a3709c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #1636; review that first. Net -756 lines.
Two line-count plays:
hir: single-label diagnostics throughprimary_diag.diagnostics.rsspelled out a fullCompleteDiagnosticliteral forevery variant, including the 71 whose only label is a primary one
with no notes.
primary_diagnow takesimpl Into<String>so aformat!result can be passed without a detour through&str.hir: inline the visitor walk closures. Everywalk_*wrappedits child visit in a braced closure holding one statement, often
with a
letbinding used once. 97 collapse to expression closures,so the walk functions read as a list of child spans.
Four drift-hazard removals, where the duplication meant a change had to
be made in two or more places to be correct:
reachable_inputandreachable_regionheld byte-identicalcapability loops; the only real difference is that one projects
through a
RegionPathfirst.setup_serviceandsetup_ws_servicerepeated the same 43-entry LSPhandler chain, differing only in the
Initializehandler and whetherthey observe
FileChange.convert_dependencyspelled out the same remote-checkout descriptorblock six times. It goes from ~200 lines and five levels of nesting
to 95 and three.
own copy of the item-to-
SymbolKindmatch, so a new item kind had tobe added twice.