aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2025-01-16 14:46:06 +0100
committerCohenArthur <arthur.cohen@embecosm.com>2025-01-21 15:18:52 +0000
commit490c70374d9e98d8f9b761afe1be1a36a8ed41d0 (patch)
tree3e6787974769cabc0e265b382d25af77f9764e6c
parent1f39e0f2cbe23d46b805f976db0807e5aa27d362 (diff)
downloadgcc-490c70374d9e98d8f9b761afe1be1a36a8ed41d0.zip
gcc-490c70374d9e98d8f9b761afe1be1a36a8ed41d0.tar.gz
gcc-490c70374d9e98d8f9b761afe1be1a36a8ed41d0.tar.bz2
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.
-rw-r--r--gcc/rust/expand/rust-derive-copy.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/rust/expand/rust-derive-copy.cc b/gcc/rust/expand/rust-derive-copy.cc
index 1f52a08e..d969943 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<T: Copy> { ... }
+ // struct Be<T> { ... }
//
// 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<std::unique_ptr<TypeParamBound>> extra_bounds;
+ extra_bounds.emplace_back (std::unique_ptr<TypeParamBound> (
+ 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;