internal: add future to minicore
This commit is contained in:
parent
2eef66a2ed
commit
3efe5c3426
@ -6,10 +6,10 @@ use super::{check_infer, check_infer_with_mismatches, check_types};
|
||||
fn infer_await() {
|
||||
check_types(
|
||||
r#"
|
||||
//- /main.rs crate:main deps:core
|
||||
//- minicore: future
|
||||
struct IntFuture;
|
||||
|
||||
impl Future for IntFuture {
|
||||
impl core::future::Future for IntFuture {
|
||||
type Output = u64;
|
||||
}
|
||||
|
||||
@ -18,16 +18,6 @@ fn test() {
|
||||
let v = r.await;
|
||||
v;
|
||||
} //^ u64
|
||||
|
||||
//- /core.rs crate:core
|
||||
pub mod prelude {
|
||||
pub mod rust_2018 {
|
||||
#[lang = "future_trait"]
|
||||
pub trait Future {
|
||||
type Output;
|
||||
}
|
||||
}
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
@ -14,6 +14,8 @@
|
||||
//! unsize: sized
|
||||
//! deref: sized
|
||||
//! coerce_unsized: unsize
|
||||
//! pin:
|
||||
//! future: pin
|
||||
|
||||
pub mod marker {
|
||||
// region:sized
|
||||
@ -113,6 +115,41 @@ pub mod slice {
|
||||
}
|
||||
// endregion:slice
|
||||
|
||||
// region:pin
|
||||
pub mod pin {
|
||||
#[lang = "pin"]
|
||||
#[fundamental]
|
||||
pub struct Pin<P> {
|
||||
pointer: P,
|
||||
}
|
||||
}
|
||||
// endregion:pin
|
||||
|
||||
// region:future
|
||||
pub mod future {
|
||||
use crate::{pin::Pin, task::{Poll, Context}};
|
||||
|
||||
#[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
|
||||
|
||||
pub mod prelude {
|
||||
pub mod v1 {
|
||||
pub use crate::marker::Sized; // :sized
|
||||
|
Loading…
x
Reference in New Issue
Block a user