Skip to content

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

Merged
alexcrichton merged 3 commits intorust-lang:masterfrom
sfackler:cfg-syntax
Sep 23, 2014
Merged

RFC: Overhaul the #[cfg(..)] pattern syntax#194
alexcrichton merged 3 commits intorust-lang:masterfrom
sfackler:cfg-syntax

Conversation

@sfackler
Copy link
Copy Markdown
Member

@sfackler sfackler commented Aug 9, 2014

No description provided.

@bharrisau
Copy link
Copy Markdown

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
Copy Markdown

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

@sfackler
Copy link
Copy Markdown
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
Copy Markdown

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

Copy link
Copy Markdown

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)

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Member

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

@sfackler
Copy link
Copy Markdown
Member Author

@kballard sounds reasonable to me.

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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