Add tests
This commit is contained in:
parent
0eb2adb7e8
commit
cd2fd34ca6
14
tests/ui/async-await/async-fn/dyn-pos.rs
Normal file
14
tests/ui/async-await/async-fn/dyn-pos.rs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// edition:2018
|
||||||
|
|
||||||
|
#![feature(async_closure)]
|
||||||
|
|
||||||
|
fn foo(x: &dyn async Fn()) {}
|
||||||
|
//~^ ERROR the trait `AsyncFn` cannot be made into an object
|
||||||
|
//~| ERROR the trait `AsyncFn` cannot be made into an object
|
||||||
|
//~| ERROR the trait `AsyncFn` cannot be made into an object
|
||||||
|
//~| ERROR the trait `AsyncFn` cannot be made into an object
|
||||||
|
//~| ERROR the trait `AsyncFnMut` cannot be made into an object
|
||||||
|
//~| ERROR the trait `AsyncFnMut` cannot be made into an object
|
||||||
|
//~| ERROR the trait `AsyncFnMut` cannot be made into an object
|
||||||
|
|
||||||
|
fn main() {}
|
87
tests/ui/async-await/async-fn/dyn-pos.stderr
Normal file
87
tests/ui/async-await/async-fn/dyn-pos.stderr
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
error[E0038]: the trait `AsyncFn` cannot be made into an object
|
||||||
|
--> $DIR/dyn-pos.rs:5:16
|
||||||
|
|
|
||||||
|
LL | fn foo(x: &dyn async Fn()) {}
|
||||||
|
| ^^^^^^^^^^ `AsyncFn` cannot be made into an object
|
||||||
|
|
|
||||||
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
|
--> $SRC_DIR/core/src/ops/async_function.rs:LL:COL
|
||||||
|
|
|
||||||
|
= note: the trait cannot be made into an object because it contains the generic associated type `CallFuture`
|
||||||
|
|
||||||
|
error[E0038]: the trait `AsyncFnMut` cannot be made into an object
|
||||||
|
--> $DIR/dyn-pos.rs:5:16
|
||||||
|
|
|
||||||
|
LL | fn foo(x: &dyn async Fn()) {}
|
||||||
|
| ^^^^^^^^^^ `AsyncFnMut` cannot be made into an object
|
||||||
|
|
|
||||||
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
|
--> $SRC_DIR/core/src/ops/async_function.rs:LL:COL
|
||||||
|
|
|
||||||
|
= note: the trait cannot be made into an object because it contains the generic associated type `CallMutFuture`
|
||||||
|
|
||||||
|
error[E0038]: the trait `AsyncFn` cannot be made into an object
|
||||||
|
--> $DIR/dyn-pos.rs:5:16
|
||||||
|
|
|
||||||
|
LL | fn foo(x: &dyn async Fn()) {}
|
||||||
|
| ^^^^^^^^^^ `AsyncFn` cannot be made into an object
|
||||||
|
|
|
||||||
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
|
--> $SRC_DIR/core/src/ops/async_function.rs:LL:COL
|
||||||
|
|
|
||||||
|
= note: the trait cannot be made into an object because it contains the generic associated type `CallFuture`
|
||||||
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||||
|
|
||||||
|
error[E0038]: the trait `AsyncFnMut` cannot be made into an object
|
||||||
|
--> $DIR/dyn-pos.rs:5:16
|
||||||
|
|
|
||||||
|
LL | fn foo(x: &dyn async Fn()) {}
|
||||||
|
| ^^^^^^^^^^ `AsyncFnMut` cannot be made into an object
|
||||||
|
|
|
||||||
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
|
--> $SRC_DIR/core/src/ops/async_function.rs:LL:COL
|
||||||
|
|
|
||||||
|
= note: the trait cannot be made into an object because it contains the generic associated type `CallMutFuture`
|
||||||
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||||
|
|
||||||
|
error[E0038]: the trait `AsyncFn` cannot be made into an object
|
||||||
|
--> $DIR/dyn-pos.rs:5:16
|
||||||
|
|
|
||||||
|
LL | fn foo(x: &dyn async Fn()) {}
|
||||||
|
| ^^^^^^^^^^ `AsyncFn` cannot be made into an object
|
||||||
|
|
|
||||||
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
|
--> $SRC_DIR/core/src/ops/async_function.rs:LL:COL
|
||||||
|
|
|
||||||
|
= note: the trait cannot be made into an object because it contains the generic associated type `CallFuture`
|
||||||
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||||
|
|
||||||
|
error[E0038]: the trait `AsyncFnMut` cannot be made into an object
|
||||||
|
--> $DIR/dyn-pos.rs:5:16
|
||||||
|
|
|
||||||
|
LL | fn foo(x: &dyn async Fn()) {}
|
||||||
|
| ^^^^^^^^^^ `AsyncFnMut` cannot be made into an object
|
||||||
|
|
|
||||||
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
|
--> $SRC_DIR/core/src/ops/async_function.rs:LL:COL
|
||||||
|
|
|
||||||
|
= note: the trait cannot be made into an object because it contains the generic associated type `CallMutFuture`
|
||||||
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||||
|
|
||||||
|
error[E0038]: the trait `AsyncFn` cannot be made into an object
|
||||||
|
--> $DIR/dyn-pos.rs:5:12
|
||||||
|
|
|
||||||
|
LL | fn foo(x: &dyn async Fn()) {}
|
||||||
|
| ^^^^^^^^^^^^^^ `AsyncFn` cannot be made into an object
|
||||||
|
|
|
||||||
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
|
--> $SRC_DIR/core/src/ops/async_function.rs:LL:COL
|
||||||
|
|
|
||||||
|
= note: the trait cannot be made into an object because it contains the generic associated type `CallFuture`
|
||||||
|
::: $SRC_DIR/core/src/ops/async_function.rs:LL:COL
|
||||||
|
|
|
||||||
|
= note: the trait cannot be made into an object because it contains the generic associated type `CallMutFuture`
|
||||||
|
|
||||||
|
error: aborting due to 7 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0038`.
|
8
tests/ui/async-await/async-fn/edition-2015.rs
Normal file
8
tests/ui/async-await/async-fn/edition-2015.rs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// FIXME(async_closures): This error message could be made better.
|
||||||
|
|
||||||
|
fn foo(x: impl async Fn()) -> impl async Fn() {}
|
||||||
|
//~^ ERROR expected
|
||||||
|
//~| ERROR expected
|
||||||
|
//~| ERROR expected
|
||||||
|
|
||||||
|
fn main() {}
|
22
tests/ui/async-await/async-fn/edition-2015.stderr
Normal file
22
tests/ui/async-await/async-fn/edition-2015.stderr
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
error: expected one of `:` or `|`, found `)`
|
||||||
|
--> $DIR/edition-2015.rs:3:26
|
||||||
|
|
|
||||||
|
LL | fn foo(x: impl async Fn()) -> impl async Fn() {}
|
||||||
|
| ^ expected one of `:` or `|`
|
||||||
|
|
||||||
|
error: expected one of `(`, `)`, `+`, `,`, `::`, or `<`, found `Fn`
|
||||||
|
--> $DIR/edition-2015.rs:3:22
|
||||||
|
|
|
||||||
|
LL | fn foo(x: impl async Fn()) -> impl async Fn() {}
|
||||||
|
| -^^ expected one of `(`, `)`, `+`, `,`, `::`, or `<`
|
||||||
|
| |
|
||||||
|
| help: missing `,`
|
||||||
|
|
||||||
|
error: expected one of `(`, `+`, `::`, `<`, `where`, or `{`, found `Fn`
|
||||||
|
--> $DIR/edition-2015.rs:3:42
|
||||||
|
|
|
||||||
|
LL | fn foo(x: impl async Fn()) -> impl async Fn() {}
|
||||||
|
| ^^ expected one of `(`, `+`, `::`, `<`, `where`, or `{`
|
||||||
|
|
||||||
|
error: aborting due to 3 previous errors
|
||||||
|
|
8
tests/ui/async-await/async-fn/impl-header.rs
Normal file
8
tests/ui/async-await/async-fn/impl-header.rs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// edition:2018
|
||||||
|
|
||||||
|
struct F;
|
||||||
|
|
||||||
|
impl async Fn<()> for F {}
|
||||||
|
//~^ ERROR expected type, found keyword `async`
|
||||||
|
|
||||||
|
fn main() {}
|
8
tests/ui/async-await/async-fn/impl-header.stderr
Normal file
8
tests/ui/async-await/async-fn/impl-header.stderr
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
error: expected type, found keyword `async`
|
||||||
|
--> $DIR/impl-header.rs:5:6
|
||||||
|
|
|
||||||
|
LL | impl async Fn<()> for F {}
|
||||||
|
| ^^^^^ expected type
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
15
tests/ui/async-await/async-fn/impl-trait.rs
Normal file
15
tests/ui/async-await/async-fn/impl-trait.rs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// edition:2018
|
||||||
|
// check-pass
|
||||||
|
|
||||||
|
#![feature(async_closure, type_alias_impl_trait)]
|
||||||
|
|
||||||
|
type Tait = impl async Fn();
|
||||||
|
fn tait() -> Tait {
|
||||||
|
|| async {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn foo(x: impl async Fn()) -> impl async Fn() { x }
|
||||||
|
|
||||||
|
fn param<T: async Fn()>() {}
|
||||||
|
|
||||||
|
fn main() {}
|
7
tests/ui/async-await/async-fn/method-call-pos.rs
Normal file
7
tests/ui/async-await/async-fn/method-call-pos.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// edition:2018
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
<_ as async Fn()>(|| async {});
|
||||||
|
//~^ ERROR expected identifier, found keyword `async`
|
||||||
|
//~| ERROR expected one of
|
||||||
|
}
|
14
tests/ui/async-await/async-fn/method-call-pos.stderr
Normal file
14
tests/ui/async-await/async-fn/method-call-pos.stderr
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
error: expected identifier, found keyword `async`
|
||||||
|
--> $DIR/method-call-pos.rs:4:11
|
||||||
|
|
|
||||||
|
LL | <_ as async Fn()>(|| async {});
|
||||||
|
| ^^^^^ expected identifier, found keyword
|
||||||
|
|
||||||
|
error: expected one of `(`, `::`, `<`, or `>`, found `Fn`
|
||||||
|
--> $DIR/method-call-pos.rs:4:17
|
||||||
|
|
|
||||||
|
LL | <_ as async Fn()>(|| async {});
|
||||||
|
| ^^ expected one of `(`, `::`, `<`, or `>`
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
Loading…
Reference in New Issue
Block a user