aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/expand
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2025-01-20 11:36:53 +0000
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-24 13:06:52 +0100
commit2bee6000c3d18de68a8a2d233a2dd5f8cd177dc7 (patch)
treed0749d3324306109d9ae8b3cd32a27c9ad728489 /gcc/rust/expand
parentd7794f91e61365bd921faff18ccd07642236aee5 (diff)
downloadgcc-2bee6000c3d18de68a8a2d233a2dd5f8cd177dc7.zip
gcc-2bee6000c3d18de68a8a2d233a2dd5f8cd177dc7.tar.gz
gcc-2bee6000c3d18de68a8a2d233a2dd5f8cd177dc7.tar.bz2
gccrs: derive(Clone): Use lang item bounds on AssertParamIsCopy
gcc/rust/ChangeLog: * expand/rust-derive-clone.cc (DeriveClone::visit_union): Use lang items for Copy and Sized bounds. gcc/testsuite/ChangeLog: * rust/compile/derive_macro6.rs: Add lang item attribute to Copy trait.
Diffstat (limited to 'gcc/rust/expand')
-rw-r--r--gcc/rust/expand/rust-derive-clone.cc11
1 files changed, 5 insertions, 6 deletions
diff --git a/gcc/rust/expand/rust-derive-clone.cc b/gcc/rust/expand/rust-derive-clone.cc
index 0081eb4..18f7723 100644
--- a/gcc/rust/expand/rust-derive-clone.cc
+++ b/gcc/rust/expand/rust-derive-clone.cc
@@ -422,17 +422,16 @@ DeriveClone::visit_union (Union &item)
// FIXME: Should be $crate::core::clone::AssertParamIsCopy (or similar)
// (Rust-GCC#3329)
- auto copy_path = TypePath (vec (builder.type_path_segment ("Copy")), loc);
- auto sized_path = TypePath (vec (builder.type_path_segment ("Sized")), loc);
+ auto copy_path = builder.type_path (LangItem::Kind::COPY);
+ auto sized_path = builder.type_path (LangItem::Kind::SIZED);
auto copy_bound = std::unique_ptr<TypeParamBound> (
new TraitBound (copy_path, item.get_locus ()));
auto sized_bound = std::unique_ptr<TypeParamBound> (
- new TraitBound (sized_path, item.get_locus (), false, true));
+ new TraitBound (sized_path, item.get_locus (), false,
+ true /* opening_question_mark */));
- auto bounds = std::vector<std::unique_ptr<TypeParamBound>> ();
- bounds.emplace_back (std::move (copy_bound));
- bounds.emplace_back (std::move (sized_bound));
+ auto bounds = vec (std::move (copy_bound), std::move (sized_bound));
// struct AssertParamIsCopy<T: Copy + ?Sized> { _t: PhantomData<T> }
auto assert_param_is_copy = "AssertParamIsCopy";