Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions gcc/rust/ast/rust-ast-builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,7 @@ Builder::match (std::unique_ptr<Expr> &&scrutinee,
MatchArm
Builder::match_arm (std::unique_ptr<Pattern> &&pattern)
{
auto patterns = std::vector<std::unique_ptr<Pattern>> ();
patterns.emplace_back (std::move (pattern));

return MatchArm (std::move (patterns), loc);
return MatchArm (std::move (pattern), loc);
}

MatchCase
Expand Down
15 changes: 3 additions & 12 deletions gcc/rust/ast/rust-ast-collector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1431,10 +1431,7 @@ TokenCollector::visit (WhileLetLoopExpr &expr)
push (Rust::Token::make (WHILE, expr.get_locus ()));
push (Rust::Token::make (LET, UNDEF_LOCATION));
// TODO: The reference mention only one Pattern
for (auto &item : expr.get_patterns ())
{
visit (item);
}
visit (expr.get_pattern ());
push (Rust::Token::make (EQUAL, UNDEF_LOCATION));
visit (expr.get_scrutinee_expr ());
visit (expr.get_loop_block ());
Expand Down Expand Up @@ -1473,10 +1470,7 @@ TokenCollector::visit (IfLetExpr &expr)
{
push (Rust::Token::make (IF, expr.get_locus ()));
push (Rust::Token::make (LET, UNDEF_LOCATION));
for (auto &pattern : expr.get_patterns ())
{
visit (pattern);
}
visit (expr.get_pattern ());
push (Rust::Token::make (EQUAL, UNDEF_LOCATION));
visit (expr.get_value_expr ());
visit (expr.get_if_block ());
Expand All @@ -1495,10 +1489,7 @@ void
TokenCollector::visit (MatchArm &arm)
{
visit_items_as_lines (arm.get_outer_attrs ());
for (auto &pattern : arm.get_patterns ())
{
visit (pattern);
}
visit (arm.get_pattern ());
if (arm.has_match_arm_guard ())
{
push (Rust::Token::make (IF, UNDEF_LOCATION));
Expand Down
9 changes: 3 additions & 6 deletions gcc/rust/ast/rust-ast-pointer-visitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,7 @@ void
PointerVisitor::visit (AST::WhileLetLoopExpr &expr)
{
visit_outer_attrs (expr);
for (auto &pattern : expr.get_patterns ())
reseat (pattern);
reseat (expr.get_pattern ());

if (expr.has_loop_label ())
visit (expr.get_loop_label ());
Expand Down Expand Up @@ -627,8 +626,7 @@ void
PointerVisitor::visit (AST::IfLetExpr &expr)
{
visit_outer_attrs (expr);
for (auto &pattern : expr.get_patterns ())
reseat (pattern);
reseat (expr.get_pattern ());
reseat (expr.get_value_expr_ptr ());
visit (expr.get_if_block ());
}
Expand All @@ -644,8 +642,7 @@ void
PointerVisitor::visit (AST::MatchArm &arm)
{
visit_outer_attrs (arm);
for (auto &pattern : arm.get_patterns ())
reseat (pattern);
reseat (arm.get_pattern ());
if (arm.has_match_arm_guard ())
reseat (arm.get_guard_expr_ptr ());
}
Expand Down
9 changes: 3 additions & 6 deletions gcc/rust/ast/rust-ast-visitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,7 @@ void
DefaultASTVisitor::visit (AST::WhileLetLoopExpr &expr)
{
visit_outer_attrs (expr);
for (auto &pattern : expr.get_patterns ())
visit (pattern);
visit (expr.get_pattern ());

if (expr.has_loop_label ())
visit (expr.get_loop_label ());
Expand Down Expand Up @@ -647,8 +646,7 @@ void
DefaultASTVisitor::visit (AST::IfLetExpr &expr)
{
visit_outer_attrs (expr);
for (auto &pattern : expr.get_patterns ())
visit (pattern);
visit (expr.get_pattern ());
visit (expr.get_value_expr ());
visit (expr.get_if_block ());
}
Expand All @@ -664,8 +662,7 @@ void
DefaultASTVisitor::visit (AST::MatchArm &arm)
{
visit_outer_attrs (arm);
for (auto &pattern : arm.get_patterns ())
visit (pattern);
visit (arm.get_pattern ());
if (arm.has_match_arm_guard ())
visit (arm.get_guard_expr ());
}
Expand Down
15 changes: 6 additions & 9 deletions gcc/rust/ast/rust-ast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1943,14 +1943,13 @@ IfLetExpr::as_string () const
str += append_attributes (outer_attrs, OUTER);

str += "\n Condition match arm patterns: ";
if (match_arm_patterns.empty ())
if (match_arm_pattern == nullptr)
{
str += "none";
}
else
{
for (const auto &pattern : match_arm_patterns)
str += "\n " + pattern->as_string ();
str += "\n " + match_arm_pattern->as_string ();
}

str += "\n Scrutinee expr: " + value->as_string ();
Expand Down Expand Up @@ -2167,14 +2166,13 @@ WhileLetLoopExpr::as_string () const
str += get_loop_label ().as_string ();

str += "\n Match arm patterns: ";
if (match_arm_patterns.empty ())
if (match_arm_pattern == nullptr)
{
str += "none";
}
else
{
for (const auto &pattern : match_arm_patterns)
str += "\n " + pattern->as_string ();
str += "\n " + match_arm_pattern->as_string ();
}

str += "\n Scrutinee expr: " + scrutinee->as_string ();
Expand Down Expand Up @@ -2253,14 +2251,13 @@ MatchArm::as_string () const
std::string str = append_attributes (outer_attrs, OUTER);

str += "\nPatterns: ";
if (match_arm_patterns.empty ())
if (match_arm_pattern == nullptr)
{
str += "none";
}
else
{
for (const auto &pattern : match_arm_patterns)
str += "\n " + pattern->as_string ();
str += "\n " + match_arm_pattern->as_string ();
}

str += "\nGuard expr: ";
Expand Down
6 changes: 1 addition & 5 deletions gcc/rust/ast/rust-desugar-question-mark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ MatchArm
make_match_arm (std::unique_ptr<Pattern> &&pattern)
{
auto loc = pattern->get_locus ();

auto patterns = std::vector<std::unique_ptr<Pattern>> ();
patterns.emplace_back (std::move (pattern));

return MatchArm (std::move (patterns), loc);
return MatchArm (std::move (pattern), loc);
}

MatchCase
Expand Down
4 changes: 2 additions & 2 deletions gcc/rust/ast/rust-desugar-while-let.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ DesugarWhileLet::DesugarCtx::make_continue_arm (
std::unique_ptr<Expr>
DesugarWhileLet::desugar (WhileLetLoopExpr &expr)
{
rust_assert (expr.get_patterns ().size () == 1);
rust_assert (expr.get_pattern () != nullptr);

auto pattern = expr.get_patterns ()[0]->clone_pattern ();
auto pattern = expr.get_pattern ()->clone_pattern ();
auto body = expr.get_loop_block ().clone_block_expr ();
auto scrutinee = expr.get_scrutinee_expr ().clone_expr ();

Expand Down
Loading