Add base feature gating for derive(CoercePointee) - #4841
Open
CohenArthur wants to merge 3 commits into
Open
CohenArthur wants to merge 3 commits into
CohenArthur wants to merge 3 commits into
Conversation
gcc/rust/ChangeLog: * checks/errors/feature/rust-feature-gate.cc (FeatureGate::visit): Add missing call to default visitor for ExternType items.
…gate. This commit adds more functionality to the BuiltinAttributeChecker class and allows it to store the list of parsed crate features. The class will then keep an instance of FeatureGate, and will be able to gate nightly attributes should it need to. This is particularly useful for checking unstable built-in derives *before* they get desugared and removed by macro expansion. gcc/rust/ChangeLog: * checks/errors/feature/rust-feature-gate.h: Make `gate` public. * checks/errors/rust-builtin-attribute-checker.cc: Make all handlers private methods instead. (lookup_handler): Transform the function to make it return pointer to member functions instead. (BuiltinAttributeChecker::BuiltinAttributeChecker): Add new argument to constructor to take in parsed CrateFeatures&. (BuiltinAttributeChecker::visit): Adapt attribute visitor to new lookup_handler function. * checks/errors/rust-builtin-attribute-checker.h: Add new declaratiosn for handlers. * rust-session-manager.cc (Session::compile_crate): Make BuiltinAttributeChecker run before expansion.
Gate derive(CoercePointee) behind `#![feature(derive_coerce_pointee)` and start adding the infrastructure required to support it. gcc/rust/ChangeLog: * checks/errors/feature/rust-feature-defs.h (FEATURE_ACTIVE): New feature. * checks/errors/feature/rust-feature-gate.h: Remove unused method? * checks/errors/rust-builtin-attribute-checker.cc (BuiltinAttributeChecker::derive): New handler. (lookup_handler): Dispatch it. * expand/rust-derive.cc (DeriveVisitor::derive): Add base handling for CoercePointee derive. * expand/rust-macro-builtins.cc: Add CoercePointee as a built-in derive when compatibility mode is greater or equal to 84. * expand/rust-macro-builtins.h (enum class): Likewise. * resolve/rust-early-name-resolver-2.0.cc (Early::visit_derive_attribute): Special case derive(CoercePointee). * rust-session-manager.h (should_support_coerce_pointee): New method. gcc/testsuite/ChangeLog: * rust/compile/derive-coerce-pointee1.rs: New test. * rust/compile/derive-coerce-pointee2.rs: New test. * rust/compile/derive-coerce-pointee3.rs: New test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds more functionality to the BuiltinAttributeChecker class and allows it to
store the list of parsed crate features. The class will then keep an instance of FeatureGate,
and will be able to gate nightly attributes should it need to. This is particularly useful for
checking unstable built-in derives before they get desugared and removed by macro expansion.
We then gate derive(CoercePointee) behind
#![feature(derive_coerce_pointee)and start adding theinfrastructure required to support the derive.