diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-09-05 00:11:22 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2021-09-05 00:11:22 +0100 |
commit | 3438ea39e33880e582e8a11b558bfacb6fb280b0 (patch) | |
tree | 8d38ced643c91645b3eb4a52ed564933e062133d /gcc/rust | |
parent | 58637abaeab1459574d6535481d7fcc8f9620167 (diff) | |
download | gcc-3438ea39e33880e582e8a11b558bfacb6fb280b0.zip gcc-3438ea39e33880e582e8a11b558bfacb6fb280b0.tar.gz gcc-3438ea39e33880e582e8a11b558bfacb6fb280b0.tar.bz2 |
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.
Diffstat (limited to 'gcc/rust')
-rw-r--r-- | gcc/rust/ast/rust-item.h | 11 |
1 files changed, 10 insertions, 1 deletions
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<AST::GenericParam> &¶m) { - generic_params.push_back (std::move (param)); + std::vector<std::unique_ptr<GenericParam>> 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: |