aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2023-03-15 23:05:07 -0400
committerCohenArthur <arthur.cohen@embecosm.com>2023-04-12 13:17:19 +0000
commit132a5011e384994e6121eb606f2442ca61fbe908 (patch)
treefb9da31637abdbcf97037be6611abc206710a548 /gcc
parentdc5f674759ecea1531e857e35ebccc1d302be7d4 (diff)
downloadgcc-132a5011e384994e6121eb606f2442ca61fbe908.zip
gcc-132a5011e384994e6121eb606f2442ca61fbe908.tar.gz
gcc-132a5011e384994e6121eb606f2442ca61fbe908.tar.bz2
Unify AST::IfExprConseqIf{,Let} into AST::IfExprConseqElse
This simplifies the AST's representation of if-statements to match the HIR. gcc/rust/ChangeLog: * ast/rust-expr.h (class IfExprConseqElse): Make else_block ExprWithBlock. (class IfExprConseqIf): Remove. (class IfExprConseqIfLet): Remove. * ast/rust-ast-full-decls.h (class IfExprConseqIf): Remove. (class IfExprConseqIfLet): Remove. * ast/rust-ast.cc (IfExprConseqElse::as_string): Adjust output. (IfExprConseqIf::as_string): Remove. (IfExprConseqIfLet::as_string): Remove. (IfExprConseqIf::accept_vis): Remove. (IfExprConseqIfLet::accept_vis): Remove. * ast/rust-ast-visitor.h (ASTVisitor::visit): Remove IfExprConseqIf{,Let} visitors. * ast/rust-ast-tokenstream.cc (TokenStream::visit): Likewise. * ast/rust-ast-tokenstream.h (TokenStream::visit): Likewise. * ast/rust-ast-dump.cc (Dump::visit): Likewise. * ast/rust-ast-dump.h (Dump::visit): Likewise. * checks/errors/rust-feature-gate.h (FeatureGate::visit): Likewise. * util/rust-attributes.cc (AttributeChecker::visit): Likewise. * util/rust-attributes.h (AttributeChecker::visit): Likewise. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise. * resolve/rust-early-name-resolver.h (EarlyNameResolver::visit): Likewise. * resolve/rust-ast-resolve-base.h (ResolverBase::visit): Likewise. * resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise. * resolve/rust-ast-resolve-expr.h (ResolveExpr::visit): Remove IfExprConseqIf visitor. * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Likewise. * expand/rust-cfg-strip.cc (CfgStrip::visit): Remove IfExprConseqIf{,Let} visitors. * expand/rust-cfg-strip.h (CfgStrip::visit): Likewise. * expand/rust-expand-visitor.cc (ExpandVisitor::visit): Likewise. * expand/rust-expand-visitor.h (ExpandVisitor::visit): Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise. * hir/rust-ast-lower-base.h (ASTLoweringBase::visit): Likewise. * hir/rust-ast-lower-block.h (ASTLoweringIfBlock::visit): Remove IfExprConseqIf visitor. (ASTLoweringExprWithBlock::visit): Likewise. * hir/rust-ast-lower.cc (ASTLoweringIfBlock::visit): Remove IfExprConseqIf visitor, adjust IfExprConseqElse lowering. * hir/rust-ast-lower-expr.h (ASTLoweringExpr::visit): Remove IfExprConseqIf visitor. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise. * parse/rust-parse-impl.h (Parser::parse_if_expr): Replace IfExprConseqIf{,Let} with IfExprConseqElse. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/ast/rust-ast-dump.cc16
-rw-r--r--gcc/rust/ast/rust-ast-dump.h2
-rw-r--r--gcc/rust/ast/rust-ast-full-decls.h2
-rw-r--r--gcc/rust/ast/rust-ast-tokenstream.cc19
-rw-r--r--gcc/rust/ast/rust-ast-tokenstream.h2
-rw-r--r--gcc/rust/ast/rust-ast-visitor.h2
-rw-r--r--gcc/rust/ast/rust-ast.cc34
-rw-r--r--gcc/rust/ast/rust-expr.h127
-rw-r--r--gcc/rust/checks/errors/rust-feature-gate.h2
-rw-r--r--gcc/rust/expand/rust-cfg-strip.cc71
-rw-r--r--gcc/rust/expand/rust-cfg-strip.h2
-rw-r--r--gcc/rust/expand/rust-expand-visitor.cc18
-rw-r--r--gcc/rust/expand/rust-expand-visitor.h2
-rw-r--r--gcc/rust/hir/rust-ast-lower-base.cc6
-rw-r--r--gcc/rust/hir/rust-ast-lower-base.h2
-rw-r--r--gcc/rust/hir/rust-ast-lower-block.h7
-rw-r--r--gcc/rust/hir/rust-ast-lower-expr.cc6
-rw-r--r--gcc/rust/hir/rust-ast-lower-expr.h1
-rw-r--r--gcc/rust/hir/rust-ast-lower.cc37
-rw-r--r--gcc/rust/parse/rust-parse-impl.h20
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-base.cc8
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-base.h2
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-expr.cc8
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-expr.h1
-rw-r--r--gcc/rust/resolve/rust-early-name-resolver.cc16
-rw-r--r--gcc/rust/resolve/rust-early-name-resolver.h2
-rw-r--r--gcc/rust/util/rust-attributes.cc8
-rw-r--r--gcc/rust/util/rust-attributes.h2
28 files changed, 21 insertions, 404 deletions
diff --git a/gcc/rust/ast/rust-ast-dump.cc b/gcc/rust/ast/rust-ast-dump.cc
index 05de528..4bc6b9d 100644
--- a/gcc/rust/ast/rust-ast-dump.cc
+++ b/gcc/rust/ast/rust-ast-dump.cc
@@ -937,22 +937,6 @@ Dump::visit (IfExprConseqElse &expr)
}
void
-Dump::visit (IfExprConseqIf &expr)
-{
- stream << "if ";
- visit (expr.get_condition_expr ());
- stream << " ";
- visit (expr.get_if_block ());
- stream << indentation << "else ";
- // The "if" part of the "else if" is printed by the next visitor
- visit (expr.get_conseq_if_expr ());
-}
-
-void
-Dump::visit (IfExprConseqIfLet &)
-{}
-
-void
Dump::visit (IfLetExpr &)
{}
diff --git a/gcc/rust/ast/rust-ast-dump.h b/gcc/rust/ast/rust-ast-dump.h
index 45722f2..cfde57d 100644
--- a/gcc/rust/ast/rust-ast-dump.h
+++ b/gcc/rust/ast/rust-ast-dump.h
@@ -184,8 +184,6 @@ private:
void visit (ForLoopExpr &expr);
void visit (IfExpr &expr);
void visit (IfExprConseqElse &expr);
- void visit (IfExprConseqIf &expr);
- void visit (IfExprConseqIfLet &expr);
void visit (IfLetExpr &expr);
void visit (IfLetExprConseqElse &expr);
void visit (IfLetExprConseqIf &expr);
diff --git a/gcc/rust/ast/rust-ast-full-decls.h b/gcc/rust/ast/rust-ast-full-decls.h
index ed0d981..ebfb17b 100644
--- a/gcc/rust/ast/rust-ast-full-decls.h
+++ b/gcc/rust/ast/rust-ast-full-decls.h
@@ -135,9 +135,7 @@ class WhileLetLoopExpr;
class ForLoopExpr;
class IfExpr;
class IfExprConseqElse;
-class IfExprConseqIf;
class IfLetExpr;
-class IfExprConseqIfLet;
class IfLetExprConseqElse;
class IfLetExprConseqIf;
class IfLetExprConseqIfLet;
diff --git a/gcc/rust/ast/rust-ast-tokenstream.cc b/gcc/rust/ast/rust-ast-tokenstream.cc
index d4e23bf..8c54141 100644
--- a/gcc/rust/ast/rust-ast-tokenstream.cc
+++ b/gcc/rust/ast/rust-ast-tokenstream.cc
@@ -1428,25 +1428,6 @@ TokenStream::visit (IfExprConseqElse &expr)
}
void
-TokenStream::visit (IfExprConseqIf &expr)
-{
- visit (static_cast<IfExpr &> (expr));
- indentation ();
- tokens.push_back (Rust::Token::make (ELSE, expr.get_locus ()));
- // The "if" part of the "else if" is printed by the next visitor
- visit (expr.get_conseq_if_expr ());
-}
-
-void
-TokenStream::visit (IfExprConseqIfLet &expr)
-{
- visit (static_cast<IfExpr &> (expr));
- indentation ();
- tokens.push_back (Rust::Token::make (ELSE, expr.get_locus ()));
- visit (expr.get_conseq_if_let_expr ());
-}
-
-void
TokenStream::visit (IfLetExpr &expr)
{
tokens.push_back (Rust::Token::make (IF, expr.get_locus ()));
diff --git a/gcc/rust/ast/rust-ast-tokenstream.h b/gcc/rust/ast/rust-ast-tokenstream.h
index 8ce25e1..83fdece 100644
--- a/gcc/rust/ast/rust-ast-tokenstream.h
+++ b/gcc/rust/ast/rust-ast-tokenstream.h
@@ -198,8 +198,6 @@ private:
void visit (ForLoopExpr &expr);
void visit (IfExpr &expr);
void visit (IfExprConseqElse &expr);
- void visit (IfExprConseqIf &expr);
- void visit (IfExprConseqIfLet &expr);
void visit (IfLetExpr &expr);
void visit (IfLetExprConseqElse &expr);
void visit (IfLetExprConseqIf &expr);
diff --git a/gcc/rust/ast/rust-ast-visitor.h b/gcc/rust/ast/rust-ast-visitor.h
index c0a5b99..4c8a745 100644
--- a/gcc/rust/ast/rust-ast-visitor.h
+++ b/gcc/rust/ast/rust-ast-visitor.h
@@ -115,8 +115,6 @@ public:
virtual void visit (ForLoopExpr &expr) = 0;
virtual void visit (IfExpr &expr) = 0;
virtual void visit (IfExprConseqElse &expr) = 0;
- virtual void visit (IfExprConseqIf &expr) = 0;
- virtual void visit (IfExprConseqIfLet &expr) = 0;
virtual void visit (IfLetExpr &expr) = 0;
virtual void visit (IfLetExprConseqElse &expr) = 0;
virtual void visit (IfLetExprConseqIf &expr) = 0;
diff --git a/gcc/rust/ast/rust-ast.cc b/gcc/rust/ast/rust-ast.cc
index 7ba9be1..5f9ca48 100644
--- a/gcc/rust/ast/rust-ast.cc
+++ b/gcc/rust/ast/rust-ast.cc
@@ -1638,27 +1638,7 @@ IfExprConseqElse::as_string () const
{
std::string str = IfExpr::as_string ();
- str += "\n Else block expr: " + else_block->as_string ();
-
- return str;
-}
-
-std::string
-IfExprConseqIf::as_string () const
-{
- std::string str = IfExpr::as_string ();
-
- str += "\n Else if expr: \n " + conseq_if_expr->as_string ();
-
- return str;
-}
-
-std::string
-IfExprConseqIfLet::as_string () const
-{
- std::string str = IfExpr::as_string ();
-
- str += "\n Else if let expr: \n " + if_let_expr->as_string ();
+ str += "\n Else expr: " + else_block->as_string ();
return str;
}
@@ -4576,18 +4556,6 @@ IfExprConseqElse::accept_vis (ASTVisitor &vis)
}
void
-IfExprConseqIf::accept_vis (ASTVisitor &vis)
-{
- vis.visit (*this);
-}
-
-void
-IfExprConseqIfLet::accept_vis (ASTVisitor &vis)
-{
- vis.visit (*this);
-}
-
-void
IfLetExpr::accept_vis (ASTVisitor &vis)
{
vis.visit (*this);
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h
index bcf5ab3..f91d9e9 100644
--- a/gcc/rust/ast/rust-expr.h
+++ b/gcc/rust/ast/rust-expr.h
@@ -3753,14 +3753,14 @@ protected:
// If expression with an ending "else" expression AST node (trailing)
class IfExprConseqElse : public IfExpr
{
- std::unique_ptr<BlockExpr> else_block;
+ std::unique_ptr<ExprWithBlock> else_block;
public:
std::string as_string () const override;
IfExprConseqElse (std::unique_ptr<Expr> condition,
std::unique_ptr<BlockExpr> if_block,
- std::unique_ptr<BlockExpr> else_block,
+ std::unique_ptr<ExprWithBlock> else_block,
std::vector<Attribute> outer_attrs, Location locus)
: IfExpr (std::move (condition), std::move (if_block),
std::move (outer_attrs), locus),
@@ -3770,7 +3770,7 @@ public:
// Copy constructor with clone
IfExprConseqElse (IfExprConseqElse const &other)
- : IfExpr (other), else_block (other.else_block->clone_block_expr ())
+ : IfExpr (other), else_block (other.else_block->clone_expr_with_block ())
{}
// Overloaded assignment operator with cloning
@@ -3779,7 +3779,7 @@ public:
IfExpr::operator= (other);
// condition = other.condition->clone_expr();
// if_block = other.if_block->clone_block_expr();
- else_block = other.else_block->clone_block_expr ();
+ else_block = other.else_block->clone_expr_with_block ();
return *this;
}
@@ -3793,7 +3793,7 @@ public:
void vis_else_block (ASTVisitor &vis) { else_block->accept_vis (vis); }
// TODO: is this better? Or is a "vis_block" better?
- std::unique_ptr<BlockExpr> &get_else_block ()
+ std::unique_ptr<ExprWithBlock> &get_else_block ()
{
rust_assert (else_block != nullptr);
return else_block;
@@ -3808,67 +3808,6 @@ protected:
}
};
-// If expression with an ending "else if" expression AST node
-class IfExprConseqIf : public IfExpr
-{
- std::unique_ptr<IfExpr> conseq_if_expr;
-
-public:
- std::string as_string () const override;
-
- IfExprConseqIf (std::unique_ptr<Expr> condition,
- std::unique_ptr<BlockExpr> if_block,
- std::unique_ptr<IfExpr> conseq_if_expr,
- std::vector<Attribute> outer_attrs, Location locus)
- : IfExpr (std::move (condition), std::move (if_block),
- std::move (outer_attrs), locus),
- conseq_if_expr (std::move (conseq_if_expr))
- {}
- // outer attributes not allowed
-
- // Copy constructor with clone
- IfExprConseqIf (IfExprConseqIf const &other)
- : IfExpr (other), conseq_if_expr (other.conseq_if_expr->clone_if_expr ())
- {}
-
- // Overloaded assignment operator to use clone
- IfExprConseqIf &operator= (IfExprConseqIf const &other)
- {
- IfExpr::operator= (other);
- // condition = other.condition->clone_expr();
- // if_block = other.if_block->clone_block_expr();
- conseq_if_expr = other.conseq_if_expr->clone_if_expr ();
-
- return *this;
- }
-
- // move constructors
- IfExprConseqIf (IfExprConseqIf &&other) = default;
- IfExprConseqIf &operator= (IfExprConseqIf &&other) = default;
-
- void accept_vis (ASTVisitor &vis) override;
-
- void vis_conseq_if_expr (ASTVisitor &vis)
- {
- conseq_if_expr->accept_vis (vis);
- }
-
- // TODO: is this better? Or is a "vis_block" better?
- std::unique_ptr<IfExpr> &get_conseq_if_expr ()
- {
- rust_assert (conseq_if_expr != nullptr);
- return conseq_if_expr;
- }
-
-protected:
- /* Use covariance to implement clone function as returning this object rather
- * than base */
- IfExprConseqIf *clone_if_expr_impl () const override
- {
- return new IfExprConseqIf (*this);
- }
-};
-
// Basic "if let" expression AST node with no else
class IfLetExpr : public ExprWithBlock
{
@@ -4002,62 +3941,6 @@ protected:
}
};
-// If expression with an ending "else if let" expression AST node
-class IfExprConseqIfLet : public IfExpr
-{
- std::unique_ptr<IfLetExpr> if_let_expr;
-
-public:
- std::string as_string () const override;
-
- IfExprConseqIfLet (std::unique_ptr<Expr> condition,
- std::unique_ptr<BlockExpr> if_block,
- std::unique_ptr<IfLetExpr> conseq_if_let_expr,
- std::vector<Attribute> outer_attrs, Location locus)
- : IfExpr (std::move (condition), std::move (if_block),
- std::move (outer_attrs), locus),
- if_let_expr (std::move (conseq_if_let_expr))
- {}
- // outer attributes not allowed
-
- // Copy constructor with clone
- IfExprConseqIfLet (IfExprConseqIfLet const &other)
- : IfExpr (other), if_let_expr (other.if_let_expr->clone_if_let_expr ())
- {}
-
- // Overloaded assignment operator to use clone
- IfExprConseqIfLet &operator= (IfExprConseqIfLet const &other)
- {
- IfExpr::operator= (other);
- // condition = other.condition->clone_expr();
- // if_block = other.if_block->clone_block_expr();
- if_let_expr = other.if_let_expr->clone_if_let_expr ();
-
- return *this;
- }
-
- // move constructors
- IfExprConseqIfLet (IfExprConseqIfLet &&other) = default;
- IfExprConseqIfLet &operator= (IfExprConseqIfLet &&other) = default;
-
- void accept_vis (ASTVisitor &vis) override;
-
- // TODO: is this better? Or is a "vis_block" better?
- std::unique_ptr<IfLetExpr> &get_conseq_if_let_expr ()
- {
- rust_assert (if_let_expr != nullptr);
- return if_let_expr;
- }
-
-protected:
- /* Use covariance to implement clone function as returning this object rather
- * than base */
- IfExprConseqIfLet *clone_if_expr_impl () const override
- {
- return new IfExprConseqIfLet (*this);
- }
-};
-
/* AST node representing "if let" expression with an "else" expression at the
* end */
class IfLetExprConseqElse : public IfLetExpr
diff --git a/gcc/rust/checks/errors/rust-feature-gate.h b/gcc/rust/checks/errors/rust-feature-gate.h
index c442fd3..5571df9 100644
--- a/gcc/rust/checks/errors/rust-feature-gate.h
+++ b/gcc/rust/checks/errors/rust-feature-gate.h
@@ -95,8 +95,6 @@ public:
void visit (AST::ForLoopExpr &expr) override {}
void visit (AST::IfExpr &expr) override {}
void visit (AST::IfExprConseqElse &expr) override {}
- void visit (AST::IfExprConseqIf &expr) override {}
- void visit (AST::IfExprConseqIfLet &expr) override {}
void visit (AST::IfLetExpr &expr) override {}
void visit (AST::IfLetExprConseqElse &expr) override {}
void visit (AST::IfLetExprConseqIf &expr) override {}
diff --git a/gcc/rust/expand/rust-cfg-strip.cc b/gcc/rust/expand/rust-cfg-strip.cc
index b102049..9c6c249 100644
--- a/gcc/rust/expand/rust-cfg-strip.cc
+++ b/gcc/rust/expand/rust-cfg-strip.cc
@@ -1701,77 +1701,6 @@ CfgStrip::visit (AST::IfExprConseqElse &expr)
"attributes not allowed");
}
void
-CfgStrip::visit (AST::IfExprConseqIf &expr)
-{
- // initial strip test based on outer attrs
- expand_cfg_attrs (expr.get_outer_attrs ());
- if (fails_cfg_with_expand (expr.get_outer_attrs ()))
- {
- expr.mark_for_strip ();
- return;
- }
-
- // can't strip condition expr itself, but can strip sub-expressions
- auto &condition_expr = expr.get_condition_expr ();
- condition_expr->accept_vis (*this);
- if (condition_expr->is_marked_for_strip ())
- rust_error_at (condition_expr->get_locus (),
- "cannot strip expression in this position - outer "
- "attributes not allowed");
-
- // can't strip if block itself, but can strip sub-expressions
- auto &if_block = expr.get_if_block ();
- if_block->accept_vis (*this);
- if (if_block->is_marked_for_strip ())
- rust_error_at (if_block->get_locus (),
- "cannot strip block expression in this position - outer "
- "attributes not allowed");
-
- // can't strip if expr itself, but can strip sub-expressions
- auto &conseq_if_expr = expr.get_conseq_if_expr ();
- conseq_if_expr->accept_vis (*this);
- if (conseq_if_expr->is_marked_for_strip ())
- rust_error_at (conseq_if_expr->get_locus (),
- "cannot strip consequent if expression in this "
- "position - outer attributes not allowed");
-}
-void
-CfgStrip::visit (AST::IfExprConseqIfLet &expr)
-{
- // initial strip test based on outer attrs
- expand_cfg_attrs (expr.get_outer_attrs ());
- if (fails_cfg_with_expand (expr.get_outer_attrs ()))
- {
- expr.mark_for_strip ();
- return;
- }
-
- // can't strip condition expr itself, but can strip sub-expressions
- auto &condition_expr = expr.get_condition_expr ();
- condition_expr->accept_vis (*this);
- if (condition_expr->is_marked_for_strip ())
- rust_error_at (condition_expr->get_locus (),
- "cannot strip expression in this position - outer "
- "attributes not allowed");
-
- // can't strip if block itself, but can strip sub-expressions
- auto &if_block = expr.get_if_block ();
- if_block->accept_vis (*this);
- if (if_block->is_marked_for_strip ())
- rust_error_at (if_block->get_locus (),
- "cannot strip block expression in this position - outer "
- "attributes not allowed");
-
- // can't strip if let expr itself, but can strip sub-expressions
- auto &conseq_if_let_expr = expr.get_conseq_if_let_expr ();
- conseq_if_let_expr->accept_vis (*this);
- if (conseq_if_let_expr->is_marked_for_strip ())
- rust_error_at (conseq_if_let_expr->get_locus (),
- "cannot strip consequent if let expression in this "
- "position - outer attributes not "
- "allowed");
-}
-void
CfgStrip::visit (AST::IfLetExpr &expr)
{
// initial strip test based on outer attrs
diff --git a/gcc/rust/expand/rust-cfg-strip.h b/gcc/rust/expand/rust-cfg-strip.h
index 34a8e56..ff71c6e 100644
--- a/gcc/rust/expand/rust-cfg-strip.h
+++ b/gcc/rust/expand/rust-cfg-strip.h
@@ -131,8 +131,6 @@ public:
void visit (AST::ForLoopExpr &expr) override;
void visit (AST::IfExpr &expr) override;
void visit (AST::IfExprConseqElse &expr) override;
- void visit (AST::IfExprConseqIf &expr) override;
- void visit (AST::IfExprConseqIfLet &expr) override;
void visit (AST::IfLetExpr &expr) override;
void visit (AST::IfLetExprConseqElse &expr) override;
void visit (AST::IfLetExprConseqIf &expr) override;
diff --git a/gcc/rust/expand/rust-expand-visitor.cc b/gcc/rust/expand/rust-expand-visitor.cc
index be6bb06..04013da 100644
--- a/gcc/rust/expand/rust-expand-visitor.cc
+++ b/gcc/rust/expand/rust-expand-visitor.cc
@@ -682,24 +682,6 @@ ExpandVisitor::visit (AST::IfExprConseqElse &expr)
}
void
-ExpandVisitor::visit (AST::IfExprConseqIf &expr)
-{
- maybe_expand_expr (expr.get_condition_expr ());
-
- visit (expr.get_if_block ());
- visit (expr.get_conseq_if_expr ());
-}
-
-void
-ExpandVisitor::visit (AST::IfExprConseqIfLet &expr)
-{
- maybe_expand_expr (expr.get_condition_expr ());
-
- visit (expr.get_if_block ());
- visit (expr.get_conseq_if_let_expr ());
-}
-
-void
ExpandVisitor::visit (AST::IfLetExpr &expr)
{
visit_outer_attrs (expr);
diff --git a/gcc/rust/expand/rust-expand-visitor.h b/gcc/rust/expand/rust-expand-visitor.h
index c2b3e78..67c9a55 100644
--- a/gcc/rust/expand/rust-expand-visitor.h
+++ b/gcc/rust/expand/rust-expand-visitor.h
@@ -216,8 +216,6 @@ public:
void visit (AST::ForLoopExpr &expr) override;
void visit (AST::IfExpr &expr) override;
void visit (AST::IfExprConseqElse &expr) override;
- void visit (AST::IfExprConseqIf &expr) override;
- void visit (AST::IfExprConseqIfLet &expr) override;
void visit (AST::IfLetExpr &expr) override;
void visit (AST::IfLetExprConseqElse &expr) override;
void visit (AST::IfLetExprConseqIf &expr) override;
diff --git a/gcc/rust/hir/rust-ast-lower-base.cc b/gcc/rust/hir/rust-ast-lower-base.cc
index 972d34c..fe751ef 100644
--- a/gcc/rust/hir/rust-ast-lower-base.cc
+++ b/gcc/rust/hir/rust-ast-lower-base.cc
@@ -230,12 +230,6 @@ void
ASTLoweringBase::visit (AST::IfExprConseqElse &)
{}
void
-ASTLoweringBase::visit (AST::IfExprConseqIf &)
-{}
-void
-ASTLoweringBase::visit (AST::IfExprConseqIfLet &)
-{}
-void
ASTLoweringBase::visit (AST::IfLetExpr &)
{}
void
diff --git a/gcc/rust/hir/rust-ast-lower-base.h b/gcc/rust/hir/rust-ast-lower-base.h
index eb95435..cee2e7b 100644
--- a/gcc/rust/hir/rust-ast-lower-base.h
+++ b/gcc/rust/hir/rust-ast-lower-base.h
@@ -143,8 +143,6 @@ public:
virtual void visit (AST::ForLoopExpr &expr);
virtual void visit (AST::IfExpr &expr);
virtual void visit (AST::IfExprConseqElse &expr);
- virtual void visit (AST::IfExprConseqIf &expr);
- virtual void visit (AST::IfExprConseqIfLet &expr);
virtual void visit (AST::IfLetExpr &expr);
virtual void visit (AST::IfLetExprConseqElse &expr);
virtual void visit (AST::IfLetExprConseqIf &expr);
diff --git a/gcc/rust/hir/rust-ast-lower-block.h b/gcc/rust/hir/rust-ast-lower-block.h
index 37e4a22..5ea68cc 100644
--- a/gcc/rust/hir/rust-ast-lower-block.h
+++ b/gcc/rust/hir/rust-ast-lower-block.h
@@ -101,8 +101,6 @@ public:
void visit (AST::IfExprConseqElse &expr) override;
- void visit (AST::IfExprConseqIf &expr) override;
-
private:
ASTLoweringIfBlock ()
: ASTLoweringBase (), translated (nullptr), terminated (false)
@@ -169,11 +167,6 @@ public:
translated = ASTLoweringIfBlock::translate (&expr, &terminated);
}
- void visit (AST::IfExprConseqIf &expr) override
- {
- translated = ASTLoweringIfBlock::translate (&expr, &terminated);
- }
-
void visit (AST::IfLetExpr &expr) override
{
translated = ASTLoweringIfLetBlock::translate (&expr);
diff --git a/gcc/rust/hir/rust-ast-lower-expr.cc b/gcc/rust/hir/rust-ast-lower-expr.cc
index 50c2eae..10d9161 100644
--- a/gcc/rust/hir/rust-ast-lower-expr.cc
+++ b/gcc/rust/hir/rust-ast-lower-expr.cc
@@ -104,12 +104,6 @@ ASTLoweringExpr::visit (AST::IfExprConseqElse &expr)
}
void
-ASTLoweringExpr::visit (AST::IfExprConseqIf &expr)
-{
- translated = ASTLoweringIfBlock::translate (&expr, &terminated);
-}
-
-void
ASTLoweringExpr::visit (AST::BlockExpr &expr)
{
translated = ASTLoweringBlock::translate (&expr, &terminated);
diff --git a/gcc/rust/hir/rust-ast-lower-expr.h b/gcc/rust/hir/rust-ast-lower-expr.h
index bea254d..7c167f6 100644
--- a/gcc/rust/hir/rust-ast-lower-expr.h
+++ b/gcc/rust/hir/rust-ast-lower-expr.h
@@ -78,7 +78,6 @@ public:
void visit (AST::TupleExpr &expr) override;
void visit (AST::IfExpr &expr) override;
void visit (AST::IfExprConseqElse &expr) override;
- void visit (AST::IfExprConseqIf &expr) override;
void visit (AST::BlockExpr &expr) override;
void visit (AST::UnsafeBlockExpr &expr) override;
void visit (AST::PathInExpression &expr) override;
diff --git a/gcc/rust/hir/rust-ast-lower.cc b/gcc/rust/hir/rust-ast-lower.cc
index 9b6227c..b999c10 100644
--- a/gcc/rust/hir/rust-ast-lower.cc
+++ b/gcc/rust/hir/rust-ast-lower.cc
@@ -182,9 +182,9 @@ ASTLoweringIfBlock::visit (AST::IfExprConseqElse &expr)
HIR::BlockExpr *if_block
= ASTLoweringBlock::translate (expr.get_if_block ().get (),
&if_block_terminated);
- HIR::BlockExpr *else_block
- = ASTLoweringBlock::translate (expr.get_else_block ().get (),
- &else_block_termianted);
+ HIR::ExprWithBlock *else_block
+ = ASTLoweringExprWithBlock::translate (expr.get_else_block ().get (),
+ &else_block_termianted);
terminated = if_block_terminated && else_block_termianted;
@@ -193,37 +193,10 @@ ASTLoweringIfBlock::visit (AST::IfExprConseqElse &expr)
mappings->get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
- translated
- = new HIR::IfExprConseqElse (mapping,
- std::unique_ptr<HIR::Expr> (condition),
- std::unique_ptr<HIR::BlockExpr> (if_block),
- std::unique_ptr<HIR::BlockExpr> (else_block),
- expr.get_locus ());
-}
-
-void
-ASTLoweringIfBlock::visit (AST::IfExprConseqIf &expr)
-{
- HIR::Expr *condition
- = ASTLoweringExpr::translate (expr.get_condition_expr ().get ());
-
- bool ignored_terminated = false;
- HIR::BlockExpr *block
- = ASTLoweringBlock::translate (expr.get_if_block ().get (),
- &ignored_terminated);
- HIR::IfExpr *conseq_if_expr
- = ASTLoweringIfBlock::translate (expr.get_conseq_if_expr ().get (),
- &ignored_terminated);
-
- auto crate_num = mappings->get_current_crate ();
- Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
- mappings->get_next_hir_id (crate_num),
- UNKNOWN_LOCAL_DEFID);
-
translated = new HIR::IfExprConseqElse (
mapping, std::unique_ptr<HIR::Expr> (condition),
- std::unique_ptr<HIR::BlockExpr> (block),
- std::unique_ptr<HIR::ExprWithBlock> (conseq_if_expr), expr.get_locus ());
+ std::unique_ptr<HIR::BlockExpr> (if_block),
+ std::unique_ptr<HIR::ExprWithBlock> (else_block), expr.get_locus ());
}
void
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index d49aa6f..a7ed23e 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -8035,11 +8035,11 @@ Parser<ManagedTokenSource>::parse_if_expr (AST::AttrVec outer_attrs,
return nullptr;
}
- return std::unique_ptr<AST::IfExprConseqIfLet> (
- new AST::IfExprConseqIfLet (std::move (condition),
- std::move (if_body),
- std::move (if_let_expr),
- std::move (outer_attrs), locus));
+ return std::unique_ptr<AST::IfExprConseqElse> (
+ new AST::IfExprConseqElse (std::move (condition),
+ std::move (if_body),
+ std::move (if_let_expr),
+ std::move (outer_attrs), locus));
}
else
{
@@ -8056,11 +8056,11 @@ Parser<ManagedTokenSource>::parse_if_expr (AST::AttrVec outer_attrs,
return nullptr;
}
- return std::unique_ptr<AST::IfExprConseqIf> (
- new AST::IfExprConseqIf (std::move (condition),
- std::move (if_body),
- std::move (if_expr),
- std::move (outer_attrs), locus));
+ return std::unique_ptr<AST::IfExprConseqElse> (
+ new AST::IfExprConseqElse (std::move (condition),
+ std::move (if_body),
+ std::move (if_expr),
+ std::move (outer_attrs), locus));
}
}
default:
diff --git a/gcc/rust/resolve/rust-ast-resolve-base.cc b/gcc/rust/resolve/rust-ast-resolve-base.cc
index 2667a24..928e5ca 100644
--- a/gcc/rust/resolve/rust-ast-resolve-base.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-base.cc
@@ -295,14 +295,6 @@ ResolverBase::visit (AST::IfExprConseqElse &)
{}
void
-ResolverBase::visit (AST::IfExprConseqIf &)
-{}
-
-void
-ResolverBase::visit (AST::IfExprConseqIfLet &)
-{}
-
-void
ResolverBase::visit (AST::IfLetExpr &)
{}
diff --git a/gcc/rust/resolve/rust-ast-resolve-base.h b/gcc/rust/resolve/rust-ast-resolve-base.h
index df70303..54f4232 100644
--- a/gcc/rust/resolve/rust-ast-resolve-base.h
+++ b/gcc/rust/resolve/rust-ast-resolve-base.h
@@ -95,8 +95,6 @@ public:
void visit (AST::ForLoopExpr &);
void visit (AST::IfExpr &);
void visit (AST::IfExprConseqElse &);
- void visit (AST::IfExprConseqIf &);
- void visit (AST::IfExprConseqIfLet &);
void visit (AST::IfLetExpr &);
void visit (AST::IfLetExprConseqElse &);
void visit (AST::IfLetExprConseqIf &);
diff --git a/gcc/rust/resolve/rust-ast-resolve-expr.cc b/gcc/rust/resolve/rust-ast-resolve-expr.cc
index a6b16f3..ba9620c 100644
--- a/gcc/rust/resolve/rust-ast-resolve-expr.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-expr.cc
@@ -187,14 +187,6 @@ ResolveExpr::visit (AST::IfExprConseqElse &expr)
}
void
-ResolveExpr::visit (AST::IfExprConseqIf &expr)
-{
- ResolveExpr::go (expr.get_condition_expr ().get (), prefix, canonical_prefix);
- ResolveExpr::go (expr.get_if_block ().get (), prefix, canonical_prefix);
- ResolveExpr::go (expr.get_conseq_if_expr ().get (), prefix, canonical_prefix);
-}
-
-void
ResolveExpr::visit (AST::IfLetExpr &expr)
{
ResolveExpr::go (expr.get_value_expr ().get (), prefix, canonical_prefix);
diff --git a/gcc/rust/resolve/rust-ast-resolve-expr.h b/gcc/rust/resolve/rust-ast-resolve-expr.h
index 9863588..5294b98 100644
--- a/gcc/rust/resolve/rust-ast-resolve-expr.h
+++ b/gcc/rust/resolve/rust-ast-resolve-expr.h
@@ -50,7 +50,6 @@ public:
void visit (AST::TypeCastExpr &expr) override;
void visit (AST::IfExpr &expr) override;
void visit (AST::IfExprConseqElse &expr) override;
- void visit (AST::IfExprConseqIf &expr) override;
void visit (AST::IfLetExpr &expr) override;
void visit (AST::BlockExpr &expr) override;
void visit (AST::UnsafeBlockExpr &expr) override;
diff --git a/gcc/rust/resolve/rust-early-name-resolver.cc b/gcc/rust/resolve/rust-early-name-resolver.cc
index b3fb5a8..b1f10d8 100644
--- a/gcc/rust/resolve/rust-early-name-resolver.cc
+++ b/gcc/rust/resolve/rust-early-name-resolver.cc
@@ -457,22 +457,6 @@ EarlyNameResolver::visit (AST::IfExprConseqElse &expr)
}
void
-EarlyNameResolver::visit (AST::IfExprConseqIf &expr)
-{
- expr.get_condition_expr ()->accept_vis (*this);
- expr.get_if_block ()->accept_vis (*this);
- expr.get_conseq_if_expr ()->accept_vis (*this);
-}
-
-void
-EarlyNameResolver::visit (AST::IfExprConseqIfLet &expr)
-{
- expr.get_condition_expr ()->accept_vis (*this);
- expr.get_if_block ()->accept_vis (*this);
- expr.get_conseq_if_let_expr ()->accept_vis (*this);
-}
-
-void
EarlyNameResolver::visit (AST::IfLetExpr &expr)
{
expr.get_value_expr ()->accept_vis (*this);
diff --git a/gcc/rust/resolve/rust-early-name-resolver.h b/gcc/rust/resolve/rust-early-name-resolver.h
index c94a775..7bedbaa 100644
--- a/gcc/rust/resolve/rust-early-name-resolver.h
+++ b/gcc/rust/resolve/rust-early-name-resolver.h
@@ -177,8 +177,6 @@ private:
virtual void visit (AST::ForLoopExpr &expr);
virtual void visit (AST::IfExpr &expr);
virtual void visit (AST::IfExprConseqElse &expr);
- virtual void visit (AST::IfExprConseqIf &expr);
- virtual void visit (AST::IfExprConseqIfLet &expr);
virtual void visit (AST::IfLetExpr &expr);
virtual void visit (AST::IfLetExprConseqElse &expr);
virtual void visit (AST::IfLetExprConseqIf &expr);
diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc
index e727fbc..2d99974 100644
--- a/gcc/rust/util/rust-attributes.cc
+++ b/gcc/rust/util/rust-attributes.cc
@@ -469,14 +469,6 @@ AttributeChecker::visit (AST::IfExprConseqElse &)
{}
void
-AttributeChecker::visit (AST::IfExprConseqIf &)
-{}
-
-void
-AttributeChecker::visit (AST::IfExprConseqIfLet &)
-{}
-
-void
AttributeChecker::visit (AST::IfLetExpr &)
{}
diff --git a/gcc/rust/util/rust-attributes.h b/gcc/rust/util/rust-attributes.h
index a9c8a33..8903c93 100644
--- a/gcc/rust/util/rust-attributes.h
+++ b/gcc/rust/util/rust-attributes.h
@@ -160,8 +160,6 @@ private:
void visit (AST::ForLoopExpr &expr);
void visit (AST::IfExpr &expr);
void visit (AST::IfExprConseqElse &expr);
- void visit (AST::IfExprConseqIf &expr);
- void visit (AST::IfExprConseqIfLet &expr);
void visit (AST::IfLetExpr &expr);
void visit (AST::IfLetExprConseqElse &expr);
void visit (AST::IfLetExprConseqIf &expr);