From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 84DDA38582A2; Mon, 4 Jul 2022 18:57:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 84DDA38582A2 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] HIR: fixup MatchArm assignment operator X-Act-Checkin: gcc X-Git-Author: David Faust X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: 33912c1a08d3892d3c72506aed38771754b9cf54 X-Git-Newrev: fa006a67280039e0d6c6f574896bb8d819b452fe Message-Id: <20220704185741.84DDA38582A2@sourceware.org> Date: Mon, 4 Jul 2022 18:57:41 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2022 18:57:41 -0000 https://gcc.gnu.org/g:fa006a67280039e0d6c6f574896bb8d819b452fe commit fa006a67280039e0d6c6f574896bb8d819b452fe Author: David Faust 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 ());