-
Notifications
You must be signed in to change notification settings - Fork 13.5k
make cfg_select
a builtin macro
#143461
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
base: master
Are you sure you want to change the base?
make cfg_select
a builtin macro
#143461
Conversation
This comment has been minimized.
This comment has been minimized.
e3aeb08
to
1dc0034
Compare
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. This PR modifies cc @jieyouxu |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior, per the tests and the impl, looks correct to me.
3d68353
to
3abcece
Compare
I moved some things around (analogously to Implementation-wise the one thing I'm not sure about is how to get |
cc @rust-lang/rustfmt @rust-lang/style |
This comment was marked as resolved.
This comment was marked as resolved.
3abcece
to
53b3b88
Compare
This comment was marked as resolved.
This comment was marked as resolved.
53b3b88
to
5d550b1
Compare
4b84ad7
to
01f41cc
Compare
Given that formatting now seems straightforward, I think this can be merged without the precise formatting logic. It's probably better (also for review etc.) to add formatting separately in the So, this PR is complete from my perspective. |
Nice! I agree that a PR to the rustfmt repo would be ideal to add the formatting logic / refactoring for code sharing with |
01f41cc
to
b4afa4a
Compare
@rustbot ready |
b4afa4a
to
f8e7813
Compare
@rustbot ready |
Thanks! |
…o, r=petrochenkov make `cfg_select` a builtin macro tracking issue: rust-lang#115585 This parses mostly the same as the `macro cfg_select` version, except: 1. wrapping in double brackets is no longer supported (or needed): `cfg_select {{ /* ... */ }}` is now rejected. 2. in an expression context, the rhs is no longer wrapped in a block, so that this now works: ```rust fn main() { println!(cfg_select! { unix => { "foo" } _ => { "bar" } }); } ``` 3. a single wildcard rule is now supported: `cfg_select { _ => 1 }` now works I've also added an error if none of the rules evaluate to true, and warnings for any arms that follow the `_` wildcard rule. cc `@traviscross` if I'm missing any feature that should/should not be included r? `@petrochenkov` for the macro logic details
Rollup of 9 pull requests Successful merges: - #143213 (de-duplicate condition scoping logic between AST→HIR lowering and `ScopeTree` construction) - #143461 (make `cfg_select` a builtin macro) - #143519 (Check assoc consts and tys later like assoc fns) - #143554 (slice: Mark `rotate_left`, `rotate_right` unstably const) - #143704 (Be a bit more careful around exotic cycles in in the inliner) - #143774 (constify `From` and `Into`) - #143786 (Fix fallback for CI_JOB_NAME) - #143796 (Fix ICE for parsed attributes with longer path not handled by CheckAttribute) - #143798 (Remove format short command trait) r? `@ghost` `@rustbot` modify labels: rollup
tracking issue: #115585
This parses mostly the same as the
macro cfg_select
version, except:cfg_select {{ /* ... */ }}
is now rejected.cfg_select { _ => 1 }
now worksI've also added an error if none of the rules evaluate to true, and warnings for any arms that follow the
_
wildcard rule.cc @traviscross if I'm missing any feature that should/should not be included
r? @petrochenkov for the macro logic details