From 3438ea39e33880e582e8a11b558bfacb6fb280b0 Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Sun, 5 Sep 2021 00:11:22 +0100 Subject: Ensure the implicit Self is first in the generic arguments Traits implement self by creating an implicit Self TypeParam but when we need to support generic arguments we must ensure Self is substituted first so that the reset of the arguments are handled as we expect. --- gcc/rust/ast/rust-item.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h index dcfc3d1..0578329 100644 --- a/gcc/rust/ast/rust-item.h +++ b/gcc/rust/ast/rust-item.h @@ -3535,7 +3535,16 @@ public: void insert_implict_self (std::unique_ptr &¶m) { - generic_params.push_back (std::move (param)); + std::vector> new_list; + new_list.reserve (generic_params.size () + 1); + + new_list.push_back (std::move (param)); + for (auto &p : generic_params) + { + new_list.push_back (std::move (p)); + } + + generic_params = std::move (new_list); } protected: -- cgit v1.1