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

Improve Rib::Definition shadowing #3188

Merged
merged 1 commit into from
Oct 9, 2024
Merged

Conversation

powerboat9
Copy link
Contributor

This modifies Rib::Definition in order to better handle shadowing. It splits shadowing declarations into shadowing and globbed declarations, as shadowing declarations must shadow non-shadowing declarations, but non-shadowing declarations must shadow "globbed" declarations.

gcc/rust/ChangeLog:

	* resolve/rust-finalize-imports-2.0.cc
	(GlobbingVisitor::visit): Replace calls to insert_shadowable with
	insert_globbed.
	* resolve/rust-forever-stack.h
	(ForeverStack::insert_globbed): Add.
	* resolve/rust-forever-stack.hxx
	(ForeverStack::insert_globbed): Add.
	(ForeverStack::dfs): Handle modifications to Rib::Definition
	fields.
	* resolve/rust-late-name-resolver-2.0.cc
	(Late::visit): Make IdentifierPattern-based declarations
	shadowable.
	* resolve/rust-name-resolution-context.cc
	(NameResolutionContext::insert_globbed): Add.
	* resolve/rust-name-resolution-context.h
	(NameResolutionContext::insert_globbed): Add.
	* resolve/rust-rib.cc
	(Rib::Definition::Definition): Use Rib::Definition::Mode to
	indicate shadowing mode instead of boolean, handle modifications
	to Rib::Definition fields.
	(Rib::Definition::is_ambiguous): Handle modifications to
	Rib::Definition fields.
	(Rib::Definition::to_string): Likewise.
	(Rib::Definition::Shadowable): Handle changed constructor
	signature.
	(Rib::Definition::NonShadowable): Likewise.
	(Rib::Definition::Globbed): Add.
	(Rib::insert): Handle changes to Rib::Definition fields.
	* resolve/rust-rib.h
	(Rib::Definition::Globbed): Add.
	(Rib::Definition::ids): Remove.
	(Rib::Definition::ids_shadowable): Add.
	(Rib::Definition::ids_non_shadowable): Add.
	(Rib::Definition::ids_globbed): Add.
	(Rib::Definition::get_node_id): Handle modifications to
	Rib::Definition fields.
	(Rib::Definition::Mode): Add.
	(Rib::Definition::Definition): Use Rib::Definition::Mode to
	indicate shadowing mode instead of boolean.

gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude: Remove shadow1.rs.

Signed-off-by: Owen Avery <[email protected]>
Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

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

LGTM but waiting for @P-E-P to review it! thank you!

Copy link
Member

@P-E-P P-E-P left a comment

Choose a reason for hiding this comment

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

Great work!

@P-E-P P-E-P added this pull request to the merge queue Oct 9, 2024
Merged via the queue into Rust-GCC:master with commit 1499466 Oct 9, 2024
12 checks passed
@powerboat9 powerboat9 deleted the rib-stretch branch October 9, 2024 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants