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

Feature gating *declarations* => new crate rustc_feature #66895

Merged
merged 14 commits into from
Dec 1, 2019

Conversation

Centril
Copy link
Contributor

@Centril Centril commented Nov 30, 2019

This PR moves the data-oriented parts of feature gating into its own crate, rustc_feature.
The parts consist of some data types as well as accepted, active, removed, and builtin_attrs.

Feature gate checking itself remains in syntax::feature_gate::check. The parts which define how to emit feature gate errors could probably be moved to rustc_errors or to the new rustc_session crate introduced in #66878. The visitor itself could probably be moved as a pass in rustc_passes depending on how the dependency edges work out.

The PR also contains some drive-by cleanup of feature gate checking. As such, the PR probably best read commit-by-commit.

r? @oli-obk
cc @petrochenkov
cc @Mark-Simulacrum

@petrochenkov petrochenkov self-assigned this Nov 30, 2019
@petrochenkov petrochenkov added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 30, 2019
// (name in cfg, feature, function to check if the feature is enabled)
(sym::target_thread_local, sym::cfg_target_thread_local, cfg_fn!(cfg_target_thread_local)),
(sym::target_has_atomic, sym::cfg_target_has_atomic, cfg_fn!(cfg_target_has_atomic)),
(sym::target_has_atomic_load_store, sym::cfg_target_has_atomic, cfg_fn!(cfg_target_has_atomic)),
];

#[derive(Debug)]
pub struct GatedCfg {
Copy link
Contributor

Choose a reason for hiding this comment

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

why move away from a struct with field names to a tuple?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you look above, the constant contains the tuples already -- I'm introducing a type alias for that. The struct GatedCfg with span and index was actively harmful; imo it became clearly cleaner using .find(...) instead. Ostensibly we could store the constant as a list of structs instead, but it doesn't seem worth it given the number of times the type is referenced and used?

src/libsyntax/feature_gate/check.rs Outdated Show resolved Hide resolved
@oli-obk
Copy link
Contributor

oli-obk commented Nov 30, 2019

@bors r+

@bors
Copy link
Contributor

bors commented Nov 30, 2019

📌 Commit ded177a has been approved by oli-obk

@bors
Copy link
Contributor

bors commented Nov 30, 2019

🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 30, 2019
Centril added a commit to Centril/rust that referenced this pull request Nov 30, 2019
Feature gating *declarations* => new crate `rustc_feature`

This PR moves the data-oriented parts of feature gating into its own crate, `rustc_feature`.
The parts consist of some data types as well as `accepted`, `active`, `removed`, and `builtin_attrs`.

Feature gate checking itself remains in `syntax::feature_gate::check`. The parts which define how to emit feature gate errors could probably be moved to `rustc_errors` or to the new `rustc_session` crate introduced in rust-lang#66878. The visitor itself could probably be moved as a pass in `rustc_passes` depending on how the dependency edges work out.

The PR also contains some drive-by cleanup of feature gate checking. As such, the PR probably best read commit-by-commit.

r? @oli-obk
cc @petrochenkov
cc @Mark-Simulacrum
bors added a commit that referenced this pull request Dec 1, 2019
Rollup of 9 pull requests

Successful merges:

 - #66612 (Initial implementation of or-pattern usefulness checking)
 - #66705 (Atomic as_mut_ptr)
 - #66759 (impl TrustedLen for vec::Drain)
 - #66858 (Use LLVMAddAnalysisPasses instead of Rust's wrapper)
 - #66870 (SimplifyArmIdentity only for locals with the same type)
 - #66883 (rustc_typeck: gate AnonConst's generics on feature(const_generics).)
 - #66889 (Make python-generated source files compatible with rustfmt)
 - #66894 (Remove unneeded prelude imports in libcore tests)
 - #66895 (Feature gating *declarations* => new crate `rustc_feature`)

Failed merges:

 - #66905 (rustc_plugin: Remove some remaining plugin features)

r? @ghost
@bors bors merged commit ded177a into rust-lang:master Dec 1, 2019
@Centril Centril deleted the rustc_feature branch December 1, 2019 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants