]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Avoid copy when constructing TypeBoundPredicate
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Thu, 21 Aug 2025 10:59:19 +0000 (12:59 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Thu, 30 Oct 2025 19:58:42 +0000 (20:58 +0100)
Construct the TypeBoundPredicate in the vector instead of copying it.

gcc/rust/ChangeLog:

* typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_trait):
Construct value in place.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/typecheck/rust-hir-trait-resolve.cc

index b8dd0ad782af534ed53293e8cf86c0c5c49cf562..03121d1009e3368e19e21c166c2b43c7c9a75e38 100644 (file)
@@ -253,12 +253,10 @@ TraitResolver::resolve_trait (HIR::Trait *trait_reference)
 
   // They also inherit themselves as a bound this enables a trait item to
   // reference other Self::trait_items
-  auto self_hrtb
-    = TyTy::TypeBoundPredicate (trait_reference->get_mappings ().get_defid (),
-                               std::move (self_subst_copy),
-                               BoundPolarity::RegularBound,
-                               trait_reference->get_locus ());
-  specified_bounds.push_back (self_hrtb);
+  specified_bounds.emplace_back (trait_reference->get_mappings ().get_defid (),
+                                std::move (self_subst_copy),
+                                BoundPolarity::RegularBound,
+                                trait_reference->get_locus ());
 
   // look for any
   std::vector<TyTy::TypeBoundPredicate> super_traits;