diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2017-03-10 16:51:13 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-03-10 16:51:13 -0600 |
| commit | 3b7a534d85e6a07ff1a0db7b7e4cfdb02edc528a (patch) | |
| tree | 8d4429abf76faed3777a903923ee4f4bd152642a /src/rustllvm/RustWrapper.cpp | |
| parent | d335c0a09b099a8737e64b043609297457d91db6 (diff) | |
| parent | db35604792fb64efa0a3deaebc0ea0842e19c67a (diff) | |
| download | rust-3b7a534d85e6a07ff1a0db7b7e4cfdb02edc528a.tar.gz rust-3b7a534d85e6a07ff1a0db7b7e4cfdb02edc528a.zip | |
Rollup merge of #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](https://github.com/rust-lang-nursery/rls/issues/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
}
}
]
```
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
