diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-12-21 08:54:31 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-21 08:54:31 +0000 |
commit | 9bb9fbab3ab603150990ef8f2df12bddc7104058 (patch) | |
tree | 40942ad355497fa78a5851a94ae363189db0b738 /crates/parser/src/grammar/expressions | |
parent | fa75e11eb699d4c959569ab8ab5934ba1ab9bc29 (diff) | |
parent | 64caa027b884b3458997318a01e99812e6bb6fca (diff) |
Merge #6965
6965: Properly attach attributes to Param instead of parent ParamList r=matklad a=Veykril
Fixes #2783, fixes #2781
The problem with `let _a = [0,#[cfg(feature = "L")]0];` has already been fixed some time ago it seems:
<details>
<summary>Syntax Tree for the const item</summary>
```
[email protected]
[email protected] "let"
[email protected] " "
[email protected]
[email protected]
[email protected] "_a"
[email protected] " "
[email protected] "="
[email protected] " "
[email protected]
[email protected] "["
[email protected]
[email protected] "0"
[email protected] ","
[email protected]
[email protected]
[email protected] "#"
[email protected] "["
[email protected]
[email protected]
[email protected]
[email protected] "cfg"
[email protected]
[email protected] "("
[email protected] "feature"
[email protected] " "
[email protected] "="
[email protected] " "
[email protected] "\"L\""
[email protected] ")"
[email protected] "]"
[email protected] "0"
[email protected] "]"
[email protected] ";"
```
</details>
Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/parser/src/grammar/expressions')
-rw-r--r-- | crates/parser/src/grammar/expressions/atom.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/crates/parser/src/grammar/expressions/atom.rs b/crates/parser/src/grammar/expressions/atom.rs index 18b63feb7..e897d5a52 100644 --- a/crates/parser/src/grammar/expressions/atom.rs +++ b/crates/parser/src/grammar/expressions/atom.rs | |||
@@ -156,11 +156,13 @@ fn tuple_expr(p: &mut Parser) -> CompletedMarker { | |||
156 | let mut saw_expr = false; | 156 | let mut saw_expr = false; |
157 | while !p.at(EOF) && !p.at(T![')']) { | 157 | while !p.at(EOF) && !p.at(T![')']) { |
158 | saw_expr = true; | 158 | saw_expr = true; |
159 | if !p.at_ts(EXPR_FIRST) { | 159 | |
160 | p.error("expected expression"); | 160 | // test tuple_attrs |
161 | // const A: (i64, i64) = (1, #[cfg(test)] 2); | ||
162 | if !expr_with_attrs(p) { | ||
161 | break; | 163 | break; |
162 | } | 164 | } |
163 | expr(p); | 165 | |
164 | if !p.at(T![')']) { | 166 | if !p.at(T![')']) { |
165 | saw_comma = true; | 167 | saw_comma = true; |
166 | p.expect(T![,]); | 168 | p.expect(T![,]); |