From: Arthur Cohen Date: Thu, 16 Jan 2025 13:46:06 +0000 (+0100) Subject: gccrs: derive(Copy): Improve bounds when deriving Copy X-Git-Tag: basepoints/gcc-16~822 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9061a823a114f1cd8c81ffafcba4eca31b0d1c96;p=thirdparty%2Fgcc.git gccrs: derive(Copy): Improve bounds when deriving Copy gcc/rust/ChangeLog: * expand/rust-derive-copy.cc: Always add an extra Copy bound on generic Copy impls. --- diff --git a/gcc/rust/expand/rust-derive-copy.cc b/gcc/rust/expand/rust-derive-copy.cc index 31b4819c042..1d5f72bd656 100644 --- a/gcc/rust/expand/rust-derive-copy.cc +++ b/gcc/rust/expand/rust-derive-copy.cc @@ -52,7 +52,7 @@ DeriveCopy::copy_impl ( // for example: // // #[derive(Copy)] - // struct Be { ... } + // struct Be { ... } // // we need to generate the impl block: // @@ -87,7 +87,12 @@ DeriveCopy::copy_impl ( = GenericArg::create_type (std::move (associated_type)); generic_args.push_back (std::move (type_arg)); - auto impl_type_param = builder.new_type_param (type_param); + std::vector> extra_bounds; + extra_bounds.emplace_back (std::unique_ptr ( + new TraitBound (builder.type_path (LangItem::Kind::COPY), loc))); + + auto impl_type_param + = builder.new_type_param (type_param, std::move (extra_bounds)); impl_generics.push_back (std::move (impl_type_param)); } break;