-
Notifications
You must be signed in to change notification settings - Fork 727
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
attributes: speculative expand when parsing fails (#1634)
## Motivation Recent `rust-analyzer` versions enabled automatic expansion of proc macro attributes by default. This is a problem with `#[instrument]`, because it currently produces a `compile_error!` when parsing the code inside the `#[instrument]`ed function fails, and *discards* those tokens. This means that if the `#[instrument]` attribute is placed on a function whose implementation fails to parse, recent versions of `rust-analyzer` will no longer be able to display diagnostics for those errors. In some cases, this can also break autocompletion. ## Solution This branch changes `#[instrument]` to always expand to the tokens contained in the `#[instrument]`ed function body, regardless of whether or not they could be parsed successfully. Now, an error is only emitted when the `#[instrument]` attribute *itself* could not be parsed. Since the instrumented function is always expanded, any errors within that function can be displayed properly by `rust-analyzer`. Fixes #1633.
- Loading branch information
Showing
2 changed files
with
117 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters