Skip to content

Commit

Permalink
Reword help and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Nov 18, 2019
1 parent aae7630 commit a767877
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/librustc_passes/ast_validation.rs
Expand Up @@ -173,12 +173,10 @@ impl<'a> AstValidator<'a> {

fn check_trait_fn_not_async(&self, span: Span, asyncness: IsAsync) {
if asyncness.is_async() {
struct_span_err!(self.session, span, E0706,
"trait fns cannot be declared `async`")
.note("Due to technical restrictions rust does not currently support `async` \
trait fns.")
.note("Consider using the `async-trait` crate in the meantime until further \
notice.")
struct_span_err!(self.session, span, E0706, "trait fns cannot be declared `async`")
.note("`async` trait functions are not currently supported")
.note("consider using the `async-trait` crate: \
https://crates.io/crates/async-trait")
.emit();
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/test/ui/async-await/async-trait-fn.rs
@@ -0,0 +1,7 @@
// edition:2018
trait T {
async fn foo() {} //~ ERROR trait fns cannot be declared `async`
async fn bar(&self) {} //~ ERROR trait fns cannot be declared `async`
}

fn main() {}
20 changes: 20 additions & 0 deletions src/test/ui/async-await/async-trait-fn.stderr
@@ -0,0 +1,20 @@
error[E0706]: trait fns cannot be declared `async`
--> $DIR/async-trait-fn.rs:3:5
|
LL | async fn foo() {}
| ^^^^^^^^^^^^^^^^^
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait

error[E0706]: trait fns cannot be declared `async`
--> $DIR/async-trait-fn.rs:4:5
|
LL | async fn bar(&self) {}
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait

error: aborting due to 2 previous errors

3 changes: 3 additions & 0 deletions src/test/ui/async-await/edition-deny-async-fns-2015.stderr
Expand Up @@ -57,6 +57,9 @@ error[E0706]: trait fns cannot be declared `async`
|
LL | async fn foo() {}
| ^^^^^^^^^^^^^^^^^
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait

error: aborting due to 10 previous errors

Expand Down

0 comments on commit a767877

Please sign in to comment.