Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--cfg accepts invalid cfgs #31495

Closed
brson opened this issue Feb 8, 2016 · 5 comments
Closed

--cfg accepts invalid cfgs #31495

brson opened this issue Feb 8, 2016 · 5 comments
Labels
A-driver Area: rustc_driver that ties everything together into the `rustc` compiler E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@brson
Copy link
Contributor

brson commented Feb 8, 2016

List meta items are not allowed in cfg specs because the compiler reserves them for built-in predicates like any.

So for example you can't write

foo.rs:1:7: 1:16 error: invalid predicate `foo`
foo.rs:1 #[cfg(foo(bar))]
               ^~~~~~~~~

You can though write `rustc --cfg "foo(bar))". This should be similarly rejected.

cc #31278

@brson brson added A-driver Area: rustc_driver that ties everything together into the `rustc` compiler E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Feb 8, 2016
@brson
Copy link
Contributor Author

brson commented Feb 8, 2016

This is probably pretty easy. Comparing the parsing in libsyntax with the parsing in librustc_driver and fix the latter to be like the former. Add a test to src/tests/compile-fail with the compile-flags: directive set to --cfg whatever.

@kamalmarhubi
Copy link
Contributor

Should rustc --cfg any(foo) be accepted?

@kamalmarhubi
Copy link
Contributor

I'm assuming it should not for now.

@brson
Copy link
Contributor Author

brson commented Feb 8, 2016

@kamalmarhubi No it should not.

kamalmarhubi added a commit to kamalmarhubi/rust that referenced this issue Feb 8, 2016
kamalmarhubi added a commit to kamalmarhubi/rust that referenced this issue Feb 8, 2016
A spec like `#[cfg(foo(bar))]` is not allowed as an attribute. This
makes the same spec be rejected by the compiler if passed in as a
`--cfg` argument.

Fixes rust-lang#31495
@kamalmarhubi
Copy link
Contributor

Excellent, less fixup work for me :-)

bors added a commit that referenced this issue Feb 10, 2016
A spec like `#[cfg(foo(bar))]` is not allowed as an attribute. This
makes the same spec be rejected by the compiler if passed in as a
`--cfg` argument.

Fixes #31495
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-driver Area: rustc_driver that ties everything together into the `rustc` compiler E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

2 participants