diff options
author | Aleksey Kladov <[email protected]> | 2021-06-18 20:10:29 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-06-18 20:10:52 +0100 |
commit | 15c4b3fa7f9d97029d64a7e13a12aa1ee42316d7 (patch) | |
tree | 5f4156b8691e5ea0c7b46b66e5075da3473e178c /crates/test_utils | |
parent | a08339e4211cfd0dc448a8f39d83561ad8754f7a (diff) |
internal: add Copy to minicore
Diffstat (limited to 'crates/test_utils')
-rw-r--r-- | crates/test_utils/src/minicore.rs | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/crates/test_utils/src/minicore.rs b/crates/test_utils/src/minicore.rs index 9ec541c57..769028580 100644 --- a/crates/test_utils/src/minicore.rs +++ b/crates/test_utils/src/minicore.rs | |||
@@ -23,6 +23,8 @@ | |||
23 | //! iterator: option | 23 | //! iterator: option |
24 | //! iterators: iterator | 24 | //! iterators: iterator |
25 | //! default: sized | 25 | //! default: sized |
26 | //! clone: sized | ||
27 | //! copy: clone | ||
26 | //! from: sized | 28 | //! from: sized |
27 | //! eq: sized | 29 | //! eq: sized |
28 | //! ord: eq, option | 30 | //! ord: eq, option |
@@ -40,6 +42,38 @@ pub mod marker { | |||
40 | #[lang = "unsize"] | 42 | #[lang = "unsize"] |
41 | pub trait Unsize<T: ?Sized> {} | 43 | pub trait Unsize<T: ?Sized> {} |
42 | // endregion:unsize | 44 | // endregion:unsize |
45 | |||
46 | // region:copy | ||
47 | #[lang = "copy"] | ||
48 | pub trait Copy: Clone {} | ||
49 | // region:derive | ||
50 | #[rustc_builtin_macro] | ||
51 | pub macro Copy($item:item) {} | ||
52 | // endregion:derive | ||
53 | |||
54 | mod copy_impls { | ||
55 | use super::Copy; | ||
56 | |||
57 | macro_rules! impl_copy { | ||
58 | ($($t:ty)*) => { | ||
59 | $( | ||
60 | impl Copy for $t {} | ||
61 | )* | ||
62 | } | ||
63 | } | ||
64 | |||
65 | impl_copy! { | ||
66 | usize u8 u16 u32 u64 u128 | ||
67 | isize i8 i16 i32 i64 i128 | ||
68 | f32 f64 | ||
69 | bool char | ||
70 | } | ||
71 | |||
72 | impl<T: ?Sized> Copy for *const T {} | ||
73 | impl<T: ?Sized> Copy for *mut T {} | ||
74 | impl<T: ?Sized> Copy for &T {} | ||
75 | } | ||
76 | // endregion:copy | ||
43 | } | 77 | } |
44 | 78 | ||
45 | // region:default | 79 | // region:default |
@@ -50,6 +84,19 @@ pub mod default { | |||
50 | } | 84 | } |
51 | // endregion:default | 85 | // endregion:default |
52 | 86 | ||
87 | // region:clone | ||
88 | pub mod clone { | ||
89 | #[lang = "clone"] | ||
90 | pub trait Clone: Sized { | ||
91 | fn clone(&self) -> Self; | ||
92 | } | ||
93 | // region:derive | ||
94 | #[rustc_builtin_macro] | ||
95 | pub macro Clone($item:item) {} | ||
96 | // endregion:derive | ||
97 | } | ||
98 | // endregion:clone | ||
99 | |||
53 | // region:from | 100 | // region:from |
54 | pub mod convert { | 101 | pub mod convert { |
55 | pub trait From<T>: Sized { | 102 | pub trait From<T>: Sized { |
@@ -114,9 +161,11 @@ pub mod ops { | |||
114 | } | 161 | } |
115 | // endregion:deref_mut | 162 | // endregion:deref_mut |
116 | } | 163 | } |
117 | pub use self::deref::Deref; | 164 | pub use self::deref::{ |
118 | pub use self::deref::DerefMut; //:deref_mut | 165 | Deref, |
119 | // endregion:deref | 166 | DerefMut, // :deref_mut |
167 | }; | ||
168 | // endregion:deref | ||
120 | 169 | ||
121 | // region:range | 170 | // region:range |
122 | mod range { | 171 | mod range { |
@@ -402,12 +451,14 @@ mod macros { | |||
402 | pub mod prelude { | 451 | pub mod prelude { |
403 | pub mod v1 { | 452 | pub mod v1 { |
404 | pub use crate::{ | 453 | pub use crate::{ |
454 | clone::Clone, // :clone | ||
405 | cmp::{Eq, PartialEq}, // :eq | 455 | cmp::{Eq, PartialEq}, // :eq |
406 | cmp::{Ord, PartialOrd}, // :ord | 456 | cmp::{Ord, PartialOrd}, // :ord |
407 | convert::{From, Into}, // :from | 457 | convert::{From, Into}, // :from |
408 | default::Default, // :default | 458 | default::Default, // :default |
409 | iter::{IntoIterator, Iterator}, // :iterator | 459 | iter::{IntoIterator, Iterator}, // :iterator |
410 | macros::builtin::derive, // :derive | 460 | macros::builtin::derive, // :derive |
461 | marker::Copy, // :copy | ||
411 | marker::Sized, // :sized | 462 | marker::Sized, // :sized |
412 | ops::{Fn, FnMut, FnOnce}, // :fn | 463 | ops::{Fn, FnMut, FnOnce}, // :fn |
413 | option::Option::{self, None, Some}, // :option | 464 | option::Option::{self, None, Some}, // :option |