mirror of
https://github.com/rust-lang/rust
synced 2024-10-01 22:34:35 +00:00
Reword help and add test
This commit is contained in:
parent
aae76304f9
commit
a7678779a1
|
@ -173,12 +173,10 @@ fn check_decl_no_pat<F: FnMut(Span, bool)>(decl: &FnDecl, mut report_err: F) {
|
|||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
7
src/test/ui/async-await/async-trait-fn.rs
Normal file
7
src/test/ui/async-await/async-trait-fn.rs
Normal file
|
@ -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
src/test/ui/async-await/async-trait-fn.stderr
Normal file
20
src/test/ui/async-await/async-trait-fn.stderr
Normal file
|
@ -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
|
||||
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue