diff --git a/futures/testcrate/Cargo.toml b/futures/testcrate/Cargo.toml deleted file mode 100644 index 96ed23238c..0000000000 --- a/futures/testcrate/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "testcrate" -version = "0.1.0" -authors = ["Alex Crichton "] - -[lib] -path = "lib.rs" - -[dependencies.futures] -features = ["std", "nightly"] -path = ".." - -[dev-dependencies] -compiletest_rs = "0.3.7" - -[[test]] -name = "ui" -harness = false - -[workspace] diff --git a/futures/testcrate/lib.rs b/futures/testcrate/lib.rs deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/futures/testcrate/tests/ui.rs b/futures/testcrate/tests/ui.rs deleted file mode 100644 index dc1f49044a..0000000000 --- a/futures/testcrate/tests/ui.rs +++ /dev/null @@ -1,21 +0,0 @@ -fn run_mode(mode: &'static str) { - use std::env; - use std::path::PathBuf; - - let mut config = compiletest_rs::Config::default(); - config.mode = mode.parse().expect("invalid mode"); - let mut me = env::current_exe().unwrap(); - me.pop(); - config.target_rustcflags = Some(format!("-L {}", me.display())); - let src = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - config.src_base = src.join(mode); - - me.pop(); - me.pop(); - config.build_base = me.join("tests").join(mode); - compiletest_rs::run_tests(&config); -} - -fn main() { - run_mode("ui"); -} diff --git a/futures/testcrate/ui/bad-return-type.rs b/futures/testcrate/ui/bad-return-type.rs deleted file mode 100644 index 0fd2187064..0000000000 --- a/futures/testcrate/ui/bad-return-type.rs +++ /dev/null @@ -1,33 +0,0 @@ -#![feature(proc_macro, generators)] - -#[async] -fn foobar() -> Result, ()> { - let val = Some(42); - if val.is_none() { - return Ok(None) - } - let val = val.unwrap(); - Ok(val) -} - -#[async_stream(item = Option)] -fn foobars() -> Result<(), ()> { - let val = Some(42); - if val.is_none() { - stream_yield!(None); - return Ok(()) - } - let val = val.unwrap(); - stream_yield!(val); - Ok(()) -} - -#[async] -fn tuple() -> Result<(i32, i32), ()> { - if false { - return Ok(3); - } - Ok((1, 2)) -} - -fn main() {} diff --git a/futures/testcrate/ui/bad-return-type.stderr b/futures/testcrate/ui/bad-return-type.stderr deleted file mode 100644 index 1e71aa7ab8..0000000000 --- a/futures/testcrate/ui/bad-return-type.stderr +++ /dev/null @@ -1,90 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/bad-return-type.rs:14:8 - | -14 | Ok(val) - | ^^^ - | | - | expected enum `std::option::Option`, found integral variable - | help: try using a variant of the expected type: `Some(val)` - | - = note: expected type `std::option::Option` - found type `{integer}` - -error[E0308]: mismatched types - --> $DIR/bad-return-type.rs:25:5 - | -25 | stream_yield!(val); - | ^^^^^^^^^^^^^^^^^^^ - | | - | expected enum `std::option::Option`, found integral variable - | help: try using a variant of the expected type: `Some(e)` - | - = note: expected type `std::option::Option<_>` - found type `{integer}` - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -error[E0907]: type inside generator must be known in this context - --> $DIR/bad-return-type.rs:19:9 - | -19 | let val = Some(42); - | ^^^ - | -note: the type is part of the generator because of this `yield` - --> $DIR/bad-return-type.rs:25:5 - | -25 | stream_yield!(val); - | ^^^^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -error[E0907]: type inside generator must be known in this context - --> $DIR/bad-return-type.rs:24:9 - | -24 | let val = val.unwrap(); - | ^^^ - | -note: the type is part of the generator because of this `yield` - --> $DIR/bad-return-type.rs:25:5 - | -25 | stream_yield!(val); - | ^^^^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -error[E0907]: type inside generator must be known in this context - --> $DIR/bad-return-type.rs:25:5 - | -25 | stream_yield!(val); - | ^^^^^^^^^^^^^^^^^^^ - | -note: the type is part of the generator because of this `yield` - --> $DIR/bad-return-type.rs:25:5 - | -25 | stream_yield!(val); - | ^^^^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -error[E0907]: type inside generator must be known in this context - --> $DIR/bad-return-type.rs:25:5 - | -25 | stream_yield!(val); - | ^^^^^^^^^^^^^^^^^^^ - | -note: the type is part of the generator because of this `yield` - --> $DIR/bad-return-type.rs:25:5 - | -25 | stream_yield!(val); - | ^^^^^^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -error[E0308]: mismatched types - --> $DIR/bad-return-type.rs:32:19 - | -32 | return Ok(3); - | ^ expected tuple, found integral variable - | - = note: expected type `(i32, i32)` - found type `{integer}` - -error: aborting due to 7 previous errors - -Some errors occurred: E0308, E0907. -For more information about an error, try `rustc --explain E0308`. diff --git a/futures/testcrate/ui/forget-ok.rs b/futures/testcrate/ui/forget-ok.rs deleted file mode 100644 index eb86ce7f76..0000000000 --- a/futures/testcrate/ui/forget-ok.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![feature(proc_macro, generators)] - -#[async] -fn foo() -> Result<(), ()> { -} - -#[async_stream(item = i32)] -fn foos() -> Result<(), ()> { -} - -fn main() {} diff --git a/futures/testcrate/ui/forget-ok.stderr b/futures/testcrate/ui/forget-ok.stderr deleted file mode 100644 index 3cb1ad5f34..0000000000 --- a/futures/testcrate/ui/forget-ok.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/forget-ok.rs:8:28 - | -8 | fn foo() -> Result<(), ()> { - | ____________________________^ -9 | | } - | |_^ expected enum `std::result::Result`, found () - | - = note: expected type `std::result::Result<(), ()>` - found type `()` - -error[E0308]: mismatched types - --> $DIR/forget-ok.rs:12:29 - | -12 | fn foos() -> Result<(), ()> { - | _____________________________^ -13 | | } - | |_^ expected enum `std::result::Result`, found () - | - = note: expected type `std::result::Result<(), ()>` - found type `()` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/futures/testcrate/ui/missing-item.rs b/futures/testcrate/ui/missing-item.rs deleted file mode 100644 index 60972fbe43..0000000000 --- a/futures/testcrate/ui/missing-item.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![allow(warnings)] -#![feature(proc_macro, generators)] - -#[async_stream] -fn foos(a: String) -> Result<(), u32> { - Ok(()) -} - -fn main() {} diff --git a/futures/testcrate/ui/missing-item.stderr b/futures/testcrate/ui/missing-item.stderr deleted file mode 100644 index 2a446ba00b..0000000000 --- a/futures/testcrate/ui/missing-item.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: custom attribute panicked - --> $DIR/missing-item.rs:8:1 - | -8 | #[async_stream] - | ^^^^^^^^^^^^^^^ - | - = help: message: #[async_stream] requires item type to be specified - -error: aborting due to previous error - diff --git a/futures/testcrate/ui/move-captured-variable.rs b/futures/testcrate/ui/move-captured-variable.rs deleted file mode 100644 index cf14818633..0000000000 --- a/futures/testcrate/ui/move-captured-variable.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![feature(proc_macro, generators)] - -fn foo(_f: F) {} - -fn main() { - let a = String::new(); - foo(|| { - async_block! { - Ok::(a) - }; - }); -} diff --git a/futures/testcrate/ui/move-captured-variable.stderr b/futures/testcrate/ui/move-captured-variable.stderr deleted file mode 100644 index 30828ab534..0000000000 --- a/futures/testcrate/ui/move-captured-variable.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0507]: cannot move out of captured outer variable in an `FnMut` closure - --> $DIR/move-captured-variable.rs:12:9 - | -10 | let a = String::new(); - | - captured outer variable -11 | foo(|| { -12 | / async_block! { -13 | | Ok::(a) -14 | | }; - | |__________^ cannot move out of captured outer variable in an `FnMut` closure - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/futures/testcrate/ui/not-a-result.rs b/futures/testcrate/ui/not-a-result.rs deleted file mode 100644 index 8bbc52bf64..0000000000 --- a/futures/testcrate/ui/not-a-result.rs +++ /dev/null @@ -1,23 +0,0 @@ -#![feature(proc_macro, generators)] - -#[async] -fn foo() -> u32 { - 3 -} - -#[async(boxed)] -fn bar() -> u32 { - 3 -} - -#[async_stream(item = u32)] -fn foos() -> u32 { - 3 -} - -#[async_stream(boxed, item = u32)] -fn bars() -> u32 { - 3 -} - -fn main() {} diff --git a/futures/testcrate/ui/not-a-result.stderr b/futures/testcrate/ui/not-a-result.stderr deleted file mode 100644 index 7f95faff36..0000000000 --- a/futures/testcrate/ui/not-a-result.stderr +++ /dev/null @@ -1,61 +0,0 @@ -error[E0277]: the trait bound `u32: futures::__rt::IsResult` is not satisfied - --> $DIR/not-a-result.rs:8:13 - | -8 | fn foo() -> u32 { - | ^^^ async functions must return a `Result` or a typedef of `Result` - | - = help: the trait `futures::__rt::IsResult` is not implemented for `u32` - = note: required by `futures::__rt::gen_future` - -error[E0277]: the trait bound `u32: futures::__rt::IsResult` is not satisfied - --> $DIR/not-a-result.rs:13:17 - | -13 | fn bar() -> u32 { - | _________________^ -14 | | 3 -15 | | } - | |_^ async functions must return a `Result` or a typedef of `Result` - | - = help: the trait `futures::__rt::IsResult` is not implemented for `u32` - -error[E0277]: the trait bound `u32: futures::__rt::IsResult` is not satisfied - --> $DIR/not-a-result.rs:13:13 - | -13 | fn bar() -> u32 { - | ^^^ async functions must return a `Result` or a typedef of `Result` - | - = help: the trait `futures::__rt::IsResult` is not implemented for `u32` - = note: required by `futures::__rt::gen_future` - -error[E0277]: the trait bound `u32: futures::__rt::IsResult` is not satisfied - --> $DIR/not-a-result.rs:18:14 - | -18 | fn foos() -> u32 { - | ^^^ async functions must return a `Result` or a typedef of `Result` - | - = help: the trait `futures::__rt::IsResult` is not implemented for `u32` - = note: required by `futures::__rt::gen_stream` - -error[E0277]: the trait bound `u32: futures::__rt::IsResult` is not satisfied - --> $DIR/not-a-result.rs:23:18 - | -23 | fn bars() -> u32 { - | __________________^ -24 | | 3 -25 | | } - | |_^ async functions must return a `Result` or a typedef of `Result` - | - = help: the trait `futures::__rt::IsResult` is not implemented for `u32` - -error[E0277]: the trait bound `u32: futures::__rt::IsResult` is not satisfied - --> $DIR/not-a-result.rs:23:14 - | -23 | fn bars() -> u32 { - | ^^^ async functions must return a `Result` or a typedef of `Result` - | - = help: the trait `futures::__rt::IsResult` is not implemented for `u32` - = note: required by `futures::__rt::gen_stream` - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/futures/testcrate/ui/type_error.rs b/futures/testcrate/ui/type_error.rs deleted file mode 100644 index 419bc4e630..0000000000 --- a/futures/testcrate/ui/type_error.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![feature(proc_macro, generators)] - -#[async] -fn foo() -> Result { - let a: i32 = "a"; //~ ERROR: mismatched types - Ok(1) -} - -fn main() {} diff --git a/futures/testcrate/ui/type_error.stderr b/futures/testcrate/ui/type_error.stderr deleted file mode 100644 index efb4b224f6..0000000000 --- a/futures/testcrate/ui/type_error.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/type_error.rs:9:18 - | -9 | let a: i32 = "a"; //~ ERROR: mismatched types - | ^^^ expected i32, found reference - | - = note: expected type `i32` - found type `&'static str` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/futures/testcrate/ui/unresolved-type.rs b/futures/testcrate/ui/unresolved-type.rs deleted file mode 100644 index 00317b1f73..0000000000 --- a/futures/testcrate/ui/unresolved-type.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(proc_macro, generators)] - -#[async] -fn foo() -> Result { - Err(3) -} - -#[async_stream(item = Left)] -fn foos() -> Result<(), u32> { - Err(3) -} - -fn main() {} diff --git a/futures/testcrate/ui/unresolved-type.stderr b/futures/testcrate/ui/unresolved-type.stderr deleted file mode 100644 index da37f5757f..0000000000 --- a/futures/testcrate/ui/unresolved-type.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0412]: cannot find type `Left` in this scope - --> $DIR/unresolved-type.rs:8:20 - | -8 | fn foo() -> Result { - | ^^^^ not found in this scope - | - = help: there is an enum variant `futures::future::Either::Left`, try using `futures::future::Either`? - = help: there is an enum variant `std::fmt::rt::v1::Alignment::Left`, try using `std::fmt::rt::v1::Alignment`? - -error[E0412]: cannot find type `Left` in this scope - --> $DIR/unresolved-type.rs:12:23 - | -12 | #[async_stream(item = Left)] - | ^^^^ not found in this scope - | - = help: there is an enum variant `futures::future::Either::Left`, try using `futures::future::Either`? - = help: there is an enum variant `std::fmt::rt::v1::Alignment::Left`, try using `std::fmt::rt::v1::Alignment`? - -error[E0907]: type inside generator must be known in this context - --> $DIR/unresolved-type.rs:12:1 - | -12 | #[async_stream(item = Left)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: the type is part of the generator because of this `yield` - --> $DIR/unresolved-type.rs:12:1 - | -12 | #[async_stream(item = Left)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 3 previous errors - -Some errors occurred: E0412, E0907. -For more information about an error, try `rustc --explain E0412`. diff --git a/futures/testcrate/ui/update-all-references.sh b/futures/testcrate/ui/update-all-references.sh deleted file mode 100755 index 7b757a4790..0000000000 --- a/futures/testcrate/ui/update-all-references.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -# -# Copyright 2015 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - -# A script to update the references for all tests. The idea is that -# you do a run, which will generate files in the build directory -# containing the (normalized) actual output of the compiler. You then -# run this script, which will copy those files over. If you find -# yourself manually editing a foo.stderr file, you're doing it wrong. -# -# See all `update-references.sh`, if you just want to update a single test. - -MY_DIR=$(dirname $0) -cd $MY_DIR -find . -name '*.rs' | xargs ./update-references.sh diff --git a/futures/testcrate/ui/update-references.sh b/futures/testcrate/ui/update-references.sh deleted file mode 100755 index 13c35dc044..0000000000 --- a/futures/testcrate/ui/update-references.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -# -# Copyright 2015 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - -# A script to update the references for particular tests. The idea is -# that you do a run, which will generate files in the build directory -# containing the (normalized) actual output of the compiler. This -# script will then copy that output and replace the "expected output" -# files. You can then commit the changes. -# -# If you find yourself manually editing a foo.stderr file, you're -# doing it wrong. - -MYDIR=$(dirname $0) - -BUILD_DIR="../../target/tests/ui" - -while [[ "$1" != "" ]]; do - STDERR_NAME="${1/%.rs/.stderr}" - STDOUT_NAME="${1/%.rs/.stdout}" - shift - if [ -f $BUILD_DIR/$STDOUT_NAME ] && \ - ! (diff $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME >& /dev/null); then - echo updating $MYDIR/$STDOUT_NAME - cp $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME - fi - if [ -f $BUILD_DIR/$STDERR_NAME ] && \ - ! (diff $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME >& /dev/null); then - echo updating $MYDIR/$STDERR_NAME - cp $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME - fi -done - - diff --git a/futures/tests_disabled/async_await/elisions.rs b/futures/tests_disabled/async_await/elisions.rs deleted file mode 100644 index 15c3a88ca0..0000000000 --- a/futures/tests_disabled/async_await/elisions.rs +++ /dev/null @@ -1,49 +0,0 @@ -use futures::stable::block_on_stable; - -struct Ref<'a, T: 'a>(&'a T); - -#[async] -fn references(x: &i32) -> Result { - Ok(*x) -} - -#[async] -fn new_types(x: Ref<'_, i32>) -> Result { - Ok(*x.0) -} - -#[async_stream(item = i32)] -fn _streams(x: &i32) -> Result<(), i32> { - stream_yield!(*x); - Ok(()) -} - -struct Foo(i32); - -impl Foo { - #[async] - fn foo(&self) -> Result<&i32, i32> { - Ok(&self.0) - } -} - -#[async] -fn single_ref(x: &i32) -> Result<&i32, i32> { - Ok(x) -} - -#[async] -fn check_for_name_colision<'_async0, T>(_x: &T, _y: &'_async0 i32) -> Result<(), ()> { - Ok(()) -} - -#[test] -fn main() { - let x = 0; - let foo = Foo(x); - assert_eq!(block_on_stable(references(&x)), Ok(x)); - assert_eq!(block_on_stable(new_types(Ref(&x))), Ok(x)); - assert_eq!(block_on_stable(single_ref(&x)), Ok(&x)); - assert_eq!(block_on_stable(foo.foo()), Ok(&x)); - assert_eq!(block_on_stable(check_for_name_colision(&x, &x)), Ok(())); -} diff --git a/futures/tests_disabled/async_await/mod.rs b/futures/tests_disabled/async_await/mod.rs deleted file mode 100644 index e7c8866eab..0000000000 --- a/futures/tests_disabled/async_await/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod elisions; -mod pinned; -mod smoke; diff --git a/futures/tests_disabled/async_await/pinned.rs b/futures/tests_disabled/async_await/pinned.rs deleted file mode 100644 index 39357c4274..0000000000 --- a/futures/tests_disabled/async_await/pinned.rs +++ /dev/null @@ -1,116 +0,0 @@ -use futures::stable::block_on_stable; -use futures::executor::{block_on, ThreadPool}; - -#[async] -fn foo() -> Result { - Ok(1) -} - -#[async] -fn bar(x: &i32) -> Result { - Ok(*x) -} - -#[async] -fn baz(x: i32) -> Result { - bar(&x).await -} - -#[async(boxed)] -fn boxed(x: i32) -> Result { - Ok(x) -} - -#[async(boxed)] -fn boxed_borrow(x: &i32) -> Result { - Ok(*x) -} - -#[async(boxed, send)] -fn boxed_send(x: i32) -> Result { - Ok(x) -} - -#[async(boxed, send)] -fn boxed_send_borrow(x: &i32) -> Result { - Ok(*x) -} - -#[async(boxed, send)] -fn spawnable() -> Result<(), Never> { - Ok(()) -} - -fn baz_block(x: i32) -> impl StableFuture { - async_block! { - bar(&x).await - } -} - -#[async_stream(item = u64)] -fn stream1() -> Result<(), i32> { - fn integer() -> u64 { 1 } - let x = &integer(); - stream_yield!(0); - stream_yield!(*x); - Ok(()) -} - -fn stream1_block() -> impl StableStream { - async_stream_block! { - #[async] - for item in stream1() { - stream_yield!(item) - } - Ok(()) - } -} - -#[async_stream(boxed, item = u64)] -fn _stream_boxed() -> Result<(), i32> { - fn integer() -> u64 { 1 } - let x = &integer(); - stream_yield!(0); - stream_yield!(*x); - Ok(()) -} - -#[async] -pub fn uses_async_for() -> Result, i32> { - let mut v = vec![]; - #[async] - for i in stream1() { - v.push(i); - } - Ok(v) -} - -#[async] -pub fn uses_async_for_block() -> Result, i32> { - let mut v = vec![]; - #[async] - for i in stream1_block() { - v.push(i); - } - Ok(v) -} - -#[test] -fn main() { - assert_eq!(block_on_stable(foo()), Ok(1)); - assert_eq!(block_on_stable(bar(&1)), Ok(1)); - assert_eq!(block_on_stable(baz(17)), Ok(17)); - assert_eq!(block_on(boxed(17)), Ok(17)); - assert_eq!(block_on(boxed_send(17)), Ok(17)); - assert_eq!(block_on(boxed_borrow(&17)), Ok(17)); - assert_eq!(block_on(boxed_send_borrow(&17)), Ok(17)); - assert_eq!(block_on_stable(baz_block(18)), Ok(18)); - assert_eq!(block_on_stable(uses_async_for()), Ok(vec![0, 1])); - assert_eq!(block_on_stable(uses_async_for_block()), Ok(vec![0, 1])); -} - -#[test] -fn run_pinned_future_in_thread_pool() { - let mut pool = ThreadPool::new().unwrap(); - pool.spawn_pinned(spawnable()).unwrap(); -} diff --git a/futures/tests_disabled/async_await/smoke.rs b/futures/tests_disabled/async_await/smoke.rs deleted file mode 100644 index 86566eb7f6..0000000000 --- a/futures/tests_disabled/async_await/smoke.rs +++ /dev/null @@ -1,223 +0,0 @@ -//! A bunch of ways to use async/await syntax. -//! -//! This is mostly a test f r this repository itself, not necessarily serving -//! much more purpose than that. - -use futures; -use futures::executor; -use futures::stable::block_on_stable; - -use std::io; - -use futures::Never; -use futures::future::poll_fn; - -#[async] -fn foo() -> Result { - Ok(1) -} - -#[async] -extern fn _foo1() -> Result { - Ok(1) -} - -#[async] -unsafe fn _foo2() -> io::Result { - Ok(1) -} - -#[async] -unsafe extern fn _foo3() -> io::Result { - Ok(1) -} - -#[async] -pub fn _foo4() -> io::Result { - Ok(1) -} - -#[async] -fn _foo5(t: T) -> Result { - Ok(t.clone()) -} - -#[async] -fn _foo6(ref a: i32) -> Result { - Err(*a) -} - -#[async] -fn _foo7(t: T) -> Result - where T: Clone + 'static, -{ - Ok(t.clone()) -} - -#[async(boxed)] -fn _foo8(a: i32, b: i32) -> Result { - return Ok(a + b) -} - -#[async(boxed, send)] -fn _foo9() -> Result<(), Never> { - Ok(()) -} - -#[async] -fn _bar() -> Result { - foo().await -} - -#[async] -fn _bar2() -> Result { - let a = foo().await?; - let b = foo().await?; - Ok(a + b) -} - -#[async] -fn _bar4() -> Result { - let mut cnt = 0; - #[async] - for x in futures::stream::iter_ok::<_, i32>(vec![1, 2, 3, 4]) { - cnt += x; - } - Ok(cnt) -} - -#[async_stream(item = u64)] -fn _stream1() -> Result<(), i32> { - stream_yield!(0); - stream_yield!(1); - Ok(()) -} - -#[async_stream(item = T)] -fn _stream2(t: T) -> Result<(), i32> { - stream_yield!(t.clone()); - stream_yield!(t.clone()); - Ok(()) -} - -#[async_stream(item = i32)] -fn _stream3() -> Result<(), i32> { - let mut cnt = 0; - #[async] - for x in futures::stream::iter_ok::<_, i32>(vec![1, 2, 3, 4]) { - cnt += x; - stream_yield!(x); - } - Err(cnt) -} - -#[async_stream(boxed, item = u64)] -fn _stream4() -> Result<(), i32> { - stream_yield!(0); - stream_yield!(1); - Ok(()) -} - -#[allow(dead_code)] -mod foo { pub struct Foo(pub i32); } - -#[allow(dead_code)] -#[async_stream(boxed, item = foo::Foo)] -pub fn stream5() -> Result<(), i32> { - stream_yield!(foo::Foo(0)); - stream_yield!(foo::Foo(1)); - Ok(()) -} - -#[async_stream(boxed, item = i32)] -pub fn _stream6() -> Result<(), i32> { - #[async] - for foo::Foo(i) in stream5() { - stream_yield!(i * i); - } - Ok(()) -} - -#[async_stream(item = ())] -pub fn _stream7() -> Result<(), i32> { - stream_yield!(()); - Ok(()) -} - -#[async_stream(item = [u32; 4])] -pub fn _stream8() -> Result<(), i32> { - stream_yield!([1, 2, 3, 4]); - Ok(()) -} - -struct A(i32); - -impl A { - #[async] - fn a_foo(self) -> Result { - Ok(self.0) - } - - #[async] - fn _a_foo2(self: Box) -> Result { - Ok(self.0) - } -} - -fn await_item_stream() -> impl Stream + Send { - ::futures::stream::iter_ok(vec![0, 1]) -} - -#[async] -fn test_await_item() -> Result<(), Never> { - let mut stream = await_item_stream(); - - assert_eq!(await_item!(stream), Ok(Some(0))); - assert_eq!(await_item!(stream), Ok(Some(1))); - assert_eq!(await_item!(stream), Ok(None)); - - Ok(()) -} - -#[test] -fn main() { - assert_eq!(block_on_stable(foo()), Ok(1)); - assert_eq!(block_on_stable(foo()), Ok(1)); - assert_eq!(block_on_stable(_bar()), Ok(1)); - assert_eq!(block_on_stable(_bar2()), Ok(2)); - assert_eq!(block_on_stable(_bar4()), Ok(10)); - assert_eq!(block_on_stable(_foo6(8)), Err(8)); - assert_eq!(block_on_stable(A(11).a_foo()), Ok(11)); - assert_eq!(block_on_stable(loop_in_loop()), Ok(true)); - assert_eq!(block_on_stable(test_await_item()), Ok(())); -} - -#[async] -fn loop_in_loop() -> Result { - let mut cnt = 0; - let vec = vec![1, 2, 3, 4]; - #[async] - for x in futures::stream::iter_ok::<_, i32>(vec.clone()) { - #[async] - for y in futures::stream::iter_ok::<_, i32>(vec.clone()) { - cnt += x * y; - } - } - - let sum = (1..5).map(|x| (1..5).map(|y| x * y).sum::()).sum::(); - Ok(cnt == sum) -} - -#[async_stream(item = i32)] -fn poll_stream_after_error_stream() -> Result<(), ()> { - stream_yield!(5); - Err(()) -} - -#[test] -fn poll_stream_after_error() { - let mut s = poll_stream_after_error_stream().pin(); - assert_eq!(executor::block_on(poll_fn(|ctx| s.poll_next(ctx))), Ok(Some(5))); - assert_eq!(executor::block_on(poll_fn(|ctx| s.poll_next(ctx))), Err(())); - assert_eq!(executor::block_on(poll_fn(|ctx| s.poll_next(ctx))), Ok(None)); -} diff --git a/futures/tests_disabled/async_await_tests.rs b/futures/tests_disabled/async_await_tests.rs deleted file mode 100644 index b3d59f5849..0000000000 --- a/futures/tests_disabled/async_await_tests.rs +++ /dev/null @@ -1,4 +0,0 @@ -#![cfg_attr(feature = "nightly", feature(proc_macro, generators))] - -#[cfg(feature = "nightly")] -mod async_await;