Skip to content

RA is now highlighting / analyzing code with async-trait incorrectly... #11533

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
dtzxporter opened this issue Feb 23, 2022 · 3 comments
Closed
Labels
S-unactionable Issue requires feedback, design decisions or is blocked on other work

Comments

@dtzxporter
Copy link

dtzxporter commented Feb 23, 2022

rust-analyzer version: d6ed146 2022-02-22 stable
rustc version: (eg. output of rustc -V) rustc 1.56.0 (09c42c458 2021-10-18)

relevant settings: Default, not modified

A few weeks ago, RA started incorrectly labeling syntax that is wrapped in #[async_trait]

For example, hovering on a trait function:
Screen Shot 2022-02-22 at 6 36 37 PM

Hovering on function brackets (which are now the wrong color):
Screen Shot 2022-02-22 at 7 09 45 PM

Just doing:

#[async_trait]
pub trait Test {
    async fn test(&mut self) {
        panic!("");
    }
}

this used to work properly

@Veykril
Copy link
Member

Veykril commented Feb 23, 2022

This is kind of expected, due to the attribute re-using the spans for its expansion pervasively.

Here is an example of it using the brace tokens span for unreachable_code https://github.com/dtolnay/async-trait/blob/master/src/expand.rs#L369

So hover on those tokens will show all the things the token resolves to after expansion.

Now this is not that ideal here for hover, but I don't think we are able to do much here as resolving these tokens down to the expansion is intentional.

Edit: We could probably sort the hover messages by putting the same thing at the top that the original token covers. Example being a function name is being hovered -> sort all hover messages for function items to the top etc.

@jhgg
Copy link
Contributor

jhgg commented Feb 23, 2022

In the interm however, you can tell rust-analyzer to not expand async-trait via the following config:

{
  "rust-analyzer.procMacro.ignored": {
    "async-trait": ["async_trait"]
  }
}

@lnicola lnicola added the S-unactionable Issue requires feedback, design decisions or is blocked on other work label Mar 1, 2022
@Veykril
Copy link
Member

Veykril commented Nov 11, 2022

We now prefer similar kinded tokens on highlighting and hovering. The async token is still shown wrong as async-trait attaches almost the entire expansion to the async keyword except for the one async keyword usage it has. So that's not an issue on our side.

@Veykril Veykril closed this as completed Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-unactionable Issue requires feedback, design decisions or is blocked on other work
Projects
None yet
Development

No branches or pull requests

4 participants