public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] HIR: fixup MatchArm assignment operator
@ 2022-07-04 18:57 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-07-04 18:57 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:fa006a67280039e0d6c6f574896bb8d819b452fe

commit fa006a67280039e0d6c6f574896bb8d819b452fe
Author: David Faust <david.faust@oracle.com>
Date:   Fri Jul 1 12:35:27 2022 -0700

    HIR: fixup MatchArm assignment operator
    
    We overload the assignment operator to clone the vector of patterns for
    the match arm. However the existing patterns were not cleared before
    inserting the new ones, so the result was to append the new patterns
    onto the assignee arm rather than replace them.

Diff:
---
 gcc/rust/hir/tree/rust-hir-expr.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/rust/hir/tree/rust-hir-expr.h b/gcc/rust/hir/tree/rust-hir-expr.h
index 789ad78ffa2..c695412e766 100644
--- a/gcc/rust/hir/tree/rust-hir-expr.h
+++ b/gcc/rust/hir/tree/rust-hir-expr.h
@@ -3827,6 +3827,7 @@ public:
     if (other.guard_expr != nullptr)
       guard_expr = other.guard_expr->clone_expr ();
 
+    match_arm_patterns.clear ();
     match_arm_patterns.reserve (other.match_arm_patterns.size ());
     for (const auto &e : other.match_arm_patterns)
       match_arm_patterns.push_back (e->clone_pattern ());


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-04 18:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-04 18:57 [gcc/devel/rust/master] HIR: fixup MatchArm assignment operator Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).