diff options
| author | bors <bors@rust-lang.org> | 2018-09-27 07:16:27 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-09-27 07:16:27 +0000 |
| commit | e999ebdb971a0bde03ec3fdfff901ac6613fcfa0 (patch) | |
| tree | 46af141bfedbbbed8cc2ba6d8e3686347539da7e /src | |
| parent | 441519536c8bd138e8c651743249acd6814747a1 (diff) | |
| parent | 2b3e16bfaabd07d87523a90e820fd2fa50377fbc (diff) | |
| download | rust-e999ebdb971a0bde03ec3fdfff901ac6613fcfa0.tar.gz rust-e999ebdb971a0bde03ec3fdfff901ac6613fcfa0.zip | |
Auto merge of #54581 - petrochenkov:cfgattr, r=alexcrichton
Accept trailing comma in `cfg_attr` Fixes https://github.com/rust-lang/rust/issues/54463 (stable-to-beta regression)
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 3d9f4a92f81..a9ce2365577 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -90,6 +90,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 + |
