Skip to content

Unify HIR::ExprStmt deriving classes#2111

Merged
philberty merged 4 commits into
Rust-GCC:masterfrom
powerboat9:unify-expr-stmt
Apr 13, 2023
Merged

Unify HIR::ExprStmt deriving classes#2111
philberty merged 4 commits into
Rust-GCC:masterfrom
powerboat9:unify-expr-stmt

Conversation

@powerboat9

Copy link
Copy Markdown
Collaborator

Simplifies the HIR with intent to address #1446.

@powerboat9 powerboat9 force-pushed the unify-expr-stmt branch 3 times, most recently from 65e6437 to 7e35506 Compare April 8, 2023 18:25
gcc/rust/ChangeLog:

	* hir/tree/rust-hir-stmt.h
	(ExprStmt::expr): Add field.
	(ExprStmt::get_expr): Add method.
	(ExprStmt::ExprStmt): Add copy/move constructors, modify existing constructor.
	(ExprStmt::operator=): Add assignment operator.
	(ExprStmtWithoutBlock::expr): Remove field.
	(ExprStmtWithoutBlock::get_expr): Remove method.
	(ExprStmtWithoutBlock::ExprStmt):
	Remove copy/move constructors, modify existing constructor.
	(ExprStmtWithoutBlock::operator=): Remove assignment operator.
	(ExprStmtWithBlock::expr): Remove field.
	(ExprStmtWithBlock::get_expr): Remove method.
	(ExprStmtWithBlock::ExprStmt): Remove copy/move constructors, modify existing constructor.
	(ExprStmtWithBlock::operator=): Remove assignment operator.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/ChangeLog:

	* hir/tree/rust-hir.cc
	(ExprStmt::as_string): Add method.
	(ExprStmtWithBlock::as_string): Remove method.
	(ExprStmtWithoutBlock::as_string): Remove method.
	* hir/tree/rust-hir-stmt.h
	(ExprStmt::as_string): Add method.
	(ExprStmtWithBlock::as_string): Remove method.
	(ExprStmtWithoutBlock::as_string): Remove method.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/ChangeLog:

	* backend/rust-compile-stmt.cc
	(CompileStmt::visit): Unify ExprStmtWith{,out}Block visitors.
	* backend/rust-compile-stmt.h
	(CompileStmt::visit): Likewise.
	* backend/rust-compile-item.h
	(CompileItem::visit): Likewise.
	* hir/rust-hir-dump.cc
	(Dump::visit): Likewise.
	* hir/rust-hir-dump.h
	(Dump::visit): Likewise.
	* hir/tree/rust-hir-stmt.h
	(ExprStmt::accept_vis): Add.
	(ExprStmtWithoutBlock::accept_vis): Remove.
	(ExprStmtWithBlock::accept_vis): Remove.
	* hir/tree/rust-hir.cc
	(ExprStmt::accept_vis): Add.
	(ExprStmtWithoutBlock::accept_vis): Remove.
	(ExprStmtWithBlock::accept_vis): Remove.
	* hir/tree/rust-hir-visitor.h
	(HIRFullVisitor::visit): Likewise.
	(HIRFullVisitorBase::visit): Likewise.
	(HIRStmtVisitor::visit): Likewise.
	* checks/errors/rust-const-checker.cc
	(ConstChecker::visit): Likewise.
	* checks/errors/rust-const-checker.h
	(ConstChecker::visit): Likewise.
	* checks/errors/rust-unsafe-checker.cc
	(UnsafeChecker::visit): Likewise.
	* checks/errors/rust-unsafe-checker.h
	(UnsafeChecker::visit): Likewise.
	* checks/errors/privacy/rust-privacy-reporter.cc
	(PrivacyReporter::visit): Likewise.
	* checks/errors/privacy/rust-privacy-reporter.h
	(PrivacyReporter::visit): Likewise.
	* checks/lints/rust-lint-marklive.h
	(MarkLive::visit): Likewise.
	* typecheck/rust-hir-type-check-stmt.cc
	(TypeCheckStmt::visit): Likewise.
	* typecheck/rust-hir-type-check-stmt.h
	(TypeCheckStmt::visit): Likewise.
	* typecheck/rust-tycheck-dump.h
	(TypeResolverDump::visit): Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/ChangeLog:

	* hir/tree/rust-hir-full-decls.h
	(class ExprStmtWithoutBlock): Remove.
	(class ExprStmtWithBlock): Remove.
	* hir/tree/rust-hir-stmt.h
	(class ExprStmt):
	Add remaining ExprStmtWith{,out}Block functionality.
	(class ExprStmtWithoutBlock): Remove.
	(class ExprStmtWithBlock): Remove.
	* hir/rust-ast-lower-stmt.cc
	(ASTLoweringStmt::visit):
	Lower to HIR::ExprStmt instead of deriving class.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>

@philberty philberty 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 if you can solve that issue we could be very grateful! Its a tricky one to get right with block expressions but i am happy to merge this since there are no regressions detected

@philberty philberty added this pull request to the merge queue Apr 13, 2023
Merged via the queue into Rust-GCC:master with commit 47b92ff Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants