Skip to content

Commit a767877

Browse files
committed
Reword help and add test
1 parent aae7630 commit a767877

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

src/librustc_passes/ast_validation.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,10 @@ impl<'a> AstValidator<'a> {
173173

174174
fn check_trait_fn_not_async(&self, span: Span, asyncness: IsAsync) {
175175
if asyncness.is_async() {
176-
struct_span_err!(self.session, span, E0706,
177-
"trait fns cannot be declared `async`")
178-
.note("Due to technical restrictions rust does not currently support `async` \
179-
trait fns.")
180-
.note("Consider using the `async-trait` crate in the meantime until further \
181-
notice.")
176+
struct_span_err!(self.session, span, E0706, "trait fns cannot be declared `async`")
177+
.note("`async` trait functions are not currently supported")
178+
.note("consider using the `async-trait` crate: \
179+
https://crates.io/crates/async-trait")
182180
.emit();
183181
}
184182
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// edition:2018
2+
trait T {
3+
async fn foo() {} //~ ERROR trait fns cannot be declared `async`
4+
async fn bar(&self) {} //~ ERROR trait fns cannot be declared `async`
5+
}
6+
7+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error[E0706]: trait fns cannot be declared `async`
2+
--> $DIR/async-trait-fn.rs:3:5
3+
|
4+
LL | async fn foo() {}
5+
| ^^^^^^^^^^^^^^^^^
6+
|
7+
= note: `async` trait functions are not currently supported
8+
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
9+
10+
error[E0706]: trait fns cannot be declared `async`
11+
--> $DIR/async-trait-fn.rs:4:5
12+
|
13+
LL | async fn bar(&self) {}
14+
| ^^^^^^^^^^^^^^^^^^^^^^
15+
|
16+
= note: `async` trait functions are not currently supported
17+
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
18+
19+
error: aborting due to 2 previous errors
20+

src/test/ui/async-await/edition-deny-async-fns-2015.stderr

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ error[E0706]: trait fns cannot be declared `async`
5757
|
5858
LL | async fn foo() {}
5959
| ^^^^^^^^^^^^^^^^^
60+
|
61+
= note: `async` trait functions are not currently supported
62+
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
6063

6164
error: aborting due to 10 previous errors
6265

0 commit comments

Comments
 (0)