forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#39820 - jonasbb:export-attributes, r=nrc
Export attributes in save-analysis data Since this is my first pull-request to rust, I would like to get some feedback about obvious errors in this implementation. I would like to change the save-analysis data to include arbitrary attribute data. A use-case I have in mind for this is identifying functions with `#[test]` annotations such that tools like rls can offer a test-runner feature. I described my idea here [rls#173](rust-lang/rls#173). My changes contain: 1. track a vector of attributes in the various `*Data` types in `data.rs` and `external_data.rs` 2. implement lowering for `Attribute` and `MetaItem` 3. adjust `JsonDumper` to print the attributes In the lowering of `Attribute` I remove the distinction between `MetaItem` and `NestedMetaItem`. I did this because this distinction is somewhat confusing. For example, `NestedMetaItemKind::Literal` has two identical spans, because both `NestedMetaItem` and `Lit` are defined as `Spanned<_>`. My model is strictly more general, as it allows an `LitKind` instead of a `Symbol` for `MetaItem` and `Symbol`s are converted into a cooked string. As a consumer of the save-analysis data this shouldn't affect you much. Example json output of `#[test]` annotation: ``` "attributes": [ { "value": { "name": { "variant": "Str", "fields": [ "test", "Cooked" ] }, "kind": "Literal", "span": { "file_name": "test.rs", "byte_start": 2, "byte_end": 6, "line_start": 1, "line_end": 1, "column_start": 3, "column_end": 7 } }, "span": { "file_name": "test.rs", "byte_start": 0, "byte_end": 7, "line_start": 1, "line_end": 1, "column_start": 1, "column_end": 8 } } ] ```
- Loading branch information
Showing
5 changed files
with
102 additions
and
5 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
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
Oops, something went wrong.