diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2018-09-26 03:07:59 +0300 |
|---|---|---|
| committer | Pietro Albini <pietro@pietroalbini.org> | 2018-10-02 14:18:40 +0200 |
| commit | 2280d5990cfbc09946e091ef0489eec047567356 (patch) | |
| tree | 57d6307df89cf30e811c41b3cb61f1bb7d1b8bd6 /src | |
| parent | 13fdba0fe7ad13bf0c3c16a07513d0c00a19f03d (diff) | |
Accept trailing comma in `cfg_attr`
Diffstat (limited to 'src')
| -rw-r--r-- | src/libsyntax/config.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/cfg-attr-trailing-comma.rs | 13 | ||||
| -rw-r--r-- | src/test/ui/cfg-attr-trailing-comma.stderr | 14 |
3 files changed, 28 insertions, 0 deletions
diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 63b70b12248..bc4b7385d8a 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -89,6 +89,7 @@ impl<'a> StripUnconfigured<'a> { parser.expect(&token::Comma)?; let lo = parser.span.lo(); let (path, tokens) = parser.parse_meta_item_unrestricted()?; + parser.eat(&token::Comma); // Optional trailing comma parser.expect(&token::CloseDelim(token::Paren))?; Ok((cfg, path, tokens, parser.prev_span.with_lo(lo))) }) { diff --git a/src/test/ui/cfg-attr-trailing-comma.rs b/src/test/ui/cfg-attr-trailing-comma.rs new file mode 100644 index 00000000000..21e00544ca0 --- /dev/null +++ b/src/test/ui/cfg-attr-trailing-comma.rs @@ -0,0 +1,13 @@ +// compile-flags: --cfg TRUE + +#[cfg_attr(TRUE, inline,)] // OK +fn f() {} + +#[cfg_attr(FALSE, inline,)] // OK +fn g() {} + +#[cfg_attr(TRUE, inline,,)] //~ ERROR expected `)`, found `,` +fn h() {} + +#[cfg_attr(FALSE, inline,,)] //~ ERROR expected `)`, found `,` +fn i() {} diff --git a/src/test/ui/cfg-attr-trailing-comma.stderr b/src/test/ui/cfg-attr-trailing-comma.stderr new file mode 100644 index 00000000000..76a470417e9 --- /dev/null +++ b/src/test/ui/cfg-attr-trailing-comma.stderr @@ -0,0 +1,14 @@ +error: expected `)`, found `,` + --> $DIR/cfg-attr-trailing-comma.rs:9:25 + | +LL | #[cfg_attr(TRUE, inline,,)] //~ ERROR expected `)`, found `,` + | ^ expected `)` + +error: expected `)`, found `,` + --> $DIR/cfg-attr-trailing-comma.rs:12:26 + | +LL | #[cfg_attr(FALSE, inline,,)] //~ ERROR expected `)`, found `,` + | ^ expected `)` + +error: aborting due to 2 previous errors + |
