diff --git a/Cargo.toml b/Cargo.toml index adfaba4..76a28ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,6 @@ futures-core-preview = { version = "0.3.0-alpha.18", default-features = false } pin-project = "0.4" [dev-dependencies] -compiletest = { version = "=0.3.22", package = "compiletest_rs", features = ["stable", "tmp"] } +trybuild = "1.0" futures-preview = "0.3.0-alpha.18" romio = "0.3.0-alpha.10" diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a5ec8cc..1d8eb5b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -40,10 +40,7 @@ jobs: parameters: toolchain: nightly - script: | - cargo clean - cargo test -p futures-async-stream --all-features --test compiletest - env: - RUSTFLAGS: -Dwarnings --cfg compiletest + RUSTFLAGS='-Dwarnings --cfg compiletest' cargo test -p futures-async-stream --all-features --test compiletest displayName: compiletest - job: clippy @@ -116,7 +113,5 @@ jobs: parameters: toolchain: nightly - script: | - cargo doc --no-deps --all --all-features - env: - RUSTDOCFLAGS: -Dwarnings + RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all --all-features displayName: cargo doc diff --git a/compiletest.sh b/compiletest.sh index cc4519b..d1e2c0c 100644 --- a/compiletest.sh +++ b/compiletest.sh @@ -8,4 +8,5 @@ # . ./compiletest.sh # ``` -rm -rf target/debug/deps/libfutures_async_stream* && RUSTFLAGS='--cfg compiletest' cargo +nightly test -p futures-async-stream --all-features --test compiletest +TRYBUILD=overwrite RUSTFLAGS='--cfg compiletest' cargo +nightly test -p futures-async-stream --all-features --test compiletest +# RUSTFLAGS='--cfg compiletest' cargo +nightly test -p futures-async-stream --all-features --test compiletest diff --git a/tests/compiletest.rs b/tests/compiletest.rs index 99b83ed..8b733b4 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -1,30 +1,8 @@ #![cfg(compiletest)] #![warn(rust_2018_idioms)] -use std::{env, path::PathBuf}; - -fn run_mode(mode: &'static str) { - let mut config = compiletest::Config::default(); - config.mode = mode.parse().expect("invalid mode"); - let mut me = env::current_exe().unwrap(); - me.pop(); - config.target_rustcflags = Some(format!( - "--edition=2018 \ - -Z unstable-options \ - --extern futures_async_stream \ - -L {}", - me.display() - )); - let src = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - config.src_base = src.join("tests").join(mode); - - me.pop(); - me.pop(); - config.build_base = me.join("tests").join(mode); - compiletest::run_tests(&config); -} - #[test] -fn compiletest() { - run_mode("ui"); +fn ui() { + let t = trybuild::TestCases::new(); + t.compile_fail("tests/ui/*.rs"); } diff --git a/tests/ui/bad-item-type.stderr b/tests/ui/bad-item-type.stderr index bb26082..3abffae 100644 --- a/tests/ui/bad-item-type.stderr +++ b/tests/ui/bad-item-type.stderr @@ -125,7 +125,5 @@ note: the type is part of the generator because of this `yield` 18 | #[async_stream(item = (i32, i32))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 11 previous errors - Some errors have detailed explanations: E0271, E0308, E0698. For more information about an error, try `rustc --explain E0271`. diff --git a/tests/ui/forget-semicolon.stderr b/tests/ui/forget-semicolon.stderr index 27b85f9..3c9d1fd 100644 --- a/tests/ui/forget-semicolon.stderr +++ b/tests/ui/forget-semicolon.stderr @@ -9,6 +9,4 @@ error[E0308]: mismatched types = note: expected type `()` found type `std::option::Option<()>` -error: aborting due to previous error - For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/invalid-arguments.stderr b/tests/ui/invalid-arguments.stderr index 5766e6b..ad1764c 100644 --- a/tests/ui/invalid-arguments.stderr +++ b/tests/ui/invalid-arguments.stderr @@ -45,6 +45,3 @@ error: `boxed` and `boxed_local` cannot be used at the same time. | 52 | #[async_stream(item = i32, boxed_local, boxed)] //~ ERROR `boxed` and `boxed_local` cannot be used at the same time. | ^^^^^ - -error: aborting due to 8 previous errors - diff --git a/tests/ui/invalid-function.stderr b/tests/ui/invalid-function.stderr index ab3fbe9..9f18037 100644 --- a/tests/ui/invalid-function.stderr +++ b/tests/ui/invalid-function.stderr @@ -27,6 +27,3 @@ error: async stream must return the unit type | 17 | async fn output() -> i32 {} //~ ERROR async stream must return the unit type | ^^^ - -error: aborting due to 5 previous errors - diff --git a/tests/ui/missing-item.stderr b/tests/ui/missing-item.stderr index 28df34b..ff0848b 100644 --- a/tests/ui/missing-item.stderr +++ b/tests/ui/missing-item.stderr @@ -3,6 +3,3 @@ error: unexpected end of input, expected `item` | 7 | #[async_stream] //~ ERROR unexpected end of input, expected `item` | ^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/move-captured-variable.stderr b/tests/ui/move-captured-variable.stderr index d4efc67..c0fb9db 100644 --- a/tests/ui/move-captured-variable.stderr +++ b/tests/ui/move-captured-variable.stderr @@ -16,6 +16,4 @@ error[E0507]: cannot move out of `a`, a captured variable in an `FnMut` closure | |__________move out of `a` occurs here | in this macro invocation -error: aborting due to previous error - For more information about this error, try `rustc --explain E0507`. diff --git a/tests/ui/nested.stderr b/tests/ui/nested.stderr index b6b82cb..1b02285 100644 --- a/tests/ui/nested.stderr +++ b/tests/ui/nested.stderr @@ -3,6 +3,3 @@ error[E0727]: `async` generators are not yet supported | 19 | yield i * i; //~ ERROR `async` generators are not yet supported [E0727] | ^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/question-mark-await-type-error.stderr b/tests/ui/question-mark-await-type-error.stderr index 317d6fd..ce72144 100644 --- a/tests/ui/question-mark-await-type-error.stderr +++ b/tests/ui/question-mark-await-type-error.stderr @@ -154,7 +154,5 @@ error[E0277]: the `?` operator can only be applied to values that implement `std = help: the trait `std::ops::Try` is not implemented for `()` = note: required by `std::ops::Try::into_result` -error: aborting due to 14 previous errors - Some errors have detailed explanations: E0277, E0698. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/threads-sendsync.stderr b/tests/ui/threads-sendsync.stderr index dde9013..e95cefd 100644 --- a/tests/ui/threads-sendsync.stderr +++ b/tests/ui/threads-sendsync.stderr @@ -12,6 +12,4 @@ error[E0277]: `dyn futures_core::stream::Stream` cannot be sent betw = note: required because it appears within the type `std::boxed::Box>` = note: required because it appears within the type `std::pin::Pin>>` -error: aborting due to previous error - For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/type-error.stderr b/tests/ui/type-error.stderr index 2e06341..bcebc0a 100644 --- a/tests/ui/type-error.stderr +++ b/tests/ui/type-error.stderr @@ -7,6 +7,4 @@ error[E0308]: mismatched types = 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/tests/ui/unresolved-type.stderr b/tests/ui/unresolved-type.stderr index fe05d78..213337a 100644 --- a/tests/ui/unresolved-type.stderr +++ b/tests/ui/unresolved-type.stderr @@ -3,17 +3,29 @@ error[E0412]: cannot find type `Left` in this scope | 7 | #[async_stream(item = Left)] //~ ERROR cannot find type `Left` in this scope | ^^^^ not found in this scope -help: there is an enum variant `core::fmt::Alignment::Left` and 4 others; try using the variant's enum +help: there is an enum variant `core::fmt::Alignment::Left` and 9 others; try using the variant's enum | 7 | #[async_stream(item = core::fmt::Alignment)] //~ ERROR cannot find type `Left` in this scope | ^^^^^^^^^^^^^^^^^^^^ 7 | #[async_stream(item = core::fmt::rt::v1::Alignment)] //~ ERROR cannot find type `Left` in this scope | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -7 | #[async_stream(item = std::fmt::Alignment)] //~ ERROR cannot find type `Left` in this scope - | ^^^^^^^^^^^^^^^^^^^ -7 | #[async_stream(item = std::fmt::rt::v1::Alignment)] //~ ERROR cannot find type `Left` in this scope - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +7 | #[async_stream(item = futures::core_reexport::fmt::Alignment)] //~ ERROR cannot find type `Left` in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +7 | #[async_stream(item = futures::core_reexport::fmt::rt::v1::Alignment)] //~ ERROR cannot find type `Left` in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +and 5 other candidates -error: aborting due to previous error +error[E0698]: type inside generator must be known in this context + --> $DIR/unresolved-type.rs:7:1 + | +7 | #[async_stream(item = Left)] //~ ERROR cannot find type `Left` in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for `T` + | +note: the type is part of the generator because of this `yield` + --> $DIR/unresolved-type.rs:7:1 + | +7 | #[async_stream(item = Left)] //~ ERROR cannot find type `Left` in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -For more information about this error, try `rustc --explain E0412`. +Some errors have detailed explanations: E0412, E0698. +For more information about an error, try `rustc --explain E0412`. diff --git a/tests/ui/update-all-references.sh b/tests/ui/update-all-references.sh deleted file mode 100644 index 207a562..0000000 --- a/tests/ui/update-all-references.sh +++ /dev/null @@ -1,24 +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 -cd - diff --git a/tests/ui/update-references.sh b/tests/ui/update-references.sh deleted file mode 100644 index 7883690..0000000 --- a/tests/ui/update-references.sh +++ /dev/null @@ -1,40 +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