@@ -84,7 +84,7 @@ impl ::core::cmp::Ord for Empty {
8484 }
8585}
8686
87- // A basic struct. Note: because this derives `Copy`, it gets the simple
87+ // A basic struct. Note: because this derives `Copy`, it gets the trivial
8888// `clone` implemention that just does `*self`.
8989struct Point {
9090 x: u32,
@@ -171,7 +171,7 @@ impl ::core::cmp::Ord for Point {
171171 }
172172}
173173
174- // A basic packed struct. Note: because this derives `Copy`, it gets the simple
174+ // A basic packed struct. Note: because this derives `Copy`, it gets the trivial
175175// `clone` implemention that just does `*self`.
176176#[repr(packed)]
177177struct PackedPoint {
@@ -409,7 +409,7 @@ impl ::core::cmp::Ord for SingleField {
409409 }
410410}
411411
412- // A large struct. Note: because this derives `Copy`, it gets the simple
412+ // A large struct. Note: because this derives `Copy`, it gets the trivial
413413// `clone` implemention that just does `*self`.
414414struct Big {
415415 b1: u32,
@@ -676,7 +676,7 @@ impl ::core::cmp::PartialOrd for Reorder {
676676 }
677677}
678678
679- // A struct that doesn't impl `Copy`, which means it gets the non-simple
679+ // A struct that doesn't impl `Copy`, which means it gets the non-trivial
680680// `clone` implemention that clones the fields individually.
681681struct NonCopy(u32);
682682#[automatically_derived]
@@ -687,7 +687,7 @@ impl ::core::clone::Clone for NonCopy {
687687 }
688688}
689689
690- // A packed struct that doesn't impl `Copy`, which means it gets the non-simple
690+ // A packed struct that doesn't impl `Copy`, which means it gets the non-trivial
691691// `clone` implemention that clones the fields individually.
692692#[repr(packed)]
693693struct PackedNonCopy(u32);
@@ -699,7 +699,7 @@ impl ::core::clone::Clone for PackedNonCopy {
699699 }
700700}
701701
702- // A struct that impls `Copy` manually, which means it gets the non-simple
702+ // A struct that impls `Copy` manually, which means it gets the non-trivial
703703// `clone` implemention that clones the fields individually.
704704struct ManualCopy(u32);
705705#[automatically_derived]
@@ -712,7 +712,7 @@ impl ::core::clone::Clone for ManualCopy {
712712impl Copy for ManualCopy {}
713713
714714// A packed struct that impls `Copy` manually, which means it gets the
715- // non-simple `clone` implemention that clones the fields individually.
715+ // non-trivial `clone` implemention that clones the fields individually.
716716#[repr(packed)]
717717struct PackedManualCopy(u32);
718718#[automatically_derived]
@@ -1791,3 +1791,62 @@ impl ::core::clone::Clone for Union {
17911791}
17921792#[automatically_derived]
17931793impl ::core::marker::Copy for Union { }
1794+
1795+ struct FooCopyClone(i32);
1796+ #[automatically_derived]
1797+ impl ::core::marker::Copy for FooCopyClone { }
1798+ #[automatically_derived]
1799+ #[doc(hidden)]
1800+ unsafe impl ::core::clone::TrivialClone for FooCopyClone { }
1801+ #[automatically_derived]
1802+ impl ::core::clone::Clone for FooCopyClone {
1803+ #[inline]
1804+ fn clone(&self) -> FooCopyClone {
1805+ let _: ::core::clone::AssertParamIsClone<i32>;
1806+ *self
1807+ }
1808+ }
1809+
1810+ struct FooCloneCopy(i32);
1811+ #[automatically_derived]
1812+ #[doc(hidden)]
1813+ unsafe impl ::core::clone::TrivialClone for FooCloneCopy { }
1814+ #[automatically_derived]
1815+ impl ::core::clone::Clone for FooCloneCopy {
1816+ #[inline]
1817+ fn clone(&self) -> FooCloneCopy {
1818+ let _: ::core::clone::AssertParamIsClone<i32>;
1819+ *self
1820+ }
1821+ }
1822+ #[automatically_derived]
1823+ impl ::core::marker::Copy for FooCloneCopy { }
1824+
1825+ struct FooCopyAndClone(i32);
1826+ #[automatically_derived]
1827+ #[doc(hidden)]
1828+ unsafe impl ::core::clone::TrivialClone for FooCopyAndClone { }
1829+ #[automatically_derived]
1830+ impl ::core::clone::Clone for FooCopyAndClone {
1831+ #[inline]
1832+ fn clone(&self) -> FooCopyAndClone {
1833+ let _: ::core::clone::AssertParamIsClone<i32>;
1834+ *self
1835+ }
1836+ }
1837+ #[automatically_derived]
1838+ impl ::core::marker::Copy for FooCopyAndClone { }
1839+
1840+ // FIXME(#124794): the previous three structs all have a trivial `Copy`-aware
1841+ // `clone`. But this one doesn't because when the `clone` is generated the
1842+ // `derive(Copy)` hasn't yet been seen.
1843+ struct FooCloneAndCopy(i32);
1844+ #[automatically_derived]
1845+ impl ::core::marker::Copy for FooCloneAndCopy { }
1846+ #[automatically_derived]
1847+ impl ::core::clone::Clone for FooCloneAndCopy {
1848+ #[inline]
1849+ fn clone(&self) -> FooCloneAndCopy {
1850+ FooCloneAndCopy(::core::clone::Clone::clone(&self.0))
1851+ }
1852+ }
0 commit comments