diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2023-03-15 16:35:47 -0400 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 18:21:12 +0100 |
commit | 265d8555fe3ad38755e64a6b9880521c7f3a3cc7 (patch) | |
tree | fff5e9683b2eb2b4da0fb2d23a5448980145dfc8 /gcc/rust/backend/rust-compile-expr.cc | |
parent | f821a019e624555397b539e864cc145057922a63 (diff) | |
download | gcc-265d8555fe3ad38755e64a6b9880521c7f3a3cc7.zip gcc-265d8555fe3ad38755e64a6b9880521c7f3a3cc7.tar.gz gcc-265d8555fe3ad38755e64a6b9880521c7f3a3cc7.tar.bz2 |
gccrs: Unify HIR::IfExprConseqIf{,Let} into HIR::IfExprConseqElse
This should simplify 'if' expression handling to match
future simplifications to 'if let' expression handling.
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-expr.cc
(TypeCheckExpr::visit): Remove IfExprConseqIf visitor.
* typecheck/rust-hir-type-check-expr.h
(TypeCheckExpr::visit): Remove IfExprConseqIf{,Let} visitor.
* backend/rust-compile-block.cc
(CompileConditionalBlocks::visit): Remove IfExprConseqIf visitor.
* backend/rust-compile-block.h
(CompileConditionalBlocks::visit): Remove IfExprConseqIf{,Let} visitors.
(CompileExprWithBlock::visit):
Remove IfExprConseqIf{,Let} visitors, implement BlockExpr visitor.
* backend/rust-compile-expr.cc
(CompileExpr::visit): Remove IfExprConseqIf visitor.
* backend/rust-compile-expr.h
(CompileExpr::visit): Remove IfExprConseqIf{,Let} visitors.
* checks/lints/rust-lint-marklive.h
(MarkLive::visit): Remove IfExprConseqIf visitor.
* checks/errors/rust-const-checker.cc
(ConstChecker::visit): Remove IfExprConseqIf{,Let} visitors.
* checks/errors/rust-const-checker.h
(ConstChecker::visit): Remove IfExprConseqIf{,Let} visitors.
* checks/errors/rust-unsafe-checker.cc
(UnsafeChecker::visit): Remove IfExprConseqIf{,Let} visitors.
* checks/errors/rust-unsafe-checker.h
(UnsafeChecker::visit): Remove IfExprConseqIf{,Let} visitors.
* checks/errors/privacy/rust-privacy-reporter.cc
(PrivacyReporter::visit): Remove IfExprConseqIf{,Let} visitors.
* checks/errors/privacy/rust-privacy-reporter.h
(PrivacyReporter::visit): Remove IfExprConseqIf{,Let} visitors.
* hir/tree/rust-hir-expr.h
(class IfExprConseqElse): Make else_block ExprWithBlock.
(class IfExprConseqIf): Remove.
(class IfExprConseqIfLet): Remove.
* hir/tree/rust-hir-full-decls.h
(class IfExprConseqIf): Remove.
(class IfExprConseqIfLet): Remove.
* hir/tree/rust-hir.cc
(IfExprConseqElse::as_string): Adjust output.
(IfExprConseqIf::as_string): Remove.
(IfExprConseqIfLet::as_string): Remove.
(IfExprConseqIf::accept_vis): Remove.
(IfExprConseqIfLet::accept_vis): Remove.
* hir/tree/rust-hir-visitor.h
(HIRFullVisitor::visit): Remove IfExprConseqIf{,Let} visitors.
(HIRFullVisitorBase::visit): Remove IfExprConseqIf{,Let} visitors.
(HIRExpressionVisitor::visit): Remove IfExprConseqIf{,Let} visitors.
* hir/rust-hir-dump.cc
(Dump::visit): Remove IfExprConseqIf{,Let} visitors.
* hir/rust-hir-dump.h
(Dump::visit): Remove IfExprConseqIf{,Let} visitors.
* hir/rust-ast-lower.cc
(ASTLoweringIfBlock::visit): Replace HIR::IfExprConseqIf with HIR::IfExprConseqElse.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-expr.cc')
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.cc | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index e138e41..962135b 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -345,43 +345,6 @@ CompileExpr::visit (HIR::IfExprConseqElse &expr) } void -CompileExpr::visit (HIR::IfExprConseqIf &expr) -{ - TyTy::BaseType *if_type = nullptr; - if (!ctx->get_tyctx ()->lookup_type (expr.get_mappings ().get_hirid (), - &if_type)) - { - rust_error_at (expr.get_locus (), - "failed to lookup type of IfExprConseqElse"); - return; - } - - Bvariable *tmp = NULL; - bool needs_temp = !if_type->is_unit (); - if (needs_temp) - { - fncontext fnctx = ctx->peek_fn (); - tree enclosing_scope = ctx->peek_enclosing_scope (); - tree block_type = TyTyResolveCompile::compile (ctx, if_type); - - bool is_address_taken = false; - tree ret_var_stmt = nullptr; - tmp = ctx->get_backend ()->temporary_variable ( - fnctx.fndecl, enclosing_scope, block_type, NULL, is_address_taken, - expr.get_locus (), &ret_var_stmt); - ctx->add_statement (ret_var_stmt); - } - - auto stmt = CompileConditionalBlocks::compile (&expr, ctx, tmp); - ctx->add_statement (stmt); - - if (tmp != NULL) - { - translated = ctx->get_backend ()->var_expression (tmp, expr.get_locus ()); - } -} - -void CompileExpr::visit (HIR::BlockExpr &expr) { TyTy::BaseType *block_tyty = nullptr; |