Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement missing members produces invalid syntax #16985

Closed
jprochazk opened this issue Mar 31, 2024 · 7 comments
Closed

Implement missing members produces invalid syntax #16985

jprochazk opened this issue Mar 31, 2024 · 7 comments
Labels
C-bug Category: bug

Comments

@jprochazk
Copy link
Contributor

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

rustc version: rustc 1.79.0-nightly (8df7e723e 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
@jprochazk jprochazk added the C-bug Category: bug label Mar 31, 2024
@roife
Copy link
Member

roife commented Mar 31, 2024

Are you using nvim?

Might be similar to #16867.

See #16867 (comment).

@jprochazk
Copy link
Contributor Author

I'm using VSCode:

$ code --version
1.83.0
e7e037083ff4455cf320e344325dacb480062c3c
x64

@roife
Copy link
Member

roife commented Mar 31, 2024

What are the versions of your rust-analyzer server (check using rust-analyzer: Show RA version) and client (check in the VSCode extension)?

This issue should have been fixed in #16781 and #16782. I couldn't reproduce this issue on the latest master branch. Maybe you can try upgrading r-a.

@jprochazk
Copy link
Contributor Author

jprochazk commented Mar 31, 2024

I'm running v0.4.1904 of the VSCode extension, I reported the issue after only trying on the latest nightly rust-analyzer (written in OP under rust-analyzer version).

I just built e4a405f (latest master at the time of writing) locally and configured the VSCode extension to use it (via rust-analyzer.server.path in .vscode/settings.json). The notification produced by Show RA Version shows:

rust-analyzer version: 0.0.0 (e4a405f87 2024-03-31)

And the issue persists, same output as in the OP.

@roife
Copy link
Member

roife commented Mar 31, 2024

I still can't reproduce it. I guess it might be related to your rust-analyzer settings? This is very strange.

@jprochazk
Copy link
Contributor Author

jprochazk commented Mar 31, 2024

I can no longer reproduce the issue either... After testing the extension locally (via launch.json in this repo) and confirming that that works, I tried using the bundled version of RA, which worked fine... And then I went back to using the nightly binary (installed via rustup), which also works now. 🤷

@roife
Copy link
Member

roife commented Mar 31, 2024

Restarting and reinstalling always fix everything!🙈

bors added a commit that referenced this issue Apr 1, 2024
update: add editor/extension information to bug report template

When attempting to reproduce issues, I encounter difficulties due to differences in versions of LSP clients and editors (such as #16985, #16867, and more)

This sometimes consumes a lot of efforts from contributors to communicate the details about LSP client information. Therefore, I believe adding editor/extension information to the issue template would be helpful for problem reproduction.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants