rust-lang / rust-lang/rust-analyzer

SSR doesn't match function_name($a)

Open
#20,519 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-ssr C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)

Image

rustc version: (eg. output of rustc -V) rustc 1.89.0 (29483883e 2025-08-04)

editor or extension: Reproduced under both neovim and vscode.

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)

repository link (if public, optional): https://github.com/adaszko/rust-analyzer-minrepro

code snippet to reproduce:

use ustr::{Ustr, ustr};

#[derive(Clone, PartialEq)]
pub enum Expr {
    // `--help`
    Terminal(Ustr, Option<Ustr>, usize),
}

fn foo(s: &str) -> Expr {
    Expr::Terminal(ustr(s), None, 0)
}

fn main() {
    use Expr::*;
    let terminal_expr = Terminal(ustr("--color="), None, 0);
    println!("Hello, world!");
    // Terminal(ustr($s), None, 0) ==>> foo($s)
    // Terminal($s, None, 0) ==>> foo($s)
}

Expected behavior: Triggering SSR using rule Terminal(ustr($s), None, 0) ==>> foo($s) should rewrite
let terminal_expr = Terminal(ustr("--color="), None, 0);
to
let terminal_expr = foo("--color=").

Actual behavior: Rule doesn't match the line let terminal_expr = Terminal(ustr("--color="), None, 0);.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the mismatch in the linked rust-analyzer-minrepro repository with the SSR rule shown in the issue. Trace the SSR matching implementation and relevant tests; done means the rule matches Terminal(ustr("--color="), None, 0) and rewrites it to foo("--color=").

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.