Rust Analyzer `Implement missing members` Quick Fix Fails

Hello, I'm using rust-analyzer for VS Code.

I have noticed what seems to be a bug for the rust-analyzer's "Quick Fix" labeled as "Implement missing members."

Bug Description

What is happening is unnecessary back slashes are being added on the curly braces for method blocks during this expansion. I have tried this for many different types of structs and traits, and it always seems that for every curly brace you didn't already include, a backslash is placed before it. This includes the mail impl block's curly braces (if you didn't include them when writing the line on step 3).

Here is a problem expansion example:

struct MyStruct;
impl Default for MyStruct {
    fn default() -> Self \{
        Self \{  \}
    \}
}

Steps for Recreation

Here are my steps for recreation:

  1. Create crate: cargo new bug_test
  2. In src/main.rs, define a struct, lets call it "MyStruct".
  3. Write an incomplete implementation for a trait for the struct. An example using "Default" would be:
    impl Default for MyStruct {}
  4. Hover the cursor to get the quick fix "implement missing members" and select it
    Screenshot_20240221_014431
  5. It should expand to the following:
struct MyStruct;
impl Default for MyStruct {
    fn default() -> Self \{
        Self \{  \}
    \}
}

Misc.

I have also tried restarting and stopping rust-analyzer, reloading the workspace, and rebulding proc-macros with no changes.

This has already been reported and should be fixed with the next release. (In general, bug reports like this are better done on GitHub :slight_smile: )