Skip to content

Add base feature gating for derive(CoercePointee) - #4841

Open
CohenArthur wants to merge 2 commits into
masterfrom
derive-coerce-pointee-base-impl
Open

CohenArthur wants to merge 2 commits into
masterfrom
derive-coerce-pointee-base-impl

Conversation

@CohenArthur

Copy link
Copy Markdown
Member

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 the
infrastructure required to support the derive.

@CohenArthur CohenArthur added the rust-for-linux Issue related to the compilation of the Linux kernel and its crates label Sep 3, 2026
gcc/rust/ChangeLog:

	* checks/errors/feature/rust-feature-gate.cc (FeatureGate::visit): Add missing call to
	default visitor for ExternType items.
@CohenArthur
CohenArthur force-pushed the derive-coerce-pointee-base-impl branch from 159f32a to 696df5c Compare September 18, 2026 16:36
Gate derive(CoercePointee) behind `#![feature(derive_coerce_pointee)` and start adding the
infrastructure required to support it. Warn that it doesn't do anything yet.

gcc/rust/ChangeLog:

	* checks/errors/feature/rust-feature-defs.h (FEATURE_ACTIVE): New feature.
	* 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.
	* expand/rust-derive-coerce-pointee.cc: New file.
	* expand/rust-derive-coerce-pointee.h: New file.
	* Make-lang.in: Compile it.

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 branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust-for-linux Issue related to the compilation of the Linux kernel and its crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant