Skip to content

Commit 942bdd1

Browse files
committed
docs(adr): close the standard-library gap of rust-analyzer in ADR 0018
Records why the workspace's vendored crates.io reached rust-analyzer's query of the standard library, that 1.92.0 has no setting to skip it, and the links in .cs/lsp/rust-library/ that replace it, measured in a workspace from cstudy init.
1 parent adeed7f commit 942bdd1

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎docs/decisions/0018-editor-code-intelligence.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ One server per language, chosen for the documentation it shows, the diagnostics
6868
| Python | basedpyright 1.40.2 | `cstudy doctor --fix`, from npm into `.cs/lsp/` | `python/`, or the project folder | Reads `[tool.pyright]`, so it checks in the workspace's `standard` mode and resolves imports through `python/.venv`, as the workspace's pyright does; hover documents the standard library, which pyright does not |
6969
| TypeScript | typescript-language-server 6.0.3 | The same | `typescript/`, or the project folder | Runs the tsserver of the workspace's own TypeScript (`typescript/node_modules/typescript/lib`), the compiler `--typecheck` runs; automatic type acquisition off |
7070
| Go (phase 3) | gopls, by the selected Go: v0.21.1 on 1.25, v0.23.0 on 1.26, v0.24.0 on 1.27 | `cstudy doctor --fix`: `go install` with `GOBIN=.cs/lsp/bin`, `GOTOOLCHAIN=local` and `GOWORK=off`, online once, again only for a Go that pins another version | `go/`, found through the root `go.work`, or the project folder, through its own `go.work` | `linksInHover` off, and `completeUnimported` off, since completing a package that is not imported adds its import; runs with `GOTOOLCHAIN=local`, `GOPROXY=off`, `GOFLAGS=-mod=readonly` and `CGO_ENABLED=0`, as `cstudy test` builds Go |
71-
| Rust (phase 3) | rust-analyzer from rustup, or any `rust-analyzer` on PATH whose `--version` runs | You: `rustup component add rust-analyzer`. `cstudy doctor --fix` never changes the Rust toolchain, as it never runs `cargo` | `rust/`, or the project folder | `check.allTargets` on and no `--keep-going` of ours; a target directory of its own (`cargo.targetDir` true: `target/rust-analyzer/`), so it never waits for an IDE's `cargo check`; `completion.autoimport.enable` off; `CARGO_NET_OFFLINE=true`; its own diagnostics, such as syntax errors, are pulled as you type, and `cargo check` errors come once the workspace is loaded and after each save |
71+
| Rust (phase 3) | rust-analyzer from rustup, or any `rust-analyzer` on PATH whose `--version` runs | You: `rustup component add rust-analyzer`. `cstudy doctor --fix` never changes the Rust toolchain, as it never runs `cargo` | `rust/`, or the project folder | `check.allTargets` on and no `--keep-going` of ours; a target directory of its own (`cargo.targetDir` true: `target/rust-analyzer/`), so it never waits for an IDE's `cargo check`; the standard library read from links in `.cs/lsp/rust-library/<root>/` (`cargo.sysrootSrc`), out of reach of the workspace's vendored crates.io; `completion.autoimport.enable` off; `CARGO_NET_OFFLINE=true`; its own diagnostics, such as syntax errors, are pulled as you type, and `cargo check` errors come once the workspace is loaded and after each save |
7272
| Java (phase 2) | Eclipse JDT LS 1.63.0, the milestone `jdt-language-server-1.63.0-202610191322.tar.gz` (51.1 MB), checked by SHA-256 | `cstudy doctor --fix`, a download into `.cs/lsp/jdtls/` (52 MB unpacked), whatever JDK is selected, so a JDK installed later needs no network | `jvm/`, or the project folder | Runs on the selected JDK only when it is 25 or 26, since cstudy never searches for another JDK ([ADR 0016](0016-jdk-range.md)); heap capped at 1 GB (`-Xmx1g`, serial collector). The Gradle import runs offline over the warm-up; no Maven import; no build, so no class file lands in a project, and the open documents are checked as they change; the Eclipse files of each project stay out of its folder. A data directory per root and per session, under `.cs/lsp/jdtls-data/<root>/<n>/`, holds its configuration, index and caches; it starts with an empty list of Gradle versions, so its check of the root's Gradle wrapper downloads no checksum, and the settings trust the wrapper cstudy ships. Idle time 5 minutes, since a start imports the build again |
7373
| Kotlin (phase 2) | None: its spike failed ([Phase 2 spikes](#phase-2-spikes)) | | | Kotlin keeps run diagnostics only |
7474

@@ -116,7 +116,7 @@ Run on 2026-11-08, on the maintainer's laptop (arm64 macOS, 18 GiB, swap nearly
116116

117117
| rust-analyzer | Result |
118118
|----------|--------|
119-
| rust-analyzer 1.92.0 (`rustup component add rust-analyzer` on stable 1.92) | On a crate of `rust/`'s shape, with the broker's capabilities: `initialize` 0.16 s; 479 MB resident; `exit` at once. Before its workspace is loaded it answers a pull with an empty report (its default while the file system or the crate graph is not ready), asks for `workspace/diagnostic/refresh` about 1.1 s after `didOpen`, and while the rest of the load runs cancels a pull with `ServerCancelled` (-32802) and `retriggerRequest` true, answered 5.4 s after it was sent in one session, so a client must ask again; the page asks again, waiting 0.5 s, then twice as long each time up to 8 s, at most 8 times. Then its own diagnostics are pulled: a syntax error (`syntax-error`) at once. An unknown function (E0425), an unresolved import (E0432) or an unknown method (E0599) is not among them: `cargo check` reports them, published 1.4 s after `didOpen` (it checks once the workspace is loaded) and 0.2 s after each `didSave`, with rustc's `unused_variables` tagged Unnecessary. `nums.len()` on a `Vec` is defined in `alloc/src/vec/mod.rs` of the toolchain's `rust-src`. In a workspace from `cstudy init`, though, `rust/.cargo/config.toml` replaces crates.io with the runtime's vendored crates, and cargo applies that to the standard library's own workspace too, which rust-analyzer loads with `cargo metadata`: `cfg-if` and the other dependencies of `std` are not found, rust-analyzer loads the standard library without them, and its items (`Vec`, `len`) get no hover, definition or completion, while the file's own items, the pulled syntax errors and `cargo check` work. Open: a way for rust-analyzer to load the standard library that the vendored source does not reach |
119+
| rust-analyzer 1.92.0 (`rustup component add rust-analyzer` on stable 1.92) | On a crate of `rust/`'s shape, with the broker's capabilities: `initialize` 0.16 s; 479 MB resident; `exit` at once. Before its workspace is loaded it answers a pull with an empty report (its default while the file system or the crate graph is not ready), asks for `workspace/diagnostic/refresh` about 1.1 s after `didOpen`, and while the rest of the load runs cancels a pull with `ServerCancelled` (-32802) and `retriggerRequest` true, answered 5.4 s after it was sent in one session, so a client must ask again; the page asks again, waiting 0.5 s, then twice as long each time up to 8 s, at most 8 times. Then its own diagnostics are pulled: a syntax error (`syntax-error`) at once. An unknown function (E0425), an unresolved import (E0432) or an unknown method (E0599) is not among them: `cargo check` reports them, published 1.4 s after `didOpen` (it checks once the workspace is loaded) and 0.2 s after each `didSave`, with rustc's `unused_variables` tagged Unnecessary. `nums.len()` on a `Vec` is defined in `alloc/src/vec/mod.rs` of the toolchain's `rust-src`. In a workspace from `cstudy init`, `rust/.cargo/config.toml` replaces crates.io with the runtime's vendored crates, and cargo applies that to the standard library's own Cargo workspace too, which rust-analyzer loads with `cargo metadata`: `cfg-if` and the other dependencies of `std` are not found, rust-analyzer loads the library without them, and `Vec` or `len` resolve to nothing. rust-analyzer 1.92.0 has no setting that skips that query (its `--print-config-schema` lists `cargo.sysroot` and `cargo.sysrootSrc`, no `sysrootQueryMetadata`), but it reads the library's crates directly when the directory it is given has no `Cargo.toml`. So each session links the library of the toolchain its root selects (`rustc --print sysroot`, run in the root) into `.cs/lsp/rust-library/<root>/`, one link per entry but the manifest and lock, and gives that directory as `cargo.sysrootSrc`, in the initialization options and the `rust-analyzer` section only: `rust/.cargo/config.toml` and the builds of `cstudy test` stay as they are. Measured in a workspace from `cstudy init`: hover on `Vec` and `len` with the standard library's documentation, `len`'s definition in `.cs/lsp/rust-library/rust/alloc/src/vec/mod.rs`, 100 completion items after `nums.` (`len`, `push`, `iter`); 465 MB resident. Without `rustc` or `rust-src` nothing is linked and rust-analyzer looks for the library itself |
120120
| From its source | It always declares a `diagnosticProvider` (identifier `rust-analyzer`); a client that declares `textDocument.diagnostic` gets its own diagnostics by pull, and `workspace/diagnostic/refresh` when they change and after each `cargo check`, while `cargo check`'s diagnostics are still published; a client that does not gets them all published. It tags rustc's `unused_variables`, `unused_imports`, `dead_code` and the other unused lints Unnecessary, and `deprecated` Deprecated (`diagnostics/flycheck_to_proto.rs`) |
121121
| Before | The first spike: hover and definitions into `core/src/slice/mod.rs` at once, `cargo check` errors 3.0 s after `didSave`, 200 MB |
122122

0 commit comments

Comments
 (0)