Skip to content

Implement missing members produces invalid syntax #16985

@jprochazk

Description

@jprochazk

rust-analyzer version: 1.79.0-nightly (8df7e72 2024-03-30)

rustc version: rustc 1.79.0-nightly (8df7e72 2024-03-30)

code snippet to reproduce:

struct Test {
    value: u32,
}

impl Default for Test {
    // Place cursor here and use the "implement missing members" action
}

The result is:

struct Test {
    value: u32,
}

impl Default for Test {
    fn default() -> Self {
        Self { value: Default::default() \}
    \}
}

The \ characters are syntax errors:

$ cargo check
    Checking ra-backslash-repro v0.1.0 (/home/jp/dev/ra-backslash-repro)
error: unknown start of token: \
  --> src/main.rs:11:42
   |
11 |         Self { value: Default::default() \}
   |                                          ^

error: unknown start of token: \
  --> src/main.rs:12:5
   |
12 |     \}
   |     ^

error: could not compile `ra-backslash-repro` (bin "ra-backslash-repro") due to 2 previous errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions