Commit ea04951
committed
parser: suggest quotes only for ident attribute values
When encountering code like:
```
#[cfg(key = ["foo", "bar"])]
fn main() {}
```
the parser incorrectly suggests:
```
error: expected unsuffixed literal, found `[`
--> ../pg/src/main.rs:1:13
|
1 | #[cfg(key = ["foo", "bar"])]
| ^
|
help: surround the identifier with quotation marks to parse it as a string
|
1 | #[cfg(key =" "["foo", "bar"])]
| + +
error: aborting due to 1 previous error
```
This commit modifies the parser to check if an attribute value is an
ident before suggesting.1 parent fcc06c8 commit ea04951
File tree
3 files changed
+36
-1
lines changed- compiler/rustc_parse/src/parser
- tests/ui/attributes
3 files changed
+36
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
415 | | - | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
416 | 419 | | |
417 | 420 | | |
418 | 421 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
0 commit comments