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

RFC: Overhaul the #[cfg(..)] pattern syntax #194

Merged
merged 3 commits into from
Sep 23, 2014

Conversation

sfackler
Copy link
Member

@sfackler sfackler commented Aug 9, 2014

No description provided.

@bharrisau
Copy link

Looks good. Did you want to treat the initial <p> as if it is wrapped in an 'any' block (the same behaviour as multiple #cfg currently, or an all block like an #cfg behaves currently. Or neither, to avoid any confusion?

@bharrisau
Copy link

Forgive the unterminated bracket. I'm on my phone and can't edit the message ;)

@sfackler
Copy link
Member Author

sfackler commented Aug 9, 2014

My gut would be neither to avoid confusion, though defaulting to all might be reasonable.

@bharrisau
Copy link

And any is probably the most common in the rust tree.

proposed names read better with the function-like syntax and are consistent
with `Iterator::all` and `Iterator::any`.

Issue [#2119](https://github.com/rust-lang/rust/issuse/2119) proposed the

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo, link should point to rust/issues/2119 (s/issuse/issues)

will change from "include `foo` if *either of* `a` and `b` are present in the
compilation environment" to "include `foo` if *both of* `a` and `b` are present
in the compilation environment". To ease the transition it will be an error to
have multiple `#[cfg(...)]` attributes on a single item for some reasonable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's entirely crazy for multiple cfgs to be an error indefinitely.

@lilyball
Copy link
Contributor

👍 on the proposal, but I think we can make some tweaks to aid the transition.

First, multiple #[cfg(...)] items should continue to be accepted, with the current semantics. Second, a #[cfg(a,b,c)] pattern should be accepted (e.g. where there's multiple patterns), again with the current semantics.

However, if either of these cases are encountered in the wild, a warning will be emitted, with a note describing how to rewrite it. This warning will not be a lint, it will instead be built in to the #[cfg] parser, thus preventing anyone from disabling it.

At some point in the future, we can switch this to an error. And then at a later time, if we decide it's appropriate, we can then turn multiple #[cfg] attributes into an all match, as the RFC currently suggests.

@alexcrichton
Copy link
Member

cc rust-lang/rust#2119, the very very old bug on this

@sfackler
Copy link
Member Author

@kballard sounds reasonable to me.

warning. After some reasonable period of time, the special case will be
removed.

In addition, `#[cfg(a, b, c)]` will be accepted with a warning and be
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this give three ways to write all? #[cfg(a, b)] #[cfg(a)] #[cfg(b)] and #[cfg(all(a, b))]?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but the first and second behaviors will trigger deprecation warnings.

Edit: Actually, the second case will in the short term be equivalent to #[cfg(any(a, b)], again with a warning.

@alexcrichton
Copy link
Member

This was discussed in today's meeting and the decision was to merge it, thanks @sfackler!

withoutboats pushed a commit to withoutboats/rfcs that referenced this pull request Jan 15, 2017
fixed another bunch of clippy warnings
@Centril Centril added A-cfg Conditional compilation related proposals & ideas A-attributes Proposals relating to attributes A-syntax Syntax related proposals & ideas labels Nov 23, 2018
wycats pushed a commit to wycats/rust-rfcs that referenced this pull request Mar 5, 2019
…event-mananger

Deprecate component `eventManager`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Proposals relating to attributes A-cfg Conditional compilation related proposals & ideas A-syntax Syntax related proposals & ideas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants