diff options
author | Aleksey Kladov <[email protected]> | 2021-06-15 20:49:00 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-06-15 20:49:00 +0100 |
commit | 3efe5c3426a311b6d617f9718b82e9a598dfa06d (patch) | |
tree | 261a0436ebf1192644ce398144d005e767326fbc | |
parent | 2eef66a2ed9b02962511e38c620efb23e2d65b00 (diff) |
internal: add future to minicore
-rw-r--r-- | crates/hir_ty/src/tests/traits.rs | 14 | ||||
-rw-r--r-- | crates/test_utils/src/minicore.rs | 37 |
2 files changed, 39 insertions, 12 deletions
diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs index fb13e3ac5..33689e081 100644 --- a/crates/hir_ty/src/tests/traits.rs +++ b/crates/hir_ty/src/tests/traits.rs | |||
@@ -6,10 +6,10 @@ use super::{check_infer, check_infer_with_mismatches, check_types}; | |||
6 | fn infer_await() { | 6 | fn infer_await() { |
7 | check_types( | 7 | check_types( |
8 | r#" | 8 | r#" |
9 | //- /main.rs crate:main deps:core | 9 | //- minicore: future |
10 | struct IntFuture; | 10 | struct IntFuture; |
11 | 11 | ||
12 | impl Future for IntFuture { | 12 | impl core::future::Future for IntFuture { |
13 | type Output = u64; | 13 | type Output = u64; |
14 | } | 14 | } |
15 | 15 | ||
@@ -18,16 +18,6 @@ fn test() { | |||
18 | let v = r.await; | 18 | let v = r.await; |
19 | v; | 19 | v; |
20 | } //^ u64 | 20 | } //^ u64 |
21 | |||
22 | //- /core.rs crate:core | ||
23 | pub mod prelude { | ||
24 | pub mod rust_2018 { | ||
25 | #[lang = "future_trait"] | ||
26 | pub trait Future { | ||
27 | type Output; | ||
28 | } | ||
29 | } | ||
30 | } | ||
31 | "#, | 21 | "#, |
32 | ); | 22 | ); |
33 | } | 23 | } |
diff --git a/crates/test_utils/src/minicore.rs b/crates/test_utils/src/minicore.rs index 8c0d122dc..127d06e59 100644 --- a/crates/test_utils/src/minicore.rs +++ b/crates/test_utils/src/minicore.rs | |||
@@ -14,6 +14,8 @@ | |||
14 | //! unsize: sized | 14 | //! unsize: sized |
15 | //! deref: sized | 15 | //! deref: sized |
16 | //! coerce_unsized: unsize | 16 | //! coerce_unsized: unsize |
17 | //! pin: | ||
18 | //! future: pin | ||
17 | 19 | ||
18 | pub mod marker { | 20 | pub mod marker { |
19 | // region:sized | 21 | // region:sized |
@@ -113,6 +115,41 @@ pub mod slice { | |||
113 | } | 115 | } |
114 | // endregion:slice | 116 | // endregion:slice |
115 | 117 | ||
118 | // region:pin | ||
119 | pub mod pin { | ||
120 | #[lang = "pin"] | ||
121 | #[fundamental] | ||
122 | pub struct Pin<P> { | ||
123 | pointer: P, | ||
124 | } | ||
125 | } | ||
126 | // endregion:pin | ||
127 | |||
128 | // region:future | ||
129 | pub mod future { | ||
130 | use crate::{pin::Pin, task::{Poll, Context}}; | ||
131 | |||
132 | #[lang = "future_trait"] | ||
133 | pub trait Future { | ||
134 | type Output; | ||
135 | #[lang = "poll"] | ||
136 | fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>; | ||
137 | } | ||
138 | } | ||
139 | pub mod task { | ||
140 | pub enum Poll<T> { | ||
141 | #[lang = "Ready"] | ||
142 | Ready(T), | ||
143 | #[lang = "Pending"] | ||
144 | Pending, | ||
145 | } | ||
146 | |||
147 | pub struct Context<'a> { | ||
148 | waker: &'a (), | ||
149 | } | ||
150 | } | ||
151 | // endregion:future | ||
152 | |||
116 | pub mod prelude { | 153 | pub mod prelude { |
117 | pub mod v1 { | 154 | pub mod v1 { |
118 | pub use crate::marker::Sized; // :sized | 155 | pub use crate::marker::Sized; // :sized |