Skip to content

Ensure TupleStructPattern and TuplePattern have items#2887

Merged
CohenArthur merged 1 commit into
Rust-GCC:masterfrom
powerboat9:no-null-items
Mar 4, 2024
Merged

Ensure TupleStructPattern and TuplePattern have items#2887
CohenArthur merged 1 commit into
Rust-GCC:masterfrom
powerboat9:no-null-items

Conversation

@powerboat9

Copy link
Copy Markdown
Collaborator

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>

@CohenArthur CohenArthur 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.

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
Copy Markdown
Collaborator 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
Copy Markdown
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
@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.

2 participants