This distinction isn't very helpful and makes correct parsing harder.
gcc/rust/ChangeLog:
* ast/rust-ast-full-decls.h (class ExprStmtWithoutBlock): Remove.
(class ExprStmtWithBlock): Remove.
* ast/rust-stmt.h (class ExprStmtWithoutBlock): Remove.
(class ExprStmtWithBlock): Remove.
(class ExprStmt):
Make non-abstract, add common functionality from removed base classes.
* ast/rust-ast.h: Move to_stmt to base class.
* ast/rust-ast.cc (ExprStmtWithBlock::as_string): Remove.
* ast/rust-macro.h: Use new signature for to_stmt.
(ExprStmt::as_string): New method.
(ExprStmtWithoutBlock::as_string): Remove.
(BlockExpr::strip_tail_expr): Update for removed classes.
(ExprStmtWithoutBlock::accept_vis): Remove.
(ExprStmtWithBlock::accept_vis): Remove.
(ExprStmt::accept_vis): New method.
* ast/rust-ast-dump.cc (Dump::visit): Update for removed classes.
* ast/rust-ast-dump.h: Likewise.
* ast/rust-ast-collector.h: Likewise.
* ast/rust-ast-collector.cc (TokenStream::visit): Likewise.
* ast/rust-ast-visitor.h: Likewise.
* checks/errors/rust-feature-gate.h: Likewise.
* expand/rust-expand-visitor.cc (ExpandVisitor::visit): Likewise.
* expand/rust-expand-visitor.h: Likewise.
* expand/rust-cfg-strip.cc (CfgStrip::visit): Likewise.
* expand/rust-cfg-strip.h: Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise.
* hir/rust-ast-lower-base.h: Likewise.
* hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): Likewise.
* hir/rust-ast-lower-stmt.h: Likewise.
* util/rust-attributes.cc (AttributeChecker::visit): Likewise.
* util/rust-attributes.h: Likewise.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise.
* resolve/rust-ast-resolve-base.h: Likewise.
* resolve/rust-ast-resolve-stmt.h: Likewise.
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit):
Likewise.
* resolve/rust-early-name-resolver.h: Likewise.
* parse/rust-parse-impl.h (Parser::parse_match_expr): Likewise.
(Parser::parse_stmt_or_expr_without_block): Likewise.
* parse/rust-parse.h: Likewise.
Signed-off-by: Matthew Jasper <mjjasper1@gmail.com>
}
void
-TokenCollector::visit (ExprStmtWithoutBlock &stmt)
-{
- visit (stmt.get_expr ());
-}
-
-void
-TokenCollector::visit (ExprStmtWithBlock &stmt)
+TokenCollector::visit (ExprStmt &stmt)
{
visit (stmt.get_expr ());
}
// rust-stmt.h
void visit (EmptyStmt &stmt);
void visit (LetStmt &stmt);
- void visit (ExprStmtWithoutBlock &stmt);
- void visit (ExprStmtWithBlock &stmt);
+ void visit (ExprStmt &stmt);
// rust-type.h
void visit (TraitBound &bound);
}
void
-Dump::visit (ExprStmtWithoutBlock &stmt)
-{
- visit (stmt.get_expr ());
-}
-
-void
-Dump::visit (ExprStmtWithBlock &stmt)
+Dump::visit (ExprStmt &stmt)
{
visit (stmt.get_expr ());
}
// rust-stmt.h
void visit (EmptyStmt &stmt);
void visit (LetStmt &stmt);
- void visit (ExprStmtWithoutBlock &stmt);
- void visit (ExprStmtWithBlock &stmt);
+ void visit (ExprStmt &stmt);
// rust-type.h
void visit (TraitBound &bound);
class EmptyStmt;
class LetStmt;
class ExprStmt;
-class ExprStmtWithoutBlock;
-class ExprStmtWithBlock;
// rust-item.h
class TypeParam;
// rust-stmt.h
virtual void visit (EmptyStmt &stmt) = 0;
virtual void visit (LetStmt &stmt) = 0;
- virtual void visit (ExprStmtWithoutBlock &stmt) = 0;
- virtual void visit (ExprStmtWithBlock &stmt) = 0;
+ virtual void visit (ExprStmt &stmt) = 0;
// rust-type.h
virtual void visit (TraitBound &bound) = 0;
}
std::string
-ExprStmtWithBlock::as_string () const
+ExprStmt::as_string () const
{
- std::string str = indent_spaces (enter) + "ExprStmtWithBlock: \n";
+ std::string str = indent_spaces (enter) + "ExprStmt: \n";
if (expr == nullptr)
{
{
indent_spaces (enter);
str += expr->as_string ();
+ if (semicolon_followed)
+ str += ";";
indent_spaces (out);
}
return str;
}
-std::string
-ExprStmtWithoutBlock::as_string () const
-{
- std::string str ("ExprStmtWithoutBlock:\n");
- indent_spaces (enter);
- str += indent_spaces (stay);
-
- if (expr == nullptr)
- str += "none (this shouldn't happen and is probably an error)";
- else
- str += expr->as_string ();
- indent_spaces (out);
-
- return str;
-}
-
std::string
FunctionParam::as_string () const
{
{
auto &stmt = static_cast<ExprStmt &> (*statements.back ());
- if (stmt.get_type () == ExprStmt::ExprStmtType::WITH_BLOCK)
+ if (!stmt.is_semicolon_followed ())
{
- auto &stmt_block = static_cast<ExprStmtWithBlock &> (stmt);
- if (!stmt_block.is_semicolon_followed ())
- {
- expr = std::move (stmt_block.get_expr ());
- statements.pop_back ();
- }
+ expr = std::move (stmt.get_expr ());
+ statements.pop_back ();
}
}
}
}
void
-ExprStmtWithoutBlock::accept_vis (ASTVisitor &vis)
-{
- vis.visit (*this);
-}
-
-void
-ExprStmtWithBlock::accept_vis (ASTVisitor &vis)
+ExprStmt::accept_vis (ASTVisitor &vis)
{
vis.visit (*this);
}
virtual std::vector<Attribute> &get_outer_attrs () = 0;
+ virtual Expr *to_stmt () const { return clone_expr_impl (); }
+
protected:
// Constructor
Expr () : node_id (Analysis::Mappings::get ()->get_next_node_id ()) {}
{
return clone_expr_without_block_impl ();
}
-
- virtual ExprWithoutBlock *to_stmt () const { return clone_expr_impl (); }
};
/* HACK: IdentifierExpr, delete when figure out identifier vs expr problem in
return clone_macro_invocation_impl ();
}
- ExprWithoutBlock *to_stmt () const override
+ Expr *to_stmt () const override
{
auto new_impl = clone_macro_invocation_impl ();
LetStmt *clone_stmt_impl () const override { return new LetStmt (*this); }
};
-/* Abstract base class for expression statements (statements containing an
- * expression) */
+// Expression statements (statements containing an expression)
class ExprStmt : public Stmt
{
-public:
- enum ExprStmtType
- {
- WITH_BLOCK,
- WITHOUT_BLOCK
- };
-
-protected:
+ std::unique_ptr<Expr> expr;
Location locus;
+ bool semicolon_followed;
public:
Location get_locus () const override final { return locus; }
bool is_item () const override final { return false; }
bool is_expr () const override final { return true; }
-
- virtual ExprStmtType get_type () const = 0;
-
-protected:
- ExprStmt (Location locus) : locus (locus) {}
-};
-
-/* Statement containing an expression without a block (or, due to technical
- * difficulties, can only be guaranteed to hold an expression). */
-class ExprStmtWithoutBlock : public ExprStmt
-{
- // TODO: ensure that this works
- std::unique_ptr<ExprWithoutBlock> expr;
- /* HACK: cannot ensure type safety of ExprWithoutBlock due to Pratt parsing,
- * so have to store more general type of Expr. FIXME: fix this issue somehow
- * or redesign AST. */
- // std::unique_ptr<Expr> expr;
-
-public:
- std::string as_string () const override;
-
- ExprStmtWithoutBlock (std::unique_ptr<ExprWithoutBlock> expr, Location locus)
- : ExprStmt (locus), expr (std::move (expr->to_stmt ()))
- {}
-
- /*ExprStmtWithoutBlock (std::unique_ptr<Expr> expr, Location locus)
- : ExprStmt (locus), expr (std::move (expr))
- {}*/
-
- // Copy constructor with clone
- ExprStmtWithoutBlock (ExprStmtWithoutBlock const &other) : ExprStmt (other)
- {
- // guard to prevent null dereference (only required if error state)
- if (other.expr != nullptr)
- expr = other.expr->clone_expr_without_block ();
- }
- /*ExprStmtWithoutBlock (ExprStmtWithoutBlock const &other)
- : ExprStmt (other), expr (other.expr->clone_expr ())
- {}*/
-
- // Overloaded assignment operator to clone
- ExprStmtWithoutBlock &operator= (ExprStmtWithoutBlock const &other)
- {
- ExprStmt::operator= (other);
- // expr = other.expr->clone_expr ();
-
- // guard to prevent null dereference (only required if error state)
- if (other.expr != nullptr)
- expr = other.expr->clone_expr_without_block ();
- else
- expr = nullptr;
-
- return *this;
- }
-
- // move constructors
- ExprStmtWithoutBlock (ExprStmtWithoutBlock &&other) = default;
- ExprStmtWithoutBlock &operator= (ExprStmtWithoutBlock &&other) = default;
-
- void accept_vis (ASTVisitor &vis) override;
-
- // Invalid if expr is null, so base stripping on that.
- void mark_for_strip () override { expr = nullptr; }
- bool is_marked_for_strip () const override { return expr == nullptr; }
-
- // TODO: is this better? Or is a "vis_block" better?
- std::unique_ptr<ExprWithoutBlock> &get_expr ()
- {
- rust_assert (expr != nullptr);
- return expr;
- }
-
- ExprStmtType get_type () const override
- {
- return ExprStmtType::WITHOUT_BLOCK;
- };
-
-protected:
- /* Use covariance to implement clone function as returning this object rather
- * than base */
- ExprStmtWithoutBlock *clone_stmt_impl () const override
- {
- return new ExprStmtWithoutBlock (*this);
- }
-};
-
-// Statement containing an expression with a block
-class ExprStmtWithBlock : public ExprStmt
-{
- std::unique_ptr<ExprWithBlock> expr;
- bool semicolon_followed;
-
-public:
std::string as_string () const override;
std::vector<LetStmt *> locals;
- ExprStmtWithBlock (std::unique_ptr<ExprWithBlock> expr, Location locus,
- bool semicolon_followed)
- : ExprStmt (locus), expr (std::move (expr)),
+ ExprStmt (std::unique_ptr<Expr> expr, Location locus, bool semicolon_followed)
+ : expr (expr->to_stmt ()), locus (locus),
semicolon_followed (semicolon_followed)
{}
// Copy constructor with clone
- ExprStmtWithBlock (ExprStmtWithBlock const &other) : ExprStmt (other)
+ ExprStmt (ExprStmt const &other)
+ : locus (other.locus), semicolon_followed (other.semicolon_followed)
{
// guard to prevent null dereference (only required if error state)
if (other.expr != nullptr)
- expr = other.expr->clone_expr_with_block ();
+ expr = other.expr->clone_expr ();
}
// Overloaded assignment operator to clone
- ExprStmtWithBlock &operator= (ExprStmtWithBlock const &other)
+ ExprStmt &operator= (ExprStmt const &other)
{
- ExprStmt::operator= (other);
+ Stmt::operator= (other);
// guard to prevent null dereference (only required if error state)
if (other.expr != nullptr)
- expr = other.expr->clone_expr_with_block ();
+ expr = other.expr->clone_expr ();
else
expr = nullptr;
+ locus = other.locus;
+ semicolon_followed = other.semicolon_followed;
+
return *this;
}
// move constructors
- ExprStmtWithBlock (ExprStmtWithBlock &&other) = default;
- ExprStmtWithBlock &operator= (ExprStmtWithBlock &&other) = default;
+ ExprStmt (ExprStmt &&other) = default;
+ ExprStmt &operator= (ExprStmt &&other) = default;
void accept_vis (ASTVisitor &vis) override;
bool is_marked_for_strip () const override { return expr == nullptr; }
// TODO: is this better? Or is a "vis_block" better?
- std::unique_ptr<ExprWithBlock> &get_expr ()
+ std::unique_ptr<Expr> &get_expr ()
{
rust_assert (expr != nullptr);
return expr;
bool is_semicolon_followed () const { return semicolon_followed; }
- ExprStmtType get_type () const override { return ExprStmtType::WITH_BLOCK; };
-
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */
- ExprStmtWithBlock *clone_stmt_impl () const override
- {
- return new ExprStmtWithBlock (*this);
- }
+ ExprStmt *clone_stmt_impl () const override { return new ExprStmt (*this); }
};
} // namespace AST
void visit (AST::AltPattern &pattern) override {}
void visit (AST::EmptyStmt &stmt) override {}
void visit (AST::LetStmt &stmt) override {}
- void visit (AST::ExprStmtWithoutBlock &stmt) override {}
- void visit (AST::ExprStmtWithBlock &stmt) override {}
+ void visit (AST::ExprStmt &stmt) override {}
void visit (AST::TraitBound &bound) override {}
void visit (AST::ImplTraitType &type) override {}
void visit (AST::TraitObjectType &type) override {}
}
}
void
-CfgStrip::visit (AST::ExprStmtWithoutBlock &stmt)
-{
- // outer attributes associated with expr, so rely on expr
-
- // guard - should prevent null pointer expr
- if (stmt.is_marked_for_strip ())
- return;
-
- // strip if expr is to be stripped
- auto &expr = stmt.get_expr ();
- expr->accept_vis (*this);
- if (expr->is_marked_for_strip ())
- {
- stmt.mark_for_strip ();
- return;
- }
-}
-void
-CfgStrip::visit (AST::ExprStmtWithBlock &stmt)
+CfgStrip::visit (AST::ExprStmt &stmt)
{
// outer attributes associated with expr, so rely on expr
void visit (AST::EmptyStmt &) override;
void visit (AST::LetStmt &stmt) override;
- void visit (AST::ExprStmtWithoutBlock &stmt) override;
- void visit (AST::ExprStmtWithBlock &stmt) override;
+ void visit (AST::ExprStmt &stmt) override;
void visit (AST::TraitBound &bound) override;
void visit (AST::ImplTraitType &type) override;
}
void
-ExpandVisitor::visit (AST::ExprStmtWithoutBlock &stmt)
-{
- visit (stmt.get_expr ());
-}
-
-void
-ExpandVisitor::visit (AST::ExprStmtWithBlock &stmt)
+ExpandVisitor::visit (AST::ExprStmt &stmt)
{
visit (stmt.get_expr ());
}
void visit (AST::EmptyStmt &) override;
void visit (AST::LetStmt &stmt) override;
- void visit (AST::ExprStmtWithoutBlock &stmt) override;
- void visit (AST::ExprStmtWithBlock &stmt) override;
+ void visit (AST::ExprStmt &stmt) override;
void visit (AST::TraitBound &bound) override;
void visit (AST::ImplTraitType &type) override;
ASTLoweringBase::visit (AST::LetStmt &)
{}
void
-ASTLoweringBase::visit (AST::ExprStmtWithoutBlock &)
-{}
-void
-ASTLoweringBase::visit (AST::ExprStmtWithBlock &)
+ASTLoweringBase::visit (AST::ExprStmt &)
{}
// rust-type.h
// rust-stmt.h
virtual void visit (AST::EmptyStmt &stmt);
virtual void visit (AST::LetStmt &stmt);
- virtual void visit (AST::ExprStmtWithoutBlock &stmt);
- virtual void visit (AST::ExprStmtWithBlock &stmt);
+ virtual void visit (AST::ExprStmt &stmt);
// rust-type.h
virtual void visit (AST::TraitBound &bound);
}
void
-ASTLoweringStmt::visit (AST::ExprStmtWithBlock &stmt)
-{
- HIR::ExprWithBlock *expr
- = ASTLoweringExprWithBlock::translate (stmt.get_expr ().get (),
- &terminated);
-
- auto crate_num = mappings->get_current_crate ();
- Analysis::NodeMapping mapping (crate_num, stmt.get_node_id (),
- mappings->get_next_hir_id (crate_num),
- UNKNOWN_LOCAL_DEFID);
- translated
- = new HIR::ExprStmt (mapping, std::unique_ptr<HIR::ExprWithBlock> (expr),
- stmt.get_locus (), !stmt.is_semicolon_followed ());
-}
-
-void
-ASTLoweringStmt::visit (AST::ExprStmtWithoutBlock &stmt)
+ASTLoweringStmt::visit (AST::ExprStmt &stmt)
{
HIR::Expr *expr
= ASTLoweringExpr::translate (stmt.get_expr ().get (), &terminated);
Analysis::NodeMapping mapping (crate_num, stmt.get_node_id (),
mappings->get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
- translated = new HIR::ExprStmt (mapping, std::unique_ptr<HIR::Expr> (expr),
- stmt.get_locus ());
+ translated
+ = new HIR::ExprStmt (mapping, std::unique_ptr<HIR::Expr> (expr),
+ stmt.get_locus (), !stmt.is_semicolon_followed ());
}
void
public:
static HIR::Stmt *translate (AST::Stmt *stmt, bool *terminated);
- void visit (AST::ExprStmtWithBlock &stmt) override;
- void visit (AST::ExprStmtWithoutBlock &stmt) override;
+ void visit (AST::ExprStmt &stmt) override;
void visit (AST::ConstantItem &constant) override;
void visit (AST::LetStmt &stmt) override;
void visit (AST::TupleStruct &struct_decl) override;
/* Parses a expression statement containing an expression with block.
* Disambiguates internally. */
template <typename ManagedTokenSource>
-std::unique_ptr<AST::ExprStmtWithBlock>
+std::unique_ptr<AST::ExprStmt>
Parser<ManagedTokenSource>::parse_expr_stmt_with_block (
AST::AttrVec outer_attrs)
{
auto locus = expr_parsed->get_locus ();
// return expr stmt created from expr
- return std::unique_ptr<AST::ExprStmtWithBlock> (
- new AST::ExprStmtWithBlock (std::move (expr_parsed), locus,
- lexer.peek_token ()->get_id () == SEMICOLON));
+ return std::unique_ptr<AST::ExprStmt> (
+ new AST::ExprStmt (std::move (expr_parsed), locus,
+ lexer.peek_token ()->get_id () == SEMICOLON));
}
/* Parses an expression statement containing an expression without block.
* Disambiguates further. */
template <typename ManagedTokenSource>
-std::unique_ptr<AST::ExprStmtWithoutBlock>
+std::unique_ptr<AST::ExprStmt>
Parser<ManagedTokenSource>::parse_expr_stmt_without_block (
AST::AttrVec outer_attrs, ParseRestrictions restrictions)
{
if (!skip_token (SEMICOLON))
return nullptr;
- return std::unique_ptr<AST::ExprStmtWithoutBlock> (
- new AST::ExprStmtWithoutBlock (std::move (expr), locus));
+ return std::unique_ptr<AST::ExprStmt> (
+ new AST::ExprStmt (std::move (expr), locus, true));
}
/* Parses an expression without a block associated with it (further
restrictions.expr_can_be_stmt = true;
restrictions.consume_semi = false;
- std::unique_ptr<AST::ExprStmt> expr = parse_expr_stmt ({}, restrictions);
- if (expr == nullptr)
+ std::unique_ptr<AST::ExprStmt> expr_stmt
+ = parse_expr_stmt ({}, restrictions);
+
+ if (expr_stmt == nullptr)
{
Error error (lexer.peek_token ()->get_locus (),
"failed to parse expr in match arm in match expr");
// skip somewhere?
return nullptr;
}
- bool is_expr_without_block
- = expr->get_type () == AST::ExprStmt::ExprStmtType::WITHOUT_BLOCK;
- // construct match case expr and add to cases
- switch (expr->get_type ())
- {
- case AST::ExprStmt::ExprStmtType::WITH_BLOCK: {
- AST::ExprStmtWithBlock *cast
- = static_cast<AST::ExprStmtWithBlock *> (expr.get ());
- std::unique_ptr<AST::Expr> e = cast->get_expr ()->clone_expr ();
- match_arms.push_back (
- AST::MatchCase (std::move (arm), std::move (e)));
- }
- break;
+ std::unique_ptr<AST::Expr> expr = expr_stmt->get_expr ()->clone_expr ();
+ bool is_expr_without_block
+ = expr_stmt->get_expr ()->is_expr_without_block ();
- case AST::ExprStmt::ExprStmtType::WITHOUT_BLOCK: {
- AST::ExprStmtWithoutBlock *cast
- = static_cast<AST::ExprStmtWithoutBlock *> (expr.get ());
- std::unique_ptr<AST::Expr> e = cast->get_expr ()->clone_expr ();
- match_arms.push_back (
- AST::MatchCase (std::move (arm), std::move (e)));
- }
- break;
- }
+ match_arms.push_back (AST::MatchCase (std::move (arm), std::move (expr)));
// handle comma presence
if (lexer.peek_token ()->get_id () != COMMA)
// internal block expr must either have semicolons followed, or evaluate to
// ()
auto locus = expr->get_locus ();
- std::unique_ptr<AST::ExprStmtWithBlock> stmt (
- new AST::ExprStmtWithBlock (std::move (expr), locus,
- tok->get_id () == SEMICOLON));
+ std::unique_ptr<AST::ExprStmt> stmt (
+ new AST::ExprStmt (std::move (expr), locus, tok->get_id () == SEMICOLON));
if (tok->get_id () == SEMICOLON)
lexer.skip_token ();
// must be expression statement
lexer.skip_token ();
- std::unique_ptr<AST::ExprStmtWithoutBlock> stmt (
- new AST::ExprStmtWithoutBlock (std::move (expr),
- t->get_locus ()));
+ std::unique_ptr<AST::ExprStmt> stmt (
+ new AST::ExprStmt (std::move (expr), t->get_locus (), true));
return ExprOrStmt (std::move (stmt));
}
// must be expression statement
lexer.skip_token ();
- std::unique_ptr<AST::ExprStmtWithoutBlock> stmt (
- new AST::ExprStmtWithoutBlock (std::move (expr),
- t->get_locus ()));
+ std::unique_ptr<AST::ExprStmt> stmt (
+ new AST::ExprStmt (std::move (expr), t->get_locus (), true));
return ExprOrStmt (std::move (stmt));
}
// must be expression statement
lexer.skip_token ();
- std::unique_ptr<AST::ExprStmtWithoutBlock> stmt (
- new AST::ExprStmtWithoutBlock (std::move (expr),
- t->get_locus ()));
+ std::unique_ptr<AST::ExprStmt> stmt (
+ new AST::ExprStmt (std::move (expr), t->get_locus (), true));
return ExprOrStmt (std::move (stmt));
}
if (expr)
{
- std::unique_ptr<AST::ExprStmtWithoutBlock> stmt (
- new AST::ExprStmtWithoutBlock (std::move (expr),
- t->get_locus ()));
+ std::unique_ptr<AST::ExprStmt> stmt (
+ new AST::ExprStmt (std::move (expr), t->get_locus (), true));
return ExprOrStmt (std::move (stmt));
}
else
{
// statement
lexer.skip_token ();
- std::unique_ptr<AST::ExprStmtWithoutBlock> stmt (
- new AST::ExprStmtWithoutBlock (std::move (expr),
- stmt_or_expr_loc));
+ std::unique_ptr<AST::ExprStmt> stmt (
+ new AST::ExprStmt (std::move (expr), stmt_or_expr_loc, true));
return ExprOrStmt (std::move (stmt));
}
{
// statement
lexer.skip_token ();
- std::unique_ptr<AST::ExprStmtWithoutBlock> stmt (
- new AST::ExprStmtWithoutBlock (std::move (struct_expr),
- stmt_or_expr_loc));
+ std::unique_ptr<AST::ExprStmt> stmt (
+ new AST::ExprStmt (std::move (struct_expr), stmt_or_expr_loc,
+ true));
return ExprOrStmt (std::move (stmt));
}
{
lexer.skip_token ();
- std::unique_ptr<AST::ExprStmtWithoutBlock> stmt (
- new AST::ExprStmtWithoutBlock (std::move (expr),
- stmt_or_expr_loc));
+ std::unique_ptr<AST::ExprStmt> stmt (
+ new AST::ExprStmt (std::move (expr), stmt_or_expr_loc, true));
return ExprOrStmt (std::move (stmt));
}
std::unique_ptr<AST::ExprStmt> parse_expr_stmt (AST::AttrVec outer_attrs,
ParseRestrictions restrictions
= ParseRestrictions ());
- std::unique_ptr<AST::ExprStmtWithBlock>
+ std::unique_ptr<AST::ExprStmt>
parse_expr_stmt_with_block (AST::AttrVec outer_attrs);
- std::unique_ptr<AST::ExprStmtWithoutBlock>
+ std::unique_ptr<AST::ExprStmt>
parse_expr_stmt_without_block (AST::AttrVec outer_attrs,
ParseRestrictions restrictions
= ParseRestrictions ());
{}
void
-ResolverBase::visit (AST::ExprStmtWithoutBlock &)
-{}
-
-void
-ResolverBase::visit (AST::ExprStmtWithBlock &)
+ResolverBase::visit (AST::ExprStmt &)
{}
void
void visit (AST::EmptyStmt &);
void visit (AST::LetStmt &);
- void visit (AST::ExprStmtWithoutBlock &);
- void visit (AST::ExprStmtWithBlock &);
+ void visit (AST::ExprStmt &);
void visit (AST::TraitBound &);
void visit (AST::ImplTraitType &);
stmt->accept_vis (resolver);
}
- void visit (AST::ExprStmtWithBlock &stmt) override
- {
- ResolveExpr::go (stmt.get_expr ().get (), prefix, canonical_prefix);
- }
-
- void visit (AST::ExprStmtWithoutBlock &stmt) override
+ void visit (AST::ExprStmt &stmt) override
{
ResolveExpr::go (stmt.get_expr ().get (), prefix, canonical_prefix);
}
}
void
-EarlyNameResolver::visit (AST::ExprStmtWithoutBlock &stmt)
-{
- stmt.get_expr ()->accept_vis (*this);
-}
-
-void
-EarlyNameResolver::visit (AST::ExprStmtWithBlock &stmt)
+EarlyNameResolver::visit (AST::ExprStmt &stmt)
{
stmt.get_expr ()->accept_vis (*this);
}
virtual void visit (AST::AltPattern &pattern);
virtual void visit (AST::EmptyStmt &stmt);
virtual void visit (AST::LetStmt &stmt);
- virtual void visit (AST::ExprStmtWithoutBlock &stmt);
- virtual void visit (AST::ExprStmtWithBlock &stmt);
+ virtual void visit (AST::ExprStmt &stmt);
virtual void visit (AST::TraitBound &bound);
virtual void visit (AST::ImplTraitType &type);
virtual void visit (AST::TraitObjectType &type);
{}
void
-AttributeChecker::visit (AST::ExprStmtWithoutBlock &)
-{}
-
-void
-AttributeChecker::visit (AST::ExprStmtWithBlock &)
+AttributeChecker::visit (AST::ExprStmt &)
{}
// rust-type.h
// rust-stmt.h
void visit (AST::EmptyStmt &stmt);
void visit (AST::LetStmt &stmt);
- void visit (AST::ExprStmtWithoutBlock &stmt);
- void visit (AST::ExprStmtWithBlock &stmt);
+ void visit (AST::ExprStmt &stmt);
// rust-type.h
void visit (AST::TraitBound &bound);