Skip to content

Rust LSP Reduced Memory mode: hover and Go to Definition silently fail on macro names and anywhere inside macro invocations (println!/format! args) #2598

Description

@sinelaw

Version: fresh 0.4.3 (built from origin/master @ 4e945b494), rust-analyzer 1.94.1 (rustup component, stable toolchain)

Switching rust-analyzer to Reduced Memory mode via the palette command "Rust LSP: Configure Mode" silently kills hover (Alt+K) and Go to Definition (F12) for:

  • the macro name itself (println!), and
  • any symbol inside a macro invocation's arguments — e.g. a plain user function called inside println!(...), or a method call inside format!(...).

The same positions work in Full mode, and non-macro positions keep working in Reduced mode, so the feature looks randomly broken to a user: F12 works on one call and reports "No definition found" on the identical call two lines up that happens to sit inside a println!. Positions inside println!/format!/assert! args are among the most common cursor positions in real Rust code.

Fresh's own status message for the mode says only: Rust LSP: Reduced Memory mode — checkOnSave, procMacro, cachePriming disabled. println!/format! are built-in (non-proc) macros, so none of those three named restrictions explains losing navigation inside them. No warning or error is surfaced (no [⚠] entry); requests just come back empty.

Steps to reproduce

  1. Create a minimal crate:
    cargo new /tmp/ralsp --name ralsp
    
    src/main.rs:
    fn main() {
        println!("{}", describe());
        let s = describe();
    }
    
    fn describe() -> String {
        "x".to_string()
    }
  2. cd /tmp/ralsp && fresh --no-restore src/main.rs, trust the folder (T), palette → "Start/Restart LSP Server", wait for LSP (on).
  3. Control: cursor on describe in line 2 (inside println! args) → F12 jumps to the definition; Alt+K shows the signature popup. Cursor on describe in line 3 (bare call) → same. Everything works in Full mode.
  4. Palette → "Rust LSP: Configure Mode" → Reduced Memory. Status: LSP (rust) ready | Rust LSP: Reduced Memory mode — checkOnSave, procMacro, cachePriming disabled.
  5. Wait ≥60 s (see note below), then:
    • Cursor on describe inside the println! args → F12.
    • Cursor on println itself → Alt+K.
    • Cursor on describe in the bare let s = describe(); line → F12.

Expected behavior

Reduced Memory mode disables what it says it disables (checkOnSave, procMacro, cachePriming). Hover and Go to Definition on built-in macros and on symbols inside their argument lists keep working — as they do in Fresh's Full mode, and as rust-analyzer does under VS Code with checkOnSave/procMacro.enable/cachePriming turned off. If a mode intentionally degrades core navigation, the mode's description/status should say so.

Actual behavior

In Reduced Memory mode (fully warmed):

  • F12 on a function called inside println!(...) → status No definition found. Reproduced on two separate lines, retried over ~5 minutes after the switch — permanent, not warm-up.
  • Alt+K on the same position → No hover information available (no popup).
  • Alt+K on println itself → No hover information available (Full mode shows the macro docs/signature).
  • F12 on a method call inside format!(...) args → No definition found.
  • Controls in the same session, same mode, seconds apart: F12 on a bare (non-macro) call works; F12 on a struct name in a struct literal works (cross-file); hover on a fn definition line works; hover/def on self works. Only macro-related positions are dead.
  • Switch back to Full mode → the exact failing position works again within seconds of the server restart.

Secondary observation (worsens the experience): after the Reduced-mode restart the status bar immediately reports LSP (rust) ready, but all requests (including non-macro positions) return empty results for roughly 30–60 s on this 8-line crate — presumably the cachePriming-disabled warm-up. During that window the user just sees "No definition found" with a green "ready" status and no progress indication. A full Stop + Start in Reduced mode goes through the same long dead window; Full mode answers within a few seconds of restart.

Workaround

Switch back to Full Mode ("Rust LSP: Configure Mode" → Full Mode) — navigation inside macro args recovers immediately.


Also noticed while testing: docs/features/lsp.md ("Rust LSP Mode Switching") tells users to run "Switch Rust Analyzer Mode", but the actual palette command is named "Rust LSP: Configure Mode" — searching the palette for the documented name finds nothing.

Duplicate-search queries used: reduced memory, rust analyzer mode, println definition macro, "no definition found" — no existing issue covers this (#1797 is the closed missing-binary retry-loop issue; #2197 is pyright request timeouts).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions