rust-lang / rust-lang/rust-analyzer

Structural Search and Replace (SSR): replacement referred unknown placeholder

Open
#12,914 0 comments 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: 2022-07-25
rustc version: 1.62.1

Code:
use std::ops::Add;
use typenum::{Sum, consts::*};

// <$l as Add<$r>>::Output ==>> typenum::Sum<$l, $r>

pub type Num = <P1 as Add<P2>>::Output;

fn main() {
    println!("Hello, world!");
}
Steps to reproduce:
  1. cargo new sample_text && cd sample_text && cargo add typenum
  2. Open text editor with LSP
  3. Paste this code snippet to src/main.rs
  4. Run code action for commented line with an SSR request
Expected behavior:

Replace

pub type Num = <P1 as Add<P2>>::Output;

with

pub type Num = Sum<P1, P2>;
Observed behavior:

Internal error: replacement referred unknown placeholder $l

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 structural search and replace request on the commented line using the provided sample project. Trace how the replacement referring to $l and $r is interpreted, then verify that the request produces pub type Num = Sum<P1, P2>; instead of the unknown-placeholder error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.