Skip to content

ast: Check before visiting a while-let's label #3797

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

CohenArthur
Copy link
Member

gcc/rust/ChangeLog:

* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Check that the WhileLet has a label
before visiting it.

gcc/testsuite/ChangeLog:

* rust/compile/while_let_without_label.rs: New test.

@powerboat9
Copy link
Collaborator

Looks like we're missing binding context handling for the while let patterns -- speaking of, are they supposed to have multiple patterns, or should they just store a pattern which could be an AltPattern?

https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-pattern-loops

… IDs

gcc/rust/ChangeLog:

	* ast/rust-ast.h (reconstruct): New function for calling the `reconstruct_*_impl` method
	and asserting that the new NodeId is different, and then wrap it in a unique_ptr<T>.
	(reconstruct_vec): Likewise, but for vectors of unique_ptr<T>
gcc/rust/ChangeLog:

	* ast/rust-ast.h: Add reconstruct() and reconstruct_impl() for Type nodes.
	* ast/rust-type.h: Implement them.
	* ast/rust-macro.h: Likewise.
	* ast/rust-path.h: Likewise.
gcc/rust/ChangeLog:

	* Make-lang.in: Remove object file for ASTTypeBuilder.
	* ast/rust-ast-builder.h: Remove function.
	* ast/rust-ast-builder.cc (Builder::new_type): Likewise.
	(Builder::new_const_param): Use reconstruct_type() instead.
	(Builder::new_generic_args): Likewise.
	* expand/rust-derive-default.cc (DeriveDefault::visit_struct): Likewise.
	(DeriveDefault::visit_tuple): Likewise.
	* expand/rust-derive-eq.cc (DeriveEq::visit_tuple): Likewise.
	(DeriveEq::visit_struct): Likewise.
	(DeriveEq::visit_enum): Likewise.
	(DeriveEq::visit_union): Likewise.
	* ast/rust-ast-builder-type.cc: Removed.
	* ast/rust-ast-builder-type.h: Removed.
gcc/rust/ChangeLog:

	* ast/rust-ast.h (reconstruct_vec): Pre-allocate size of vector.
gcc/rust/ChangeLog:

	* ast/rust-ast-builder.cc: Remove extra include, fix new formatting.
gcc/rust/ChangeLog:

	* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Check that the WhileLet has a label
	before visiting it.

gcc/testsuite/ChangeLog:

	* rust/compile/while_let_without_label.rs: New test.
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