Skip to content

Commit 2280d59

Browse files
petrochenkovpietroalbini
authored andcommitted
Accept trailing comma in cfg_attr
1 parent 13fdba0 commit 2280d59

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

src/libsyntax/config.rs

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ impl<'a> StripUnconfigured<'a> {
8989
parser.expect(&token::Comma)?;
9090
let lo = parser.span.lo();
9191
let (path, tokens) = parser.parse_meta_item_unrestricted()?;
92+
parser.eat(&token::Comma); // Optional trailing comma
9293
parser.expect(&token::CloseDelim(token::Paren))?;
9394
Ok((cfg, path, tokens, parser.prev_span.with_lo(lo)))
9495
}) {
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// compile-flags: --cfg TRUE
2+
3+
#[cfg_attr(TRUE, inline,)] // OK
4+
fn f() {}
5+
6+
#[cfg_attr(FALSE, inline,)] // OK
7+
fn g() {}
8+
9+
#[cfg_attr(TRUE, inline,,)] //~ ERROR expected `)`, found `,`
10+
fn h() {}
11+
12+
#[cfg_attr(FALSE, inline,,)] //~ ERROR expected `)`, found `,`
13+
fn i() {}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: expected `)`, found `,`
2+
--> $DIR/cfg-attr-trailing-comma.rs:9:25
3+
|
4+
LL | #[cfg_attr(TRUE, inline,,)] //~ ERROR expected `)`, found `,`
5+
| ^ expected `)`
6+
7+
error: expected `)`, found `,`
8+
--> $DIR/cfg-attr-trailing-comma.rs:12:26
9+
|
10+
LL | #[cfg_attr(FALSE, inline,,)] //~ ERROR expected `)`, found `,`
11+
| ^ expected `)`
12+
13+
error: aborting due to 2 previous errors
14+

0 commit comments

Comments
 (0)