2021-06-15 13:02:40 -05:00
|
|
|
//! This is a fixture we use for tests that need lang items.
|
|
|
|
//!
|
|
|
|
//! We want to include the minimal subset of core for each test, so this file
|
|
|
|
//! supports "conditional compilation". Tests use the following syntax to include minicore:
|
|
|
|
//!
|
|
|
|
//! //- minicore: flag1, flag2
|
|
|
|
//!
|
|
|
|
//! We then strip all the code marked with other flags.
|
|
|
|
//!
|
|
|
|
//! Available flags:
|
|
|
|
//! sized:
|
2021-06-15 13:34:26 -05:00
|
|
|
//! slice:
|
2021-06-15 13:45:25 -05:00
|
|
|
//! range:
|
2021-06-15 13:11:53 -05:00
|
|
|
//! unsize: sized
|
2021-06-15 13:34:26 -05:00
|
|
|
//! deref: sized
|
2021-06-15 13:11:53 -05:00
|
|
|
//! coerce_unsized: unsize
|
2021-06-15 13:02:40 -05:00
|
|
|
|
|
|
|
pub mod marker {
|
|
|
|
// region:sized
|
|
|
|
#[lang = "sized"]
|
|
|
|
#[fundamental]
|
|
|
|
#[rustc_specialization_trait]
|
|
|
|
pub trait Sized {}
|
2021-06-15 13:11:53 -05:00
|
|
|
// endregion:sized
|
2021-06-15 13:02:40 -05:00
|
|
|
|
2021-06-15 13:11:53 -05:00
|
|
|
// region:unsize
|
2021-06-15 13:02:40 -05:00
|
|
|
#[lang = "unsize"]
|
|
|
|
pub trait Unsize<T: ?Sized> {}
|
2021-06-15 13:11:53 -05:00
|
|
|
// endregion:unsize
|
2021-06-15 13:02:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
pub mod ops {
|
2021-06-15 13:34:26 -05:00
|
|
|
// region:coerce_unsized
|
2021-06-15 13:02:40 -05:00
|
|
|
mod unsize {
|
|
|
|
use crate::marker::Unsize;
|
|
|
|
|
|
|
|
#[lang = "coerce_unsized"]
|
|
|
|
pub trait CoerceUnsized<T: ?Sized> {}
|
|
|
|
|
|
|
|
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a mut U> for &'a mut T {}
|
|
|
|
impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b mut T {}
|
|
|
|
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*mut U> for &'a mut T {}
|
|
|
|
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for &'a mut T {}
|
|
|
|
|
|
|
|
impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}
|
|
|
|
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for &'a T {}
|
|
|
|
|
|
|
|
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*mut U> for *mut T {}
|
|
|
|
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *mut T {}
|
|
|
|
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *const T {}
|
|
|
|
}
|
2021-06-15 13:34:26 -05:00
|
|
|
pub use self::unsize::CoerceUnsized;
|
|
|
|
// endregion:coerce_unsized
|
2021-06-15 13:11:53 -05:00
|
|
|
|
2021-06-15 13:34:26 -05:00
|
|
|
// region:deref
|
|
|
|
mod deref {
|
|
|
|
#[lang = "deref"]
|
|
|
|
pub trait Deref {
|
|
|
|
#[lang = "deref_target"]
|
|
|
|
type Target: ?Sized;
|
|
|
|
fn deref(&self) -> &Self::Target;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pub use self::deref::Deref;
|
|
|
|
// endregion:deref
|
2021-06-15 13:45:25 -05:00
|
|
|
|
|
|
|
//region:range
|
|
|
|
mod range {
|
|
|
|
#[lang = "RangeFull"]
|
|
|
|
pub struct RangeFull;
|
|
|
|
|
|
|
|
#[lang = "Range"]
|
|
|
|
pub struct Range<Idx> {
|
|
|
|
pub start: Idx,
|
|
|
|
pub end: Idx,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[lang = "RangeFrom"]
|
|
|
|
pub struct RangeFrom<Idx> {
|
|
|
|
pub start: Idx,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[lang = "RangeTo"]
|
|
|
|
pub struct RangeTo<Idx> {
|
|
|
|
pub end: Idx,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[lang = "RangeInclusive"]
|
|
|
|
pub struct RangeInclusive<Idx> {
|
|
|
|
pub(crate) start: Idx,
|
|
|
|
pub(crate) end: Idx,
|
|
|
|
pub(crate) exhausted: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[lang = "RangeToInclusive"]
|
|
|
|
pub struct RangeToInclusive<Idx> {
|
|
|
|
pub end: Idx,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pub use self::range::{Range, RangeFrom, RangeFull, RangeTo};
|
|
|
|
pub use self::range::{RangeInclusive, RangeToInclusive};
|
|
|
|
//endregion:range
|
2021-06-15 13:34:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// region:slice
|
|
|
|
pub mod slice {
|
|
|
|
#[lang = "slice"]
|
|
|
|
impl<T> [T] {
|
2021-06-15 13:45:25 -05:00
|
|
|
pub fn len(&self) -> usize {
|
|
|
|
loop {}
|
|
|
|
}
|
2021-06-15 13:34:26 -05:00
|
|
|
}
|
2021-06-15 13:02:40 -05:00
|
|
|
}
|
2021-06-15 13:34:26 -05:00
|
|
|
// endregion:slice
|
2021-06-15 13:02:40 -05:00
|
|
|
|
|
|
|
pub mod prelude {
|
|
|
|
pub mod v1 {
|
|
|
|
pub use crate::marker::Sized; // :sized
|
|
|
|
}
|
|
|
|
|
|
|
|
pub mod rust_2015 {
|
|
|
|
pub use super::v1::*;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub mod rust_2018 {
|
|
|
|
pub use super::v1::*;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub mod rust_2021 {
|
|
|
|
pub use super::v1::*;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[prelude_import]
|
|
|
|
#[allow(unused)]
|
|
|
|
use prelude::v1::*;
|