fix(rust-lsp): keep proc-macro expansion on in Reduced Memory mode (#2598) - #2657
Open
sinelaw wants to merge 1 commit into
Open
fix(rust-lsp): keep proc-macro expansion on in Reduced Memory mode (#2598)#2657sinelaw wants to merge 1 commit into
sinelaw wants to merge 1 commit into
Conversation
…2598) Reduced Memory mode restarted rust-analyzer with `procMacro.enable: false`. rust-analyzer resolves identifiers *inside* a macro invocation's arguments (and the macro name itself) through macro expansion, so disabling proc-macro expansion silently killed hover and Go to Definition for the macro name and everything inside its args — including built-in macros like println!/format!/assert!, which are among the most common cursor positions in real Rust code. This made navigation look randomly broken: F12 worked on a bare call but returned "No definition found" on the identical call one line up inside a println!. Keep procMacro enabled in Reduced mode. Its expansion cost is small next to checkOnSave/cachePriming, and the process limits still cap RAM/CPU. Update the status message and comment to match, mirror the change in the example config, and fix docs/features/lsp.md which referenced a non-existent palette command name ("Switch Rust Analyzer Mode" -> "Rust LSP: Configure Mode"). Verified by driving rust-analyzer over LSP: with the shipped options, Go to Definition inside println! args, on the macro name, and on bare calls all resolve; with procMacro disabled, only the in-macro position comes back empty — pinning the root cause. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014bSc9dVgYMs4C1cbm1p3bx
sinelaw
force-pushed
the
claude/compassionate-newton-dgy212
branch
from
July 17, 2026 11:55
d1f102f to
e12b3e3
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.
Fixes #2598.
Problem
Switching rust-analyzer to Reduced Memory mode ("Rust LSP: Configure Mode" → Reduced Memory) silently killed hover (
Alt+K) and Go to Definition (F12) for:println!), andprintln!(...), or a method call insideformat!(...).F12worked on a bare call but returnedNo definition foundon the identical call one line up that happened to sit inside aprintln!, so the feature looked randomly broken. Positions insideprintln!/format!/assert!args are among the most common cursor positions in real Rust code.Root cause
Reduced Memory mode restarted rust-analyzer with
procMacro.enable: false. rust-analyzer resolves identifiers inside a macro invocation's arguments (and the macro name itself) through macro expansion, so disabling proc-macro expansion takes navigation there down with it — including the built-inprintln!/format!/assert!macros, whose name doesn't obviously imply a proc-macro dependency. The mode's own status even claimed it only disabledcheckOnSave, procMacro, cachePriming, none of which explains losing built-in-macro navigation to a user.I isolated this by driving rust-analyzer directly over LSP against a minimal crate and toggling one option at a time.
procMacro.enable: falseis the sole cause; everything else in the reduced-mode options is fine.Fix
Keep
procMacroenabled in Reduced Memory mode. Its expansion cost is small next tocheckOnSave/cachePriming, and the 50% RAM / 90% CPU process limits still apply, so the mode keeps its memory character while navigation stays intact.Changes:
crates/fresh-editor/plugins/rust-lsp.ts:procMacro.enable: trueinREDUCED_MEMORY_INIT_OPTIONS; comment explains why it must stay on; status message updated (no longer claims procMacro is disabled).crates/fresh-editor/config.example.json: mirror the same change in the sample reduced-memory config.docs/features/lsp.md: fix the palette command name (the doc said "Switch Rust Analyzer Mode"; the real command is Rust LSP: Configure Mode — a discrepancy also noted in the issue) and describe what Reduced Memory mode disables.CHANGELOG.md: bug-fix entry.Validation
Drove rust-analyzer 1.95.0 over LSP against a minimal crate:
println!argprintlnnameThe pre-fix column reproduces exactly the bug from the report; the shipped column shows it fixed. Plugin type-check (
check-types.sh) passes.Notes / out of scope
The issue's secondary observation — a ~30–60 s window after a Reduced-mode restart where all requests return empty while the status reads
ready— stems fromcachePriming.enable: false(no background priming) and is an inherent, documented trade-off of the mode, not part of this navigation bug. Left as-is.🤖 Generated with Claude Code
https://claude.ai/code/session_014bSc9dVgYMs4C1cbm1p3bx
Generated by Claude Code