Skip to content

Commit a18741a

Browse files
committed
split async-trait-fn test into working and not-yet working parts
1 parent 4a14677 commit a18741a

File tree

4 files changed

+126
-94
lines changed

4 files changed

+126
-94
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// edition:2018
2+
3+
// FIXME: enable the async_fn_in_trait feature in this test after 101665 is fixed and we can
4+
// actually test these.
5+
6+
trait T {
7+
async fn foo() {} //~ ERROR functions in traits cannot be declared `async`
8+
//~^ ERROR mismatched types
9+
async fn bar(&self) {} //~ ERROR functions in traits cannot be declared `async`
10+
//~^ ERROR mismatched types
11+
async fn baz() { //~ ERROR functions in traits cannot be declared `async`
12+
//~^ ERROR mismatched types
13+
// Nested item must not ICE.
14+
fn a() {}
15+
}
16+
}
17+
18+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
error[E0706]: functions in traits cannot be declared `async`
2+
--> $DIR/async-trait-fn-with-default-body.rs:7:5
3+
|
4+
LL | async fn foo() {}
5+
| -----^^^^^^^^^
6+
| |
7+
| `async` because of this
8+
|
9+
= note: `async` trait functions are not currently supported
10+
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
11+
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
12+
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
13+
14+
error[E0706]: functions in traits cannot be declared `async`
15+
--> $DIR/async-trait-fn-with-default-body.rs:9:5
16+
|
17+
LL | async fn bar(&self) {}
18+
| -----^^^^^^^^^^^^^^
19+
| |
20+
| `async` because of this
21+
|
22+
= note: `async` trait functions are not currently supported
23+
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
24+
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
25+
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
26+
27+
error[E0706]: functions in traits cannot be declared `async`
28+
--> $DIR/async-trait-fn-with-default-body.rs:11:5
29+
|
30+
LL | async fn baz() {
31+
| -----^^^^^^^^^
32+
| |
33+
| `async` because of this
34+
|
35+
= note: `async` trait functions are not currently supported
36+
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
37+
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
38+
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
39+
40+
error[E0308]: mismatched types
41+
--> $DIR/async-trait-fn-with-default-body.rs:7:20
42+
|
43+
LL | async fn foo() {}
44+
| ^^ expected associated type, found opaque type
45+
|
46+
::: $SRC_DIR/core/src/future/mod.rs:LL:COL
47+
|
48+
LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
49+
| ------------------------------- the found opaque type
50+
|
51+
= note: expected associated type `impl Future<Output = ()>` (trait associated opaque type at <$DIR/async-trait-fn-with-default-body.rs:7:20>)
52+
found opaque type `impl Future<Output = ()>` (opaque type at <$SRC_DIR/core/src/future/mod.rs:LL:COL>)
53+
54+
error[E0308]: mismatched types
55+
--> $DIR/async-trait-fn-with-default-body.rs:9:25
56+
|
57+
LL | async fn bar(&self) {}
58+
| ^^ expected associated type, found opaque type
59+
|
60+
::: $SRC_DIR/core/src/future/mod.rs:LL:COL
61+
|
62+
LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
63+
| ------------------------------- the found opaque type
64+
|
65+
= note: expected associated type `impl Future<Output = ()>` (trait associated opaque type at <$DIR/async-trait-fn-with-default-body.rs:9:25>)
66+
found opaque type `impl Future<Output = ()>` (opaque type at <$SRC_DIR/core/src/future/mod.rs:LL:COL>)
67+
68+
error[E0308]: mismatched types
69+
--> $DIR/async-trait-fn-with-default-body.rs:11:20
70+
|
71+
LL | async fn baz() {
72+
| ____________________^
73+
LL | |
74+
LL | | // Nested item must not ICE.
75+
LL | | fn a() {}
76+
LL | | }
77+
| |_____^ expected associated type, found opaque type
78+
|
79+
::: $SRC_DIR/core/src/future/mod.rs:LL:COL
80+
|
81+
LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
82+
| ------------------------------- the found opaque type
83+
|
84+
= note: expected associated type `impl Future<Output = ()>` (trait associated opaque type at <$DIR/async-trait-fn-with-default-body.rs:11:20>)
85+
found opaque type `impl Future<Output = ()>` (opaque type at <$SRC_DIR/core/src/future/mod.rs:LL:COL>)
86+
87+
error: aborting due to 6 previous errors
88+
89+
Some errors have detailed explanations: E0308, E0706.
90+
For more information about an error, try `rustc --explain E0308`.
+12-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
// edition:2018
2+
// check-pass
3+
4+
#![feature(async_fn_in_trait)] //~ WARN the feature `async_fn_in_trait` is incomplete
5+
26
trait T {
3-
async fn foo() {} //~ ERROR functions in traits cannot be declared `async`
4-
//~^ ERROR mismatched types
5-
async fn bar(&self) {} //~ ERROR functions in traits cannot be declared `async`
6-
//~^ ERROR mismatched types
7-
async fn baz() { //~ ERROR functions in traits cannot be declared `async`
8-
//~^ ERROR mismatched types
9-
// Nested item must not ICE.
10-
fn a() {}
11-
}
7+
async fn foo();
8+
// async fn bar(&self);
9+
}
10+
11+
struct Impl;
12+
13+
impl T for Impl {
14+
async fn foo() {}
1215
}
1316

1417
fn main() {}
+6-85
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,11 @@
1-
error[E0706]: functions in traits cannot be declared `async`
2-
--> $DIR/async-trait-fn.rs:3:5
1+
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/async-trait-fn.rs:4:12
33
|
4-
LL | async fn foo() {}
5-
| -----^^^^^^^^^
6-
| |
7-
| `async` because of this
4+
LL | #![feature(async_fn_in_trait)]
5+
| ^^^^^^^^^^^^^^^^^
86
|
9-
= note: `async` trait functions are not currently supported
10-
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
7+
= note: `#[warn(incomplete_features)]` on by default
118
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
12-
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
139

14-
error[E0706]: functions in traits cannot be declared `async`
15-
--> $DIR/async-trait-fn.rs:5:5
16-
|
17-
LL | async fn bar(&self) {}
18-
| -----^^^^^^^^^^^^^^
19-
| |
20-
| `async` because of this
21-
|
22-
= note: `async` trait functions are not currently supported
23-
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
24-
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
25-
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
26-
27-
error[E0706]: functions in traits cannot be declared `async`
28-
--> $DIR/async-trait-fn.rs:7:5
29-
|
30-
LL | async fn baz() {
31-
| -----^^^^^^^^^
32-
| |
33-
| `async` because of this
34-
|
35-
= note: `async` trait functions are not currently supported
36-
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
37-
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
38-
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
39-
40-
error[E0308]: mismatched types
41-
--> $DIR/async-trait-fn.rs:3:20
42-
|
43-
LL | async fn foo() {}
44-
| ^^ expected associated type, found opaque type
45-
|
46-
::: $SRC_DIR/core/src/future/mod.rs:LL:COL
47-
|
48-
LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
49-
| ------------------------------- the found opaque type
50-
|
51-
= note: expected associated type `impl Future<Output = ()>` (trait associated opaque type at <$DIR/async-trait-fn.rs:3:20>)
52-
found opaque type `impl Future<Output = ()>` (opaque type at <$SRC_DIR/core/src/future/mod.rs:LL:COL>)
53-
54-
error[E0308]: mismatched types
55-
--> $DIR/async-trait-fn.rs:5:25
56-
|
57-
LL | async fn bar(&self) {}
58-
| ^^ expected associated type, found opaque type
59-
|
60-
::: $SRC_DIR/core/src/future/mod.rs:LL:COL
61-
|
62-
LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
63-
| ------------------------------- the found opaque type
64-
|
65-
= note: expected associated type `impl Future<Output = ()>` (trait associated opaque type at <$DIR/async-trait-fn.rs:5:25>)
66-
found opaque type `impl Future<Output = ()>` (opaque type at <$SRC_DIR/core/src/future/mod.rs:LL:COL>)
67-
68-
error[E0308]: mismatched types
69-
--> $DIR/async-trait-fn.rs:7:20
70-
|
71-
LL | async fn baz() {
72-
| ____________________^
73-
LL | |
74-
LL | | // Nested item must not ICE.
75-
LL | | fn a() {}
76-
LL | | }
77-
| |_____^ expected associated type, found opaque type
78-
|
79-
::: $SRC_DIR/core/src/future/mod.rs:LL:COL
80-
|
81-
LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
82-
| ------------------------------- the found opaque type
83-
|
84-
= note: expected associated type `impl Future<Output = ()>` (trait associated opaque type at <$DIR/async-trait-fn.rs:7:20>)
85-
found opaque type `impl Future<Output = ()>` (opaque type at <$SRC_DIR/core/src/future/mod.rs:LL:COL>)
86-
87-
error: aborting due to 6 previous errors
10+
warning: 1 warning emitted
8811

89-
Some errors have detailed explanations: E0308, E0706.
90-
For more information about an error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)