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
45 #[rustc_specialization_trait]
51 pub trait Unsize<T: ?Sized> {}
56 pub trait Copy: Clone {}
58 #[rustc_builtin_macro]
59 pub macro Copy($item:item) {}
65 macro_rules! impl_copy {
74 usize u8 u16 u32 u64 u128
75 isize i8 i16 i32 i64 i128
80 impl<T: ?Sized> Copy for *const T {}
81 impl<T: ?Sized> Copy for *mut T {}
82 impl<T: ?Sized> Copy for &T {}
89 pub trait Default: Sized {
93 #[rustc_builtin_macro]
94 pub macro Default($item:item) {}
104 fn hash<H: Hasher>(&self, state: &mut H);
112 pub trait Clone: Sized {
113 fn clone(&self) -> Self;
116 #[rustc_builtin_macro]
117 pub macro Clone($item:item) {}
124 pub trait From<T>: Sized {
125 fn from(_: T) -> Self;
127 pub trait Into<T>: Sized {
131 impl<T, U> Into<U> for T
140 impl<T> From<T> for T {
148 pub trait AsRef<T: ?Sized> {
149 fn as_ref(&self) -> &T;
155 // region:coerce_unsized
157 use crate::marker::Unsize;
159 #[lang = "coerce_unsized"]
160 pub trait CoerceUnsized<T: ?Sized> {}
162 impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a mut U> for &'a mut T {}
163 impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b mut T {}
164 impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*mut U> for &'a mut T {}
165 impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for &'a mut T {}
167 impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}
168 impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for &'a T {}
170 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*mut U> for *mut T {}
171 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *mut T {}
172 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *const T {}
174 pub use self::unsize::CoerceUnsized;
175 // endregion:coerce_unsized
181 #[lang = "deref_target"]
183 fn deref(&self) -> &Self::Target;
186 #[lang = "deref_mut"]
187 pub trait DerefMut: Deref {
188 fn deref_mut(&mut self) -> &mut Self::Target;
190 // endregion:deref_mut
192 pub use self::deref::{
194 DerefMut, // :deref_mut
208 pub trait Index<Idx: ?Sized> {
210 fn index(&self, index: Idx) -> &Self::Output;
212 #[lang = "index_mut"]
213 pub trait IndexMut<Idx: ?Sized>: Index<Idx> {
214 fn index_mut(&mut self, index: Idx) -> &mut Self::Output;
218 impl<T, I> Index<I> for [T]
222 type Output = I::Output;
223 fn index(&self, index: I) -> &I::Output {
227 impl<T, I> IndexMut<I> for [T]
231 fn index_mut(&mut self, index: I) -> &mut I::Output {
236 pub unsafe trait SliceIndex<T: ?Sized> {
239 unsafe impl<T> SliceIndex<[T]> for usize {
244 pub use self::index::{Index, IndexMut};
249 pub fn drop<T>(_x: T) {}
255 #[lang = "RangeFull"]
256 pub struct RangeFull;
259 pub struct Range<Idx> {
264 #[lang = "RangeFrom"]
265 pub struct RangeFrom<Idx> {
270 pub struct RangeTo<Idx> {
274 #[lang = "RangeInclusive"]
275 pub struct RangeInclusive<Idx> {
276 pub(crate) start: Idx,
278 pub(crate) exhausted: bool,
281 #[lang = "RangeToInclusive"]
282 pub struct RangeToInclusive<Idx> {
286 pub use self::range::{Range, RangeFrom, RangeFull, RangeTo};
287 pub use self::range::{RangeInclusive, RangeToInclusive};
294 pub trait Fn<Args>: FnMut<Args> {}
298 pub trait FnMut<Args>: FnOnce<Args> {}
302 pub trait FnOnce<Args> {
303 #[lang = "fn_once_output"]
307 pub use self::function::{Fn, FnMut, FnOnce};
311 pub enum ControlFlow<B, C = ()> {
315 pub trait FromResidual<R = Self::Residual> {
316 #[lang = "from_residual"]
317 fn from_residual(residual: R) -> Self;
320 pub trait Try: FromResidual<Self::Residual> {
323 #[lang = "from_output"]
324 fn from_output(output: Self::Output) -> Self;
326 fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
329 impl<B, C> Try for ControlFlow<B, C> {
331 type Residual = ControlFlow<B, convert::Infallible>;
332 fn from_output(output: Self::Output) -> Self {}
333 fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {}
336 impl<B, C> FromResidual for ControlFlow<B, C> {
337 fn from_residual(residual: ControlFlow<B, convert::Infallible>) -> Self {}
340 pub use self::try_::{ControlFlow, FromResidual, Try};
345 pub trait Add<Rhs = Self> {
347 fn add(self, rhs: Rhs) -> Self::Output;
355 pub trait PartialEq<Rhs: ?Sized = Self> {
356 fn eq(&self, other: &Rhs) -> bool;
359 pub trait Eq: PartialEq<Self> {}
362 #[rustc_builtin_macro]
363 pub macro PartialEq($item:item) {}
364 #[rustc_builtin_macro]
365 pub macro Eq($item:item) {}
369 #[lang = "partial_ord"]
370 pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
371 fn partial_cmp(&self, other: &Rhs) -> Option<Ordering>;
374 pub trait Ord: Eq + PartialOrd<Self> {
375 fn cmp(&self, other: &Self) -> Ordering;
385 #[rustc_builtin_macro]
386 pub macro PartialOrd($item:item) {}
387 #[rustc_builtin_macro]
388 pub macro Ord($item:item) {}
398 pub type Result = Result<(), Error>;
399 pub struct Formatter<'a>;
401 fn fmt(&self, f: &mut Formatter<'_>) -> Result;
410 pub fn len(&self) -> usize {
427 pub const fn unwrap(self) -> T {
430 None => panic!("called `Option::unwrap()` on a `None` value"),
439 pub enum Result<T, E> {
462 task::{Context, Poll},
465 #[lang = "future_trait"]
469 fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>;
480 pub struct Context<'a> {
494 impl<I> Iterator for Take<I>
498 type Item = <I as Iterator>::Item;
500 fn next(&mut self) -> Option<<I as Iterator>::Item> {
505 pub struct FilterMap<I, F> {
509 impl<B, I: Iterator, F> Iterator for FilterMap<I, F>
511 F: FnMut(I::Item) -> Option<B>,
516 fn next(&mut self) -> Option<B> {
521 pub use self::adapters::Take;
525 pub fn repeat<T>(elt: T) -> Repeat<T> {
529 pub struct Repeat<A> {
533 impl<A> Iterator for Repeat<A> {
536 fn next(&mut self) -> Option<A> {
541 pub use self::repeat::{repeat, Repeat};
543 pub use self::sources::{repeat, Repeat};
544 // endregion:iterators
548 use super::super::Take;
553 fn next(&mut self) -> Option<Self::Item>;
554 fn nth(&mut self, n: usize) -> Option<Self::Item> {
557 fn by_ref(&mut self) -> &mut Self
564 fn take(self, n: usize) -> crate::iter::Take<Self> {
567 fn filter_map<B, F>(self, f: F) -> crate::iter::FilterMap<Self, F>
570 F: FnMut(Self::Item) -> Option<B>,
574 // endregion:iterators
576 impl<I: Iterator + ?Sized> Iterator for &mut I {
578 fn next(&mut self) -> Option<I::Item> {
583 pub use self::iterator::Iterator;
586 pub trait IntoIterator {
588 type IntoIter: Iterator<Item = Self::Item>;
589 #[lang = "into_iter"]
590 fn into_iter(self) -> Self::IntoIter;
592 impl<I: Iterator> IntoIterator for I {
595 fn into_iter(self) -> I {
600 pub use self::collect::IntoIterator;
602 pub use self::traits::{IntoIterator, Iterator};
604 // endregion:iterator
608 pub(crate) mod builtin {
609 #[rustc_builtin_macro]
610 pub macro derive($item:item) {
611 /* compiler built-in */
620 pub fn then<T, F: FnOnce() -> T>(self, f: F) -> Option<T> {
628 // endregion:bool_impl
633 clone::Clone, // :clone
634 cmp::{Eq, PartialEq}, // :eq
635 cmp::{Ord, PartialOrd}, // :ord
636 convert::AsRef, // :as_ref
637 convert::{From, Into}, // :from
638 default::Default, // :default
639 iter::{IntoIterator, Iterator}, // :iterator
640 macros::builtin::derive, // :derive
641 marker::Copy, // :copy
642 marker::Sized, // :sized
645 ops::{Fn, FnMut, FnOnce}, // :fn
646 option::Option::{self, None, Some}, // :option
647 result::Result::{self, Err, Ok}, // :result
652 pub use super::v1::*;
656 pub use super::v1::*;
660 pub use super::v1::*;