Skip to content

Commit 7a93567

Browse files
committed
docs: show Clone and Copy on () doc pages
1 parent 1e6a857 commit 7a93567

File tree

4 files changed

+68
-2
lines changed

4 files changed

+68
-2
lines changed

library/core/src/clone.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ use crate::marker::Destruct;
9595
///
9696
/// * Function item types (i.e., the distinct types defined for each function)
9797
/// * Function pointer types (e.g., `fn() -> i32`)
98-
/// * Tuple types, if each component also implements `Clone` (e.g., `()`, `(i32, bool)`)
9998
/// * Closure types, if they capture no value from the environment
10099
/// or if all such captured values implement `Clone` themselves.
101100
/// Note that variables captured by shared reference always implement `Clone`

library/core/src/marker.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ pub trait StructuralEq {
359359
///
360360
/// * Function item types (i.e., the distinct types defined for each function)
361361
/// * Function pointer types (e.g., `fn() -> i32`)
362-
/// * Tuple types, if each component also implements `Copy` (e.g., `()`, `(i32, bool)`)
363362
/// * Closure types, if they capture no value from the environment
364363
/// or if all such captured values implement `Copy` themselves.
365364
/// Note that variables captured by shared reference always implement `Copy`

library/core/src/primitive_docs.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,22 @@ mod prim_unit {}
444444
#[doc(hidden)]
445445
impl () {}
446446

447+
// Fake impl that's only really used for docs.
448+
#[cfg(doc)]
449+
#[stable(feature = "rust1", since = "1.0.0")]
450+
impl Clone for () {
451+
fn clone(&self) -> Self {
452+
loop {}
453+
}
454+
}
455+
456+
// Fake impl that's only really used for docs.
457+
#[cfg(doc)]
458+
#[stable(feature = "rust1", since = "1.0.0")]
459+
impl Copy for () {
460+
// empty
461+
}
462+
447463
#[doc(primitive = "pointer")]
448464
#[doc(alias = "ptr")]
449465
#[doc(alias = "*")]
@@ -959,6 +975,24 @@ mod prim_tuple {}
959975
#[doc(hidden)]
960976
impl<T, U> (T, U) {}
961977

978+
// Fake impl that's only really used for docs.
979+
#[cfg(doc)]
980+
#[stable(feature = "rust1", since = "1.0.0")]
981+
/// This trait is implemented on arbitrary-length tuples.
982+
impl<T: Clone> Clone for (T,) {
983+
fn clone(&self) -> Self {
984+
loop {}
985+
}
986+
}
987+
988+
// Fake impl that's only really used for docs.
989+
#[cfg(doc)]
990+
#[stable(feature = "rust1", since = "1.0.0")]
991+
/// This trait is implemented on arbitrary-length tuples.
992+
impl<T: Copy> Copy for (T,) {
993+
// empty
994+
}
995+
962996
#[doc(primitive = "f32")]
963997
/// A 32-bit floating point type (specifically, the "binary32" type defined in IEEE 754-2008).
964998
///

library/std/src/primitive_docs.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,22 @@ mod prim_unit {}
444444
#[doc(hidden)]
445445
impl () {}
446446

447+
// Fake impl that's only really used for docs.
448+
#[cfg(doc)]
449+
#[stable(feature = "rust1", since = "1.0.0")]
450+
impl Clone for () {
451+
fn clone(&self) -> Self {
452+
loop {}
453+
}
454+
}
455+
456+
// Fake impl that's only really used for docs.
457+
#[cfg(doc)]
458+
#[stable(feature = "rust1", since = "1.0.0")]
459+
impl Copy for () {
460+
// empty
461+
}
462+
447463
#[doc(primitive = "pointer")]
448464
#[doc(alias = "ptr")]
449465
#[doc(alias = "*")]
@@ -959,6 +975,24 @@ mod prim_tuple {}
959975
#[doc(hidden)]
960976
impl<T, U> (T, U) {}
961977

978+
// Fake impl that's only really used for docs.
979+
#[cfg(doc)]
980+
#[stable(feature = "rust1", since = "1.0.0")]
981+
/// This trait is implemented on arbitrary-length tuples.
982+
impl<T: Clone> Clone for (T,) {
983+
fn clone(&self) -> Self {
984+
loop {}
985+
}
986+
}
987+
988+
// Fake impl that's only really used for docs.
989+
#[cfg(doc)]
990+
#[stable(feature = "rust1", since = "1.0.0")]
991+
/// This trait is implemented on arbitrary-length tuples.
992+
impl<T: Copy> Copy for (T,) {
993+
// empty
994+
}
995+
962996
#[doc(primitive = "f32")]
963997
/// A 32-bit floating point type (specifically, the "binary32" type defined in IEEE 754-2008).
964998
///

0 commit comments

Comments
 (0)