internal: add Copy to minicore

This commit is contained in:
Aleksey Kladov 2021-06-18 22:10:29 +03:00
parent a08339e421
commit 15c4b3fa7f
3 changed files with 464 additions and 306 deletions

View file

@ -3014,8 +3014,8 @@ fn foo() {
file_id: FileId( file_id: FileId(
1, 1,
), ),
full_range: 248..430, full_range: 250..432,
focus_range: 287..293, focus_range: 289..295,
name: "Future", name: "Future",
kind: Trait, kind: Trait,
description: "pub trait Future", description: "pub trait Future",

File diff suppressed because it is too large Load diff

View file

@ -23,6 +23,8 @@
//! iterator: option //! iterator: option
//! iterators: iterator //! iterators: iterator
//! default: sized //! default: sized
//! clone: sized
//! copy: clone
//! from: sized //! from: sized
//! eq: sized //! eq: sized
//! ord: eq, option //! ord: eq, option
@ -40,6 +42,38 @@ pub mod marker {
#[lang = "unsize"] #[lang = "unsize"]
pub trait Unsize<T: ?Sized> {} pub trait Unsize<T: ?Sized> {}
// endregion:unsize // endregion:unsize
// region:copy
#[lang = "copy"]
pub trait Copy: Clone {}
// region:derive
#[rustc_builtin_macro]
pub macro Copy($item:item) {}
// endregion:derive
mod copy_impls {
use super::Copy;
macro_rules! impl_copy {
($($t:ty)*) => {
$(
impl Copy for $t {}
)*
}
}
impl_copy! {
usize u8 u16 u32 u64 u128
isize i8 i16 i32 i64 i128
f32 f64
bool char
}
impl<T: ?Sized> Copy for *const T {}
impl<T: ?Sized> Copy for *mut T {}
impl<T: ?Sized> Copy for &T {}
}
// endregion:copy
} }
// region:default // region:default
@ -50,6 +84,19 @@ pub mod default {
} }
// endregion:default // endregion:default
// region:clone
pub mod clone {
#[lang = "clone"]
pub trait Clone: Sized {
fn clone(&self) -> Self;
}
// region:derive
#[rustc_builtin_macro]
pub macro Clone($item:item) {}
// endregion:derive
}
// endregion:clone
// region:from // region:from
pub mod convert { pub mod convert {
pub trait From<T>: Sized { pub trait From<T>: Sized {
@ -114,9 +161,11 @@ pub mod ops {
} }
// endregion:deref_mut // endregion:deref_mut
} }
pub use self::deref::Deref; pub use self::deref::{
pub use self::deref::DerefMut; //:deref_mut Deref,
// endregion:deref DerefMut, // :deref_mut
};
// endregion:deref
// region:range // region:range
mod range { mod range {
@ -402,12 +451,14 @@ mod macros {
pub mod prelude { pub mod prelude {
pub mod v1 { pub mod v1 {
pub use crate::{ pub use crate::{
clone::Clone, // :clone
cmp::{Eq, PartialEq}, // :eq cmp::{Eq, PartialEq}, // :eq
cmp::{Ord, PartialOrd}, // :ord cmp::{Ord, PartialOrd}, // :ord
convert::{From, Into}, // :from convert::{From, Into}, // :from
default::Default, // :default default::Default, // :default
iter::{IntoIterator, Iterator}, // :iterator iter::{IntoIterator, Iterator}, // :iterator
macros::builtin::derive, // :derive macros::builtin::derive, // :derive
marker::Copy, // :copy
marker::Sized, // :sized marker::Sized, // :sized
ops::{Fn, FnMut, FnOnce}, // :fn ops::{Fn, FnMut, FnOnce}, // :fn
option::Option::{self, None, Some}, // :option option::Option::{self, None, Some}, // :option