diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-08-08 14:04:28 +0100 |
---|---|---|
committer | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-08-08 14:04:28 +0100 |
commit | 87608904f697a3f58ddb71a7f6828dac80f8b3ce (patch) | |
tree | 11907e37146390bd033a9667995a5e8c9d61a9ed /crates/ra_parser/src | |
parent | de4523fae07a2bf0c058d021bd4cfdb53946c4bf (diff) | |
parent | 6fa2d8214784b6ecfc3fbcd98778d4e58fa8664e (diff) |
Merge #1661
1661: Parse function parameters attributes r=matklad a=eupn
Fixes #1397. The [RFC-2565](https://github.com/rust-lang/rfcs/blob/master/text/2565-formal-function-parameter-attributes.md) specifies `#[attributes]` to function parameters:
```rust
fn foo(#[attr] a, #[unused] b, #[must_use] ...) {
// ...
}
```
This PR adds those attributes into grammar and to the parser, extending corresponding inline tests.
Co-authored-by: Evgenii P <[email protected]>
Diffstat (limited to 'crates/ra_parser/src')
-rw-r--r-- | crates/ra_parser/src/grammar/params.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/crates/ra_parser/src/grammar/params.rs b/crates/ra_parser/src/grammar/params.rs index 723b56343..0b09f1874 100644 --- a/crates/ra_parser/src/grammar/params.rs +++ b/crates/ra_parser/src/grammar/params.rs | |||
@@ -41,9 +41,20 @@ fn list_(p: &mut Parser, flavor: Flavor) { | |||
41 | let m = p.start(); | 41 | let m = p.start(); |
42 | p.bump(); | 42 | p.bump(); |
43 | if flavor.type_required() { | 43 | if flavor.type_required() { |
44 | // test self_param_outer_attr | ||
45 | // fn f(#[must_use] self) {} | ||
46 | attributes::outer_attributes(p); | ||
44 | opt_self_param(p); | 47 | opt_self_param(p); |
45 | } | 48 | } |
46 | while !p.at(EOF) && !p.at(ket) && !(flavor.type_required() && p.at(T![...])) { | 49 | while !p.at(EOF) && !p.at(ket) { |
50 | // test param_outer_arg | ||
51 | // fn f(#[attr1] pat: Type) {} | ||
52 | attributes::outer_attributes(p); | ||
53 | |||
54 | if flavor.type_required() && p.at(T![...]) { | ||
55 | break; | ||
56 | } | ||
57 | |||
47 | if !p.at_ts(VALUE_PARAMETER_FIRST) { | 58 | if !p.at_ts(VALUE_PARAMETER_FIRST) { |
48 | p.error("expected value parameter"); | 59 | p.error("expected value parameter"); |
49 | break; | 60 | break; |