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 introduces a \ before the curly braces of functions of a trait #16607

Closed
IceTDrinker opened this issue Feb 19, 2024 · 7 comments · Fixed by #16618
Closed
Labels
C-bug Category: bug

Comments

@IceTDrinker
Copy link

IceTDrinker commented Feb 19, 2024

rust-analyzer version: rust-analyzer version: 0.3.1850-standalone in VSCode

rustc version: rustc 1.78.0-nightly (2bf78d12d 2024-02-18)

relevant settings: nothing notable

/// A trait for types representing distributions.
pub trait Distribution: seal::Sealed + Copy {
    fn required_bytes_count_for_safe_generation<Scalar>(&self) -> usize;
}


impl Distribution for Uniform {
    // Cursor is HERE
}

Quick fix tooltip (ctrl + ; in my case) -> implement missing members

gets me

    fn required_bytes_count_for_safe_generation<Scalar>(&self) -> usize \{
        todo!()
    \}

which the compiler (and rust analyzer) obviously don't like

expected:

    fn required_bytes_count_for_safe_generation<Scalar>(&self) -> usize {
        todo!()
    }

Cheers

@IceTDrinker IceTDrinker added the C-bug Category: bug label Feb 19, 2024
@IceTDrinker
Copy link
Author

Previous version does not have the issue, I've reverted for now because it's not usable enough as is

@Veykril
Copy link
Member

Veykril commented Feb 19, 2024

cc @DropDemBits

@kgiebeler-xq-tec
Copy link

kgiebeler-xq-tec commented Feb 20, 2024

Same happens with "Extract into function". Every generated curly brace gets preceded with a backslash.

Maybe related after a quick peek: 1d8ed34

@franklinblanco
Copy link

Same is happening here, everything gets a \

@c-git
Copy link

c-git commented Feb 20, 2024

Yeah just bumped into this but not in a impl in "Extract into function".

image

@DropDemBits
Copy link
Contributor

The latest vscode nightly extension (0.4.1852-standalone) includes #16475 which fixes } having a \ added before it. Unfortunately it still adds \ before any {, but fixing the latter is a simple change.

bors added a commit that referenced this issue Feb 20, 2024
…-curly, r=Veykril

fix: Don't add `\` before `{`

Fixes #16607 for `{`. The `}` case is already fixed by #16475.

The [LSP snippet grammar](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#snippet_syntax) only specifies that `$`, `}`, and `\` can be escaped with backslashes, but not `{`.
@bors bors closed this as completed in 543d7e9 Feb 20, 2024
@timstr
Copy link

timstr commented Feb 23, 2024

Just encountered this as well in VSCode. Confirming that switching to the current pre-release of the rust-analyzer extension and reloading fixes it.

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

Successfully merging a pull request may close this issue.

7 participants