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

Fix feature gate visitor #3136

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

CohenArthur
Copy link
Member

Needs #3135, so only review the last commit

This commit turns a few of the fields into tl::optional<T> and cleanups
the constructor with a couple default parameters. We can also reuse the
variable that we are switching on, instead of repeating the enum variants
each time.

Most importantly, the FeatureGate visitor now uses the DefaultAstVisitor
correctly, and will now visit nested items. This means that we have to
fix a bunch of the testsuite as some feature attributes were missing.

@CohenArthur CohenArthur requested a review from P-E-P August 21, 2024 14:10
@CohenArthur CohenArthur force-pushed the fix-feature-gate-visitor branch from 39809b9 to ce65813 Compare August 21, 2024 14:43
gcc/rust/checks/errors/rust-feature-gate.cc Outdated Show resolved Hide resolved
gcc/rust/checks/errors/rust-feature-gate.h Show resolved Hide resolved
{
switch (name)
switch (f)
{
case Feature::Name::ASSOCIATED_TYPE_BOUNDS:
return Feature (Feature::Name::ASSOCIATED_TYPE_BOUNDS,
Feature::State::ACCEPTED, "associated_type_bounds",
Copy link
Member

Choose a reason for hiding this comment

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

Should we introduce constexpr for those feature name ? Probably not because most of the code will make use of the features, not their name.

@CohenArthur CohenArthur force-pushed the fix-feature-gate-visitor branch 2 times, most recently from 77e0aa2 to e2562fd Compare August 22, 2024 13:06
This commit turns a few of the fields into `tl::optional<T>` and cleanups
the constructor with a couple default parameters. We can also reuse the
variable that we are `switch`ing on, instead of repeating the enum variants
each time.

Most importantly, the `FeatureGate` visitor now uses the `DefaultAstVisitor`
correctly, and will now visit nested items. This means that we have to
fix a bunch of the testsuite as some feature attributes were missing.

gcc/rust/ChangeLog:

	* checks/errors/rust-feature.cc (Feature::create): Reuse variable,
	remove now optional parameters from constructor.
	* checks/errors/rust-feature.h: Cleanup class definition.
	* checks/errors/rust-feature-gate.cc (FeatureGate::gate): Use optional.
	* checks/errors/rust-feature-gate.h: Cleanup visitor implementation.

gcc/testsuite/ChangeLog:

	* rust/compile/assume.rs: Add missing feature attribute.
	* rust/compile/issue-1901.rs: Likewise.
	* rust/compile/issue-1981.rs: Likewise.
	* rust/compile/sizeof-stray-infer-var-bug.rs: Likewise.
	* rust/compile/torture/intrinsics-8.rs: Likewise.
	* rust/compile/torture/transmute-size-check-1.rs: Likewise.
	* rust/compile/torture/transmute1.rs: Likewise.
	* rust/compile/torture/uninit-intrinsic-1.rs: Likewise.
	* rust/execute/torture/issue-1436.rs: Likewise.
	* rust/execute/torture/issue-2583.rs: Likewise.
@CohenArthur CohenArthur force-pushed the fix-feature-gate-visitor branch from e2562fd to 00879ac Compare August 22, 2024 13:10
@CohenArthur CohenArthur enabled auto-merge August 22, 2024 13:10
@CohenArthur CohenArthur added this pull request to the merge queue Aug 22, 2024
Merged via the queue into Rust-GCC:master with commit 084789e Aug 22, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants