1 //! This is a fixture we use for tests that need lang items.
3 //! We want to include the minimal subset of core for each test, so this file
4 //! supports "conditional compilation". Tests use the following syntax to include minicore:
6 //! //- minicore: flag1, flag2
8 //! We then strip all the code marked with other flags.
13 //! coerce_unsized: unsize
26 //! iterators: iterator, fn
36 //! bool_impl: option, fn
46 #[rustc_specialization_trait]
52 pub trait Unsize<T: ?Sized> {}
57 pub trait Copy: Clone {}
59 #[rustc_builtin_macro]
60 pub macro Copy($item:item) {}
66 macro_rules! impl_copy {
75 usize u8 u16 u32 u64 u128
76 isize i8 i16 i32 i64 i128
81 impl<T: ?Sized> Copy for *const T {}
82 impl<T: ?Sized> Copy for *mut T {}
83 impl<T: ?Sized> Copy for &T {}
90 pub trait Default: Sized {
94 #[rustc_builtin_macro]
95 pub macro Default($item:item) {}
105 fn hash<H: Hasher>(&self, state: &mut H);
113 pub trait Clone: Sized {
114 fn clone(&self) -> Self;
117 #[rustc_builtin_macro]
118 pub macro Clone($item:item) {}
125 pub trait From<T>: Sized {
126 fn from(_: T) -> Self;
128 pub trait Into<T>: Sized {
132 impl<T, U> Into<U> for T
141 impl<T> From<T> for T {
149 pub trait AsRef<T: ?Sized> {
150 fn as_ref(&self) -> &T;
156 // region:coerce_unsized
158 use crate::marker::Unsize;
160 #[lang = "coerce_unsized"]
161 pub trait CoerceUnsized<T: ?Sized> {}
163 impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a mut U> for &'a mut T {}
164 impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b mut T {}
165 impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*mut U> for &'a mut T {}
166 impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for &'a mut T {}
168 impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}
169 impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for &'a T {}
171 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*mut U> for *mut T {}
172 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *mut T {}
173 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *const T {}
175 pub use self::unsize::CoerceUnsized;
176 // endregion:coerce_unsized
182 #[lang = "deref_target"]
184 fn deref(&self) -> &Self::Target;
187 impl<T: ?Sized> Deref for &T {
189 fn deref(&self) -> &T {
193 impl<T: ?Sized> Deref for &mut T {
195 fn deref(&self) -> &T {
200 #[lang = "deref_mut"]
201 pub trait DerefMut: Deref {
202 fn deref_mut(&mut self) -> &mut Self::Target;
204 // endregion:deref_mut
206 pub use self::deref::{
208 DerefMut, // :deref_mut
222 pub trait Index<Idx: ?Sized> {
224 fn index(&self, index: Idx) -> &Self::Output;
226 #[lang = "index_mut"]
227 pub trait IndexMut<Idx: ?Sized>: Index<Idx> {
228 fn index_mut(&mut self, index: Idx) -> &mut Self::Output;
232 impl<T, I> Index<I> for [T]
236 type Output = I::Output;
237 fn index(&self, index: I) -> &I::Output {
241 impl<T, I> IndexMut<I> for [T]
245 fn index_mut(&mut self, index: I) -> &mut I::Output {
250 pub unsafe trait SliceIndex<T: ?Sized> {
253 unsafe impl<T> SliceIndex<[T]> for usize {
258 pub use self::index::{Index, IndexMut};
263 pub fn drop<T>(_x: T) {}
269 #[lang = "RangeFull"]
270 pub struct RangeFull;
273 pub struct Range<Idx> {
278 #[lang = "RangeFrom"]
279 pub struct RangeFrom<Idx> {
284 pub struct RangeTo<Idx> {
288 #[lang = "RangeInclusive"]
289 pub struct RangeInclusive<Idx> {
290 pub(crate) start: Idx,
292 pub(crate) exhausted: bool,
295 #[lang = "RangeToInclusive"]
296 pub struct RangeToInclusive<Idx> {
300 pub use self::range::{Range, RangeFrom, RangeFull, RangeTo};
301 pub use self::range::{RangeInclusive, RangeToInclusive};
308 pub trait Fn<Args>: FnMut<Args> {}
312 pub trait FnMut<Args>: FnOnce<Args> {}
316 pub trait FnOnce<Args> {
317 #[lang = "fn_once_output"]
321 pub use self::function::{Fn, FnMut, FnOnce};
325 pub enum ControlFlow<B, C = ()> {
329 pub trait FromResidual<R = Self::Residual> {
330 #[lang = "from_residual"]
331 fn from_residual(residual: R) -> Self;
334 pub trait Try: FromResidual<Self::Residual> {
337 #[lang = "from_output"]
338 fn from_output(output: Self::Output) -> Self;
340 fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
343 impl<B, C> Try for ControlFlow<B, C> {
345 type Residual = ControlFlow<B, convert::Infallible>;
346 fn from_output(output: Self::Output) -> Self {}
347 fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {}
350 impl<B, C> FromResidual for ControlFlow<B, C> {
351 fn from_residual(residual: ControlFlow<B, convert::Infallible>) -> Self {}
354 pub use self::try_::{ControlFlow, FromResidual, Try};
359 pub trait Add<Rhs = Self> {
361 fn add(self, rhs: Rhs) -> Self::Output;
369 #[lang = "generator"]
370 pub trait Generator<R = ()> {
372 #[lang = "generator_return"]
374 fn resume(self: Pin<&mut Self>, arg: R) -> GeneratorState<Self::Yield, Self::Return>;
377 #[lang = "generator_state"]
378 pub enum GeneratorState<Y, R> {
383 pub use self::generator::{Generator, GeneratorState};
384 // endregion:generator
390 pub trait PartialEq<Rhs: ?Sized = Self> {
391 fn eq(&self, other: &Rhs) -> bool;
392 fn ne(&self, other: &Rhs) -> bool {
397 pub trait Eq: PartialEq<Self> {}
400 #[rustc_builtin_macro]
401 pub macro PartialEq($item:item) {}
402 #[rustc_builtin_macro]
403 pub macro Eq($item:item) {}
407 #[lang = "partial_ord"]
408 pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
409 fn partial_cmp(&self, other: &Rhs) -> Option<Ordering>;
412 pub trait Ord: Eq + PartialOrd<Self> {
413 fn cmp(&self, other: &Self) -> Ordering;
423 #[rustc_builtin_macro]
424 pub macro PartialOrd($item:item) {}
425 #[rustc_builtin_macro]
426 pub macro Ord($item:item) {}
436 pub type Result = Result<(), Error>;
437 pub struct Formatter<'a>;
439 fn fmt(&self, f: &mut Formatter<'_>) -> Result;
448 pub fn len(&self) -> usize {
465 pub const fn unwrap(self) -> T {
468 None => panic!("called `Option::unwrap()` on a `None` value"),
477 pub enum Result<T, E> {
494 pub fn new(pointer: P) -> Pin<P> {
499 impl<P: crate::ops::Deref> crate::ops::Deref for Pin<P> {
500 type Target = P::Target;
501 fn deref(&self) -> &P::Target {
513 task::{Context, Poll},
516 #[lang = "future_trait"]
520 fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>;
523 pub trait IntoFuture {
525 type IntoFuture: Future<Output = Self::Output>;
526 #[lang = "into_future"]
527 fn into_future(self) -> Self::IntoFuture;
530 impl<F: Future> IntoFuture for F {
531 type Output = F::Output;
533 fn into_future(self) -> F {
546 pub struct Context<'a> {
560 impl<I> Iterator for Take<I>
564 type Item = <I as Iterator>::Item;
566 fn next(&mut self) -> Option<<I as Iterator>::Item> {
571 pub struct FilterMap<I, F> {
575 impl<B, I: Iterator, F> Iterator for FilterMap<I, F>
577 F: FnMut(I::Item) -> Option<B>,
582 fn next(&mut self) -> Option<B> {
587 pub use self::adapters::{Take, FilterMap};
591 pub fn repeat<T>(elt: T) -> Repeat<T> {
595 pub struct Repeat<A> {
599 impl<A> Iterator for Repeat<A> {
602 fn next(&mut self) -> Option<A> {
607 pub use self::repeat::{repeat, Repeat};
609 pub use self::sources::{repeat, Repeat};
610 // endregion:iterators
614 use super::super::Take;
619 fn next(&mut self) -> Option<Self::Item>;
620 fn nth(&mut self, n: usize) -> Option<Self::Item> {
623 fn by_ref(&mut self) -> &mut Self
630 fn take(self, n: usize) -> crate::iter::Take<Self> {
633 fn filter_map<B, F>(self, f: F) -> crate::iter::FilterMap<Self, F>
636 F: FnMut(Self::Item) -> Option<B>,
640 // endregion:iterators
642 impl<I: Iterator + ?Sized> Iterator for &mut I {
644 fn next(&mut self) -> Option<I::Item> {
649 pub use self::iterator::Iterator;
652 pub trait IntoIterator {
654 type IntoIter: Iterator<Item = Self::Item>;
655 #[lang = "into_iter"]
656 fn into_iter(self) -> Self::IntoIter;
658 impl<I: Iterator> IntoIterator for I {
661 fn into_iter(self) -> I {
666 pub use self::collect::IntoIterator;
668 pub use self::traits::{IntoIterator, Iterator};
670 // endregion:iterator
674 pub(crate) mod builtin {
675 #[rustc_builtin_macro]
676 pub macro derive($item:item) {
677 /* compiler built-in */
686 pub fn then<T, F: FnOnce() -> T>(self, f: F) -> Option<T> {
694 // endregion:bool_impl
699 clone::Clone, // :clone
700 cmp::{Eq, PartialEq}, // :eq
701 cmp::{Ord, PartialOrd}, // :ord
702 convert::AsRef, // :as_ref
703 convert::{From, Into}, // :from
704 default::Default, // :default
705 iter::{IntoIterator, Iterator}, // :iterator
706 macros::builtin::derive, // :derive
707 marker::Copy, // :copy
708 marker::Sized, // :sized
711 ops::{Fn, FnMut, FnOnce}, // :fn
712 option::Option::{self, None, Some}, // :option
713 result::Result::{self, Err, Ok}, // :result
718 pub use super::v1::*;
722 pub use super::v1::*;
726 pub use super::v1::*;