Add tests and error messages
This commit is contained in:
parent
0308d4ad18
commit
104aacb49f
17 changed files with 339 additions and 14 deletions
|
@ -0,0 +1,17 @@
|
|||
// edition: 2021
|
||||
|
||||
#![feature(return_type_notation, async_fn_in_trait)]
|
||||
//~^ WARN the feature `return_type_notation` is incomplete
|
||||
//~| WARN the feature `async_fn_in_trait` is incomplete
|
||||
|
||||
trait Trait {
|
||||
async fn method() {}
|
||||
}
|
||||
|
||||
fn foo<T: Trait<method(i32): Send>>() {}
|
||||
//~^ ERROR argument types not allowed with return type notation
|
||||
|
||||
fn bar<T: Trait<method() -> (): Send>>() {}
|
||||
//~^ ERROR return type not allowed with return type notation
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,31 @@
|
|||
warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/bad-inputs-and-output.rs:3:12
|
||||
|
|
||||
LL | #![feature(return_type_notation, async_fn_in_trait)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/bad-inputs-and-output.rs:3:34
|
||||
|
|
||||
LL | #![feature(return_type_notation, async_fn_in_trait)]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
|
||||
|
||||
error: argument types not allowed with return type notation
|
||||
--> $DIR/bad-inputs-and-output.rs:11:23
|
||||
|
|
||||
LL | fn foo<T: Trait<method(i32): Send>>() {}
|
||||
| ^^^^^ help: remove the input types: `()`
|
||||
|
||||
error: return type not allowed with return type notation
|
||||
--> $DIR/bad-inputs-and-output.rs:14:25
|
||||
|
|
||||
LL | fn bar<T: Trait<method() -> (): Send>>() {}
|
||||
| ^^^^^^ help: remove the return type
|
||||
|
||||
error: aborting due to 2 previous errors; 2 warnings emitted
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
// revisions: with without
|
||||
// edition: 2021
|
||||
//[with] check-pass
|
||||
|
||||
#![feature(return_type_notation, async_fn_in_trait)]
|
||||
//~^ WARN the feature `return_type_notation` is incomplete
|
||||
//~| WARN the feature `async_fn_in_trait` is incomplete
|
||||
|
||||
trait Foo {
|
||||
async fn method() -> Result<(), ()>;
|
||||
}
|
||||
|
||||
async fn foo<T: Foo>() -> Result<(), ()> {
|
||||
T::method().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn is_send(_: impl Send) {}
|
||||
|
||||
fn test<
|
||||
#[cfg(with)] T: Foo<method(): Send>,
|
||||
#[cfg(without)] T: Foo,
|
||||
>() {
|
||||
is_send(foo::<T>());
|
||||
//[without]~^ ERROR future cannot be sent between threads safely
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,19 @@
|
|||
warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/basic.rs:5:12
|
||||
|
|
||||
LL | #![feature(return_type_notation, async_fn_in_trait)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/basic.rs:5:34
|
||||
|
|
||||
LL | #![feature(return_type_notation, async_fn_in_trait)]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
|
||||
|
||||
warning: 2 warnings emitted
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/basic.rs:5:12
|
||||
|
|
||||
LL | #![feature(return_type_notation, async_fn_in_trait)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/basic.rs:5:34
|
||||
|
|
||||
LL | #![feature(return_type_notation, async_fn_in_trait)]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
|
||||
|
||||
error: future cannot be sent between threads safely
|
||||
--> $DIR/basic.rs:24:13
|
||||
|
|
||||
LL | is_send(foo::<T>());
|
||||
| ^^^^^^^^^^ future returned by `foo` is not `Send`
|
||||
|
|
||||
= help: within `impl Future<Output = Result<(), ()>>`, the trait `Send` is not implemented for `impl Future<Output = Result<(), ()>>`
|
||||
note: future is not `Send` as it awaits another future which is not `Send`
|
||||
--> $DIR/basic.rs:14:5
|
||||
|
|
||||
LL | T::method().await?;
|
||||
| ^^^^^^^^^^^ await occurs here on type `impl Future<Output = Result<(), ()>>`, which is not `Send`
|
||||
note: required by a bound in `is_send`
|
||||
--> $DIR/basic.rs:18:20
|
||||
|
|
||||
LL | fn is_send(_: impl Send) {}
|
||||
| ^^^^ required by this bound in `is_send`
|
||||
|
||||
error: aborting due to previous error; 2 warnings emitted
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
// edition: 2021
|
||||
|
||||
#![feature(return_type_notation, async_fn_in_trait)]
|
||||
//~^ WARN the feature `return_type_notation` is incomplete
|
||||
//~| WARN the feature `async_fn_in_trait` is incomplete
|
||||
|
||||
use std::future::Future;
|
||||
|
||||
trait Trait {
|
||||
async fn method() {}
|
||||
}
|
||||
|
||||
fn test<T: Trait<method() = Box<dyn Future<Output = ()>>>>() {}
|
||||
//~^ ERROR return type notation is not allowed to use type equality
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,25 @@
|
|||
warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/equality.rs:3:12
|
||||
|
|
||||
LL | #![feature(return_type_notation, async_fn_in_trait)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/equality.rs:3:34
|
||||
|
|
||||
LL | #![feature(return_type_notation, async_fn_in_trait)]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
|
||||
|
||||
error: return type notation is not allowed to use type equality
|
||||
--> $DIR/equality.rs:13:18
|
||||
|
|
||||
LL | fn test<T: Trait<method() = Box<dyn Future<Output = ()>>>>() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error; 2 warnings emitted
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
// edition: 2021
|
||||
|
||||
#![feature(return_type_notation, async_fn_in_trait)]
|
||||
//~^ WARN the feature `return_type_notation` is incomplete
|
||||
//~| WARN the feature `async_fn_in_trait` is incomplete
|
||||
|
||||
trait Trait {
|
||||
async fn method() {}
|
||||
}
|
||||
|
||||
fn bar<T: Trait<methid(): Send>>() {}
|
||||
//~^ ERROR cannot find associated function `methid` in trait `Trait`
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,25 @@
|
|||
warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/missing.rs:3:12
|
||||
|
|
||||
LL | #![feature(return_type_notation, async_fn_in_trait)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/missing.rs:3:34
|
||||
|
|
||||
LL | #![feature(return_type_notation, async_fn_in_trait)]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
|
||||
|
||||
error: cannot find associated function `methid` in trait `Trait`
|
||||
--> $DIR/missing.rs:11:17
|
||||
|
|
||||
LL | fn bar<T: Trait<methid(): Send>>() {}
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error; 2 warnings emitted
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
#![feature(return_type_notation)]
|
||||
//~^ WARN the feature `return_type_notation` is incomplete
|
||||
|
||||
trait Trait {
|
||||
fn method() {}
|
||||
}
|
||||
|
||||
fn test<T: Trait<method(): Send>>() {}
|
||||
//~^ ERROR return type notation used on function that is not `async` and does not return `impl Trait`
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,22 @@
|
|||
warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/non-rpitit.rs:1:12
|
||||
|
|
||||
LL | #![feature(return_type_notation)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error: return type notation used on function that is not `async` and does not return `impl Trait`
|
||||
--> $DIR/non-rpitit.rs:8:18
|
||||
|
|
||||
LL | fn method() {}
|
||||
| ----------- this function must be `async` or return `impl Trait`
|
||||
...
|
||||
LL | fn test<T: Trait<method(): Send>>() {}
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: function returns `()`, which is not compatible with associated type return bounds
|
||||
|
||||
error: aborting due to previous error; 1 warning emitted
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue