internal: add option to minicore
This commit is contained in:
parent
3efe5c3426
commit
2870d2bade
3 changed files with 25 additions and 41 deletions
|
|
@ -26,25 +26,14 @@ fn test() {
|
|||
fn infer_async() {
|
||||
check_types(
|
||||
r#"
|
||||
//- /main.rs crate:main deps:core
|
||||
async fn foo() -> u64 {
|
||||
128
|
||||
}
|
||||
//- minicore: future
|
||||
async fn foo() -> u64 { 128 }
|
||||
|
||||
fn test() {
|
||||
let r = foo();
|
||||
let v = r.await;
|
||||
v;
|
||||
} //^ u64
|
||||
|
||||
//- /core.rs crate:core
|
||||
#[prelude_import] use future::*;
|
||||
mod future {
|
||||
#[lang = "future_trait"]
|
||||
trait Future {
|
||||
type Output;
|
||||
}
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
|
@ -53,24 +42,13 @@ mod future {
|
|||
fn infer_desugar_async() {
|
||||
check_types(
|
||||
r#"
|
||||
//- /main.rs crate:main deps:core
|
||||
async fn foo() -> u64 {
|
||||
128
|
||||
}
|
||||
//- minicore: future
|
||||
async fn foo() -> u64 { 128 }
|
||||
|
||||
fn test() {
|
||||
let r = foo();
|
||||
r;
|
||||
} //^ impl Future<Output = u64>
|
||||
|
||||
//- /core.rs crate:core
|
||||
#[prelude_import] use future::*;
|
||||
mod future {
|
||||
trait Future {
|
||||
type Output;
|
||||
}
|
||||
}
|
||||
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
|
@ -79,7 +57,7 @@ mod future {
|
|||
fn infer_async_block() {
|
||||
check_types(
|
||||
r#"
|
||||
//- /main.rs crate:main deps:core
|
||||
//- minicore: future, option
|
||||
async fn test() {
|
||||
let a = async { 42 };
|
||||
a;
|
||||
|
|
@ -91,7 +69,7 @@ async fn test() {
|
|||
b;
|
||||
// ^ ()
|
||||
let c = async {
|
||||
let y = Option::None;
|
||||
let y = None;
|
||||
y
|
||||
// ^ Option<u64>
|
||||
};
|
||||
|
|
@ -99,18 +77,6 @@ async fn test() {
|
|||
c;
|
||||
// ^ impl Future<Output = Option<u64>>
|
||||
}
|
||||
|
||||
enum Option<T> { None, Some(T) }
|
||||
|
||||
//- /core.rs crate:core
|
||||
#[prelude_import] use future::*;
|
||||
mod future {
|
||||
#[lang = "future_trait"]
|
||||
trait Future {
|
||||
type Output;
|
||||
}
|
||||
}
|
||||
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -198,6 +198,7 @@ impl MiniCore {
|
|||
self.activated_flags.iter().any(|it| it == flag)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn assert_valid_flag(&self, flag: &str) {
|
||||
if !self.valid_flags.iter().any(|it| it == flag) {
|
||||
panic!("invalid flag: {:?}, valid flags: {:?}", flag, self.valid_flags);
|
||||
|
|
@ -299,6 +300,7 @@ impl MiniCore {
|
|||
let skip = if flag == "" {
|
||||
false
|
||||
} else {
|
||||
assert!(!flag.starts_with(' '), "region marker starts with a space: {:?}", flag);
|
||||
self.assert_valid_flag(flag);
|
||||
!self.has_flag(flag)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
//! coerce_unsized: unsize
|
||||
//! pin:
|
||||
//! future: pin
|
||||
//! option:
|
||||
|
||||
pub mod marker {
|
||||
// region:sized
|
||||
|
|
@ -115,6 +116,17 @@ pub mod slice {
|
|||
}
|
||||
// endregion:slice
|
||||
|
||||
// region:option
|
||||
pub mod option {
|
||||
pub enum Option<T> {
|
||||
#[lang = "None"]
|
||||
None,
|
||||
#[lang = "Some"]
|
||||
Some(T),
|
||||
}
|
||||
}
|
||||
// endregion:option
|
||||
|
||||
// region:pin
|
||||
pub mod pin {
|
||||
#[lang = "pin"]
|
||||
|
|
@ -127,7 +139,10 @@ pub mod pin {
|
|||
|
||||
// region:future
|
||||
pub mod future {
|
||||
use crate::{pin::Pin, task::{Poll, Context}};
|
||||
use crate::{
|
||||
pin::Pin,
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
#[lang = "future_trait"]
|
||||
pub trait Future {
|
||||
|
|
@ -153,6 +168,7 @@ pub mod task {
|
|||
pub mod prelude {
|
||||
pub mod v1 {
|
||||
pub use crate::marker::Sized; // :sized
|
||||
pub use crate::option::Option::{self, None, Some}; // :option
|
||||
}
|
||||
|
||||
pub mod rust_2015 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue