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-16 02:48:07 -05:00
|
|
|
//! unsize: sized
|
|
|
|
//! coerce_unsized: unsize
|
2021-06-15 13:34:26 -05:00
|
|
|
//! slice:
|
2021-06-15 13:45:25 -05:00
|
|
|
//! range:
|
2021-06-15 13:34:26 -05:00
|
|
|
//! deref: sized
|
2021-06-16 02:30:29 -05:00
|
|
|
//! deref_mut: deref
|
2021-06-16 02:48:07 -05:00
|
|
|
//! fn:
|
2021-06-15 14:49:00 -05:00
|
|
|
//! pin:
|
|
|
|
//! future: pin
|
2021-06-15 14:59:51 -05:00
|
|
|
//! option:
|
2021-06-15 15:07:25 -05:00
|
|
|
//! result:
|
2021-06-16 14:48:48 -05:00
|
|
|
//! iterator: option
|
2021-06-17 03:28:44 -05:00
|
|
|
//! iterators: iterator
|
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;
|
|
|
|
}
|
2021-06-16 02:30:29 -05:00
|
|
|
// region:deref_mut
|
|
|
|
#[lang = "deref_mut"]
|
|
|
|
pub trait DerefMut: Deref {
|
|
|
|
fn deref_mut(&mut self) -> &mut Self::Target;
|
|
|
|
}
|
|
|
|
// endregion:deref_mut
|
2021-06-15 13:34:26 -05:00
|
|
|
}
|
|
|
|
pub use self::deref::Deref;
|
2021-06-16 02:30:29 -05:00
|
|
|
pub use self::deref::DerefMut; //:deref_mut
|
2021-06-16 02:48:07 -05:00
|
|
|
// endregion:deref
|
2021-06-15 13:45:25 -05:00
|
|
|
|
2021-06-15 14:38:21 -05:00
|
|
|
// region:range
|
2021-06-15 13:45:25 -05:00
|
|
|
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};
|
2021-06-15 14:38:21 -05:00
|
|
|
// endregion:range
|
2021-06-16 02:48:07 -05:00
|
|
|
|
|
|
|
// region:fn
|
|
|
|
mod function {
|
|
|
|
#[lang = "fn"]
|
|
|
|
#[fundamental]
|
|
|
|
pub trait Fn<Args>: FnMut<Args> {}
|
|
|
|
|
|
|
|
#[lang = "fn_mut"]
|
|
|
|
#[fundamental]
|
|
|
|
pub trait FnMut<Args>: FnOnce<Args> {}
|
|
|
|
|
|
|
|
#[lang = "fn_once"]
|
|
|
|
#[fundamental]
|
|
|
|
pub trait FnOnce<Args> {
|
|
|
|
#[lang = "fn_once_output"]
|
|
|
|
type Output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pub use self::function::{Fn, FnMut, FnOnce};
|
|
|
|
// endregion:fn
|
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
|
|
|
|
2021-06-15 14:59:51 -05:00
|
|
|
// region:option
|
|
|
|
pub mod option {
|
|
|
|
pub enum Option<T> {
|
|
|
|
#[lang = "None"]
|
|
|
|
None,
|
|
|
|
#[lang = "Some"]
|
|
|
|
Some(T),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// endregion:option
|
|
|
|
|
2021-06-15 15:07:25 -05:00
|
|
|
// region:result
|
|
|
|
pub mod result {
|
|
|
|
pub enum Result<T, E> {
|
|
|
|
#[lang = "Ok"]
|
|
|
|
Ok(T),
|
|
|
|
#[lang = "Err"]
|
|
|
|
Err(E),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// endregion:result
|
|
|
|
|
2021-06-15 14:49:00 -05:00
|
|
|
// region:pin
|
|
|
|
pub mod pin {
|
|
|
|
#[lang = "pin"]
|
|
|
|
#[fundamental]
|
|
|
|
pub struct Pin<P> {
|
|
|
|
pointer: P,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// endregion:pin
|
|
|
|
|
|
|
|
// region:future
|
|
|
|
pub mod future {
|
2021-06-15 14:59:51 -05:00
|
|
|
use crate::{
|
|
|
|
pin::Pin,
|
|
|
|
task::{Context, Poll},
|
|
|
|
};
|
2021-06-15 14:49:00 -05:00
|
|
|
|
|
|
|
#[lang = "future_trait"]
|
|
|
|
pub trait Future {
|
|
|
|
type Output;
|
|
|
|
#[lang = "poll"]
|
|
|
|
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pub mod task {
|
|
|
|
pub enum Poll<T> {
|
|
|
|
#[lang = "Ready"]
|
|
|
|
Ready(T),
|
|
|
|
#[lang = "Pending"]
|
|
|
|
Pending,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct Context<'a> {
|
|
|
|
waker: &'a (),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// endregion:future
|
|
|
|
|
2021-06-16 14:48:48 -05:00
|
|
|
// region:iterator
|
|
|
|
pub mod iter {
|
2021-06-17 03:28:44 -05:00
|
|
|
// region:iterators
|
2021-06-16 15:27:04 -05:00
|
|
|
mod adapters {
|
|
|
|
pub struct Take<I> {
|
|
|
|
iter: I,
|
|
|
|
n: usize,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<I> Iterator for Take<I>
|
|
|
|
where
|
|
|
|
I: Iterator,
|
|
|
|
{
|
|
|
|
type Item = <I as Iterator>::Item;
|
|
|
|
|
|
|
|
fn next(&mut self) -> Option<<I as Iterator>::Item> {
|
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pub use self::adapters::Take;
|
|
|
|
|
2021-06-17 03:18:37 -05:00
|
|
|
mod sources {
|
|
|
|
mod repeat {
|
|
|
|
pub fn repeat<T>(elt: T) -> Repeat<T> {
|
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct Repeat<A> {
|
|
|
|
element: A,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<A> Iterator for Repeat<A> {
|
|
|
|
type Item = A;
|
|
|
|
|
|
|
|
fn next(&mut self) -> Option<A> {
|
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pub use self::repeat::{repeat, Repeat};
|
|
|
|
}
|
|
|
|
pub use self::sources::{repeat, Repeat};
|
2021-06-17 03:28:44 -05:00
|
|
|
// endregion:iterators
|
2021-06-17 03:18:37 -05:00
|
|
|
|
2021-06-16 14:48:48 -05:00
|
|
|
mod traits {
|
|
|
|
mod iterator {
|
2021-06-16 15:27:04 -05:00
|
|
|
use super::super::Take;
|
|
|
|
|
2021-06-16 14:48:48 -05:00
|
|
|
pub trait Iterator {
|
|
|
|
type Item;
|
|
|
|
#[lang = "next"]
|
|
|
|
fn next(&mut self) -> Option<Self::Item>;
|
|
|
|
fn nth(&mut self, n: usize) -> Option<Self::Item> {
|
|
|
|
loop {}
|
|
|
|
}
|
2021-06-17 03:18:37 -05:00
|
|
|
fn by_ref(&mut self) -> &mut Self
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
{
|
|
|
|
self
|
|
|
|
}
|
2021-06-17 03:28:44 -05:00
|
|
|
// region:iterators
|
|
|
|
fn take(self, n: usize) -> crate::iter::Take<Self> {
|
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
// endregion:iterators
|
2021-06-17 03:18:37 -05:00
|
|
|
}
|
|
|
|
impl<I: Iterator + ?Sized> Iterator for &mut I {
|
|
|
|
type Item = I::Item;
|
|
|
|
fn next(&mut self) -> Option<I::Item> {
|
|
|
|
(**self).next()
|
|
|
|
}
|
2021-06-16 14:48:48 -05:00
|
|
|
}
|
|
|
|
}
|
2021-06-16 15:27:04 -05:00
|
|
|
pub use self::iterator::Iterator;
|
|
|
|
|
2021-06-16 14:48:48 -05:00
|
|
|
mod collect {
|
|
|
|
pub trait IntoIterator {
|
|
|
|
type Item;
|
|
|
|
type IntoIter: Iterator<Item = Self::Item>;
|
|
|
|
#[lang = "into_iter"]
|
|
|
|
fn into_iter(self) -> Self::IntoIter;
|
|
|
|
}
|
2021-06-16 14:54:57 -05:00
|
|
|
impl<I: Iterator> IntoIterator for I {
|
|
|
|
type Item = I::Item;
|
|
|
|
type IntoIter = I;
|
|
|
|
fn into_iter(self) -> I {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
2021-06-16 14:48:48 -05:00
|
|
|
}
|
|
|
|
pub use self::collect::IntoIterator;
|
|
|
|
}
|
|
|
|
pub use self::traits::{IntoIterator, Iterator};
|
|
|
|
}
|
|
|
|
// endregion:iterator
|
|
|
|
|
2021-06-15 13:02:40 -05:00
|
|
|
pub mod prelude {
|
|
|
|
pub mod v1 {
|
2021-06-15 15:07:25 -05:00
|
|
|
pub use crate::{
|
2021-06-16 14:48:48 -05:00
|
|
|
iter::{IntoIterator, Iterator}, // :iterator
|
2021-06-15 15:07:25 -05:00
|
|
|
marker::Sized, // :sized
|
2021-06-16 02:48:07 -05:00
|
|
|
ops::{Fn, FnMut, FnOnce}, // :fn
|
2021-06-15 15:07:25 -05:00
|
|
|
option::Option::{self, None, Some}, // :option
|
|
|
|
result::Result::{self, Err, Ok}, // :result
|
|
|
|
};
|
2021-06-15 13:02:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
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::*;
|