Skip to content

Duplicate "remove unnecessary parentheses" code action #15801

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

Closed
oriongonza opened this issue Oct 25, 2023 · 5 comments
Closed

Duplicate "remove unnecessary parentheses" code action #15801

oriongonza opened this issue Oct 25, 2023 · 5 comments
Labels
C-bug Category: bug

Comments

@oriongonza
Copy link

if (true) {}

image

rust-analyzer version: 2023-10-16
rustc version: rustc 1.73.0 (cc66ad468 2023-10-03)

@oriongonza oriongonza added the C-bug Category: bug label Oct 25, 2023
@omertuc
Copy link
Contributor

omertuc commented Nov 7, 2023

One of them is a code assist that rust-analyzer is generating out of the output of a compiler warning (run cargo check and you'll see the string "remove these parentheses" in the warning, rust-analyzer knows how to turn these compiler suggestions into code assists and this is what you see in the code actions list), the other one ("Remove redundant parentheses") is coming from a built-in rust-analyzer assist to remove parenthesis.

The rust-analyzer one is even broken in some cases:

fn main() {
    match(true) {}
}

Becomes:

fn main() {
    matchtrue {}
}

Which is of-course invalid.

Maybe getting rid of the built-in rust-analyzer assist would be a better idea than trying to fix it? I don't know how much the built-in rust-analyzer code-assist and the compiler suggestions overlap in terms of functionality

@lnicola
Copy link
Member

lnicola commented Nov 7, 2023

The built-in diagnostic works on-the-fly, without saving the file. Why should we get rid of it?

@omertuc
Copy link
Contributor

omertuc commented Nov 7, 2023

Good point, haven't thought of that, thought it was simply redundant

@omertuc
Copy link
Contributor

omertuc commented Nov 7, 2023

Created a separate ticket #15844 to address the issue I mentioned

@lnicola
Copy link
Member

lnicola commented Dec 4, 2023

Let's close this, I don't think we can do much else about it.

@lnicola lnicola closed this as completed Dec 4, 2023
@lnicola lnicola closed this as not planned Won't fix, can't repro, duplicate, stale Dec 4, 2023
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

3 participants