Migrate trait_fn_async

This commit is contained in:
finalchild 2022-08-18 16:49:52 +09:00
parent 88afae5d1a
commit e3d4c4039a
3 changed files with 18 additions and 10 deletions

View File

@ -287,16 +287,7 @@ impl<'a> AstValidator<'a> {
fn check_trait_fn_not_async(&self, fn_span: Span, asyncness: Async) {
if let Async::Yes { span, .. } = asyncness {
struct_span_err!(
self.session,
fn_span,
E0706,
"functions in traits cannot be declared `async`"
)
.span_label(span, "`async` because of this")
.note("`async` trait functions are not currently supported")
.note("consider using the `async-trait` crate: https://crates.io/crates/async-trait")
.emit();
self.session.emit_err(TraitFnAsync { fn_span, span });
}
}

View File

@ -71,3 +71,14 @@ pub enum InvalidVisibilityNote {
#[note(ast_passes::individual_foreign_items)]
IndividualForeignItems,
}
#[derive(SessionDiagnostic)]
#[error(ast_passes::trait_fn_async, code = "E0706")]
#[note]
#[note(ast_passes::note2)]
pub struct TraitFnAsync {
#[primary_span]
pub fn_span: Span,
#[label]
pub span: Span,
}

View File

@ -21,3 +21,9 @@ ast_passes_invalid_visibility =
.implied = `pub` not permitted here because it's implied
.individual_impl_items = place qualifiers on individual impl items instead
.individual_foreign_items = place qualifiers on individual foreign items instead
ast_passes_trait_fn_async =
functions in traits cannot be declared `async`
.label = `async` because of this
.note = `async` trait functions are not currently supported
.note2 = consider using the `async-trait` crate: https://crates.io/crates/async-trait