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

Ensure TupleStructPattern and TuplePattern have items #2887

Merged
merged 1 commit into from Mar 4, 2024

Conversation

powerboat9
Copy link
Contributor

No description provided.

Note that instances of both classes which have been
moved from will have (items == nullptr).

gcc/rust/ChangeLog:

	* ast/rust-pattern.h
	(class TupleStructPattern): Assert that items != nullptr.
	(class TuplePattern): Likewise.
	(TupleStructPattern::has_items): Remove.
	(TuplePattern::has_tuple_pattern_items): Likewise.
	* parse/rust-parse-impl.h
	(Parser::parse_ident_leading_pattern):
	Prevent construction of TupleStructPattern with
	(items == nullptr).
	(Parser::parse_pattern_no_alt): Likewise.
	* ast/rust-ast-collector.cc
	(TokenCollector::visit): Remove usage of
	TupleStructPattern::has_items.
	* ast/rust-ast-visitor.cc
	(DefaultASTVisitor::visit): Likewise.
	* resolve/rust-early-name-resolver.cc
	(EarlyNameResolver::visit): Likewise.

gcc/testsuite/ChangeLog:

	* rust/compile/pattern-struct.rs: Fix test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
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.

I don't know if this is actually correct, unless I'm misunderstanding? it seems to me that empty patterns are allowed? https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=755341695f14b8bd2d51f095778ec222

@powerboat9
Copy link
Contributor Author

This just ensures that an empty pattern is represented with a non-null TupleStructItems.

@CohenArthur CohenArthur added this pull request to the merge queue Mar 4, 2024
@CohenArthur
Copy link
Member

This just ensures that an empty pattern is represented with a non-null TupleStructItems.

thanks for the explanation :)

Merged via the queue into Rust-GCC:master with commit dae69e8 Mar 4, 2024
9 checks passed
@powerboat9 powerboat9 deleted the no-null-items branch March 4, 2024 19:04
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.

None yet

2 participants