Skip to content

nr2.0: Update IdentifierPattern's subpattern name resolution#3828

Merged
P-E-P merged 1 commit into
Rust-GCC:masterfrom
Polygonalr:identifier-pattern-visit
Jun 17, 2025
Merged

nr2.0: Update IdentifierPattern's subpattern name resolution#3828
P-E-P merged 1 commit into
Rust-GCC:masterfrom
Polygonalr:identifier-pattern-visit

Conversation

@Polygonalr

Copy link
Copy Markdown
Contributor

Addresses this comment, thanks to @P-E-P for explaining the rationale for this change over meeting :)

gcc/rust/ChangeLog:

	* resolve/rust-late-name-resolver-2.0.cc (Late::visit(IdentifierPattern)):
	Remove redundant subpattern check.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
@powerboat9

Copy link
Copy Markdown
Collaborator

@P-E-P it looks like IdentifierPattern::get_subpattern doesn't return an optional and has the line

rust_assert (has_subpattern ());

@P-E-P

P-E-P commented Jun 16, 2025

Copy link
Copy Markdown
Member

@P-E-P it looks like IdentifierPattern::get_subpattern doesn't return an optional and has the line

rust_assert (has_subpattern ());

Right now the focus is the semantic aspect within the class ("yes that value can be missing and that null pointer IS a bug"), not at the class boundaries. This means you can keep the assert on the getter, if you really want to go the extra mile you can even rename it to get_subpattern_unchecked (it has been done in the codebase before, grep for _unchecked within the rust directory). If we have some time later we'll introduce proper optional APIs for the getters (and grepping "unchecked" will help) but for now the true goal is communicating the intent of the class to easily tell appart buggy null pointers from none values.

@powerboat9

Copy link
Copy Markdown
Collaborator

Oh, wait, nvm -- I should have read the patch more closely. Looks good

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@P-E-P P-E-P added this pull request to the merge queue Jun 17, 2025
Merged via the queue into Rust-GCC:master with commit d31e537 Jun 17, 2025
12 checks passed
@Polygonalr Polygonalr deleted the identifier-pattern-visit branch August 2, 2025 06:53
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