mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
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 <eupn@protonmail.com>
This commit is contained in:
commit
87608904f6
9 changed files with 571 additions and 1 deletions
|
@ -41,9 +41,20 @@ fn list_(p: &mut Parser, flavor: Flavor) {
|
|||
let m = p.start();
|
||||
p.bump();
|
||||
if flavor.type_required() {
|
||||
// test self_param_outer_attr
|
||||
// fn f(#[must_use] self) {}
|
||||
attributes::outer_attributes(p);
|
||||
opt_self_param(p);
|
||||
}
|
||||
while !p.at(EOF) && !p.at(ket) && !(flavor.type_required() && p.at(T![...])) {
|
||||
while !p.at(EOF) && !p.at(ket) {
|
||||
// test param_outer_arg
|
||||
// fn f(#[attr1] pat: Type) {}
|
||||
attributes::outer_attributes(p);
|
||||
|
||||
if flavor.type_required() && p.at(T![...]) {
|
||||
break;
|
||||
}
|
||||
|
||||
if !p.at_ts(VALUE_PARAMETER_FIRST) {
|
||||
p.error("expected value parameter");
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue