about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2022-06-07 12:12:49 -0700
committerMichael Howell <michael@notriddle.com>2022-06-07 12:12:49 -0700
commit7a935670055d87e17c381542f4eaab481e8bf17b (patch)
tree179b9eb8918763f6c860e0b852f93e83be60a208
parent1e6a85789e866c725015e0e2a5defeccbcc2cc3b (diff)
downloadrust-7a935670055d87e17c381542f4eaab481e8bf17b.tar.gz
rust-7a935670055d87e17c381542f4eaab481e8bf17b.zip
docs: show Clone and Copy on () doc pages
-rw-r--r--library/core/src/clone.rs1
-rw-r--r--library/core/src/marker.rs1
-rw-r--r--library/core/src/primitive_docs.rs34
-rw-r--r--library/std/src/primitive_docs.rs34
4 files changed, 68 insertions, 2 deletions
diff --git a/library/core/src/clone.rs b/library/core/src/clone.rs
index 70f3fe853d9..fd5624812f5 100644
--- a/library/core/src/clone.rs
+++ b/library/core/src/clone.rs
@@ -95,7 +95,6 @@ use crate::marker::Destruct;
 ///
 /// * Function item types (i.e., the distinct types defined for each function)
 /// * Function pointer types (e.g., `fn() -> i32`)
-/// * Tuple types, if each component also implements `Clone` (e.g., `()`, `(i32, bool)`)
 /// * Closure types, if they capture no value from the environment
 ///   or if all such captured values implement `Clone` themselves.
 ///   Note that variables captured by shared reference always implement `Clone`
diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs
index 4a90ef9545d..2c57897956f 100644
--- a/library/core/src/marker.rs
+++ b/library/core/src/marker.rs
@@ -359,7 +359,6 @@ pub trait StructuralEq {
 ///
 /// * Function item types (i.e., the distinct types defined for each function)
 /// * Function pointer types (e.g., `fn() -> i32`)
-/// * Tuple types, if each component also implements `Copy` (e.g., `()`, `(i32, bool)`)
 /// * Closure types, if they capture no value from the environment
 ///   or if all such captured values implement `Copy` themselves.
 ///   Note that variables captured by shared reference always implement `Copy`
diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs
index 06e2a0eb2de..db2f7ec0e0e 100644
--- a/library/core/src/primitive_docs.rs
+++ b/library/core/src/primitive_docs.rs
@@ -444,6 +444,22 @@ mod prim_unit {}
 #[doc(hidden)]
 impl () {}
 
+// Fake impl that's only really used for docs.
+#[cfg(doc)]
+#[stable(feature = "rust1", since = "1.0.0")]
+impl Clone for () {
+    fn clone(&self) -> Self {
+        loop {}
+    }
+}
+
+// Fake impl that's only really used for docs.
+#[cfg(doc)]
+#[stable(feature = "rust1", since = "1.0.0")]
+impl Copy for () {
+    // empty
+}
+
 #[doc(primitive = "pointer")]
 #[doc(alias = "ptr")]
 #[doc(alias = "*")]
@@ -959,6 +975,24 @@ mod prim_tuple {}
 #[doc(hidden)]
 impl<T, U> (T, U) {}
 
+// Fake impl that's only really used for docs.
+#[cfg(doc)]
+#[stable(feature = "rust1", since = "1.0.0")]
+/// This trait is implemented on arbitrary-length tuples.
+impl<T: Clone> Clone for (T,) {
+    fn clone(&self) -> Self {
+        loop {}
+    }
+}
+
+// Fake impl that's only really used for docs.
+#[cfg(doc)]
+#[stable(feature = "rust1", since = "1.0.0")]
+/// This trait is implemented on arbitrary-length tuples.
+impl<T: Copy> Copy for (T,) {
+    // empty
+}
+
 #[doc(primitive = "f32")]
 /// A 32-bit floating point type (specifically, the "binary32" type defined in IEEE 754-2008).
 ///
diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs
index 06e2a0eb2de..db2f7ec0e0e 100644
--- a/library/std/src/primitive_docs.rs
+++ b/library/std/src/primitive_docs.rs
@@ -444,6 +444,22 @@ mod prim_unit {}
 #[doc(hidden)]
 impl () {}
 
+// Fake impl that's only really used for docs.
+#[cfg(doc)]
+#[stable(feature = "rust1", since = "1.0.0")]
+impl Clone for () {
+    fn clone(&self) -> Self {
+        loop {}
+    }
+}
+
+// Fake impl that's only really used for docs.
+#[cfg(doc)]
+#[stable(feature = "rust1", since = "1.0.0")]
+impl Copy for () {
+    // empty
+}
+
 #[doc(primitive = "pointer")]
 #[doc(alias = "ptr")]
 #[doc(alias = "*")]
@@ -959,6 +975,24 @@ mod prim_tuple {}
 #[doc(hidden)]
 impl<T, U> (T, U) {}
 
+// Fake impl that's only really used for docs.
+#[cfg(doc)]
+#[stable(feature = "rust1", since = "1.0.0")]
+/// This trait is implemented on arbitrary-length tuples.
+impl<T: Clone> Clone for (T,) {
+    fn clone(&self) -> Self {
+        loop {}
+    }
+}
+
+// Fake impl that's only really used for docs.
+#[cfg(doc)]
+#[stable(feature = "rust1", since = "1.0.0")]
+/// This trait is implemented on arbitrary-length tuples.
+impl<T: Copy> Copy for (T,) {
+    // empty
+}
+
 #[doc(primitive = "f32")]
 /// A 32-bit floating point type (specifically, the "binary32" type defined in IEEE 754-2008).
 ///