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

DX regression in view macro for rust-analyzer 2024-03-18 (v0.3.1885) and newer #2527

Open
Ar4ys opened this issue Apr 14, 2024 · 5 comments
Open

Comments

@Ar4ys
Copy link
Contributor

Ar4ys commented Apr 14, 2024

In rust-analyzer 2024-03-18 (v0.3.1885) they updated how they handle overlapping spans, which resulted in a degraded DX of #2289 (worse syntax highlighting, hover tooltips, go to definition etc.).

Examples

Note: This is not a full list of regressions

Hover over items used inside view! macro

Working (rust-analyzer 2024-03-11 (v0.3.1877)) Screenshot of working tooltip
Broken (rust-analyzer 2024-03-18 (v0.3.1885)) Screenshot of broken tooltip

Component's syntax highlighting

Working (rust-analyzer 2024-03-11 (v0.3.1877)) Screenshot of working syntax highlighting
Broken (rust-analyzer 2024-03-18 (v0.3.1885)) Screenshot of broken syntax highlighting

Go to definition

Working (rust-analyzer 2024-03-11 (v0.3.1877)) Screenshot of good "go to definition"
Broken (rust-analyzer 2024-03-18 (v0.3.1885)) Screenshot of bad "go to definition"

Temporary workarounds

Until the issue is resolved, users can:

  1. Downgrade to rust-analyzer 2024-03-11 (v0.3.1877)
    • by following official installation guide here and using downloaded rust-analyzer binary in your IDE instead of a bundled one
    • in VSCode users can select "install another version" from the rust-analyzer context menu (thanks @zenlex for suggestion)
  2. Or use latest stable rustc version (rustc 1.78.0 (9b00956e5 2024-04-29) at the time of writing), instead on nightly

Proposed solutions

I see two possible solutions to this issue:

  1. Remove overlapping spans introduced in Fix error reporting in view macro #2289. While this will fix the problem, it will also worsen error reporting in view! macro.
  2. File an issue against rust-analyzer and try to fix the problem upstream.
@jensmeindertsma
Copy link

jensmeindertsma commented Apr 20, 2024

Yeah, I've noticed this as well. Highlighting any part of the view! macro now shows a useless overlay:

|----------------------------------------------------------|
| clippy::needless_borrows_for_generic_args                |
| ---------------------------------------------------------|
| Checks for borrow operations (&) that used as a          |
| generic argument to a function when the borrowed         |
| value could be used.                                     |
|----------------------------------------------------------|

@SeraphyBR
Copy link

I also had the same problem.. I tried some ways to ignore clippy (because when it hovers that's what appears), but I couldn't.

@zenlex
Copy link

zenlex commented Apr 30, 2024

same, didn't have much luck with any allow or config options and it also seemed to bork the syntax highlighting in vscode a tad too - primarily that the Component name lost it's coloration after rust-analyzer finished indexing leptos.

Confirmed that reverting rust-analyzer to https://github.com/rust-lang/rust-analyzer/releases/tag/2024-03-11 addressed both issues. In VSCode you can select "install another version" from the rust-analyzer context menu and not need to manually install any binaries.

@gbj
Copy link
Collaborator

gbj commented May 8, 2024

I don't know the first thing about how rust-analyzer works. Is there a reason to think this was an intentional decision by rust-analyzer, not a bug/regression? If it was an intentional decision to no longer support overlapping spans in this way, then I guess we should revert the changes made in #2289. If not, opening an issue there makes sense and @Ar4ys I'd appreciate it if you could do that, as you know what you're talking about more than I do!

@Ar4ys
Copy link
Contributor Author

Ar4ys commented May 9, 2024

While trying to make a reproduction repository for my issue against rust-analyzer, I found out that DX regressions are not present when using latest stable rustc (rustc 1.78.0 (9b00956e5 2024-04-29) at the time of writing) instead of nightly. I added this as a possible workaround to the current issue.

Still investigating why nightly breaks....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants