mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Migrate trait_fn_async
This commit is contained in:
parent
88afae5d1a
commit
e3d4c4039a
@ -287,16 +287,7 @@ impl<'a> AstValidator<'a> {
|
|||||||
|
|
||||||
fn check_trait_fn_not_async(&self, fn_span: Span, asyncness: Async) {
|
fn check_trait_fn_not_async(&self, fn_span: Span, asyncness: Async) {
|
||||||
if let Async::Yes { span, .. } = asyncness {
|
if let Async::Yes { span, .. } = asyncness {
|
||||||
struct_span_err!(
|
self.session.emit_err(TraitFnAsync { fn_span, span });
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,3 +71,14 @@ pub enum InvalidVisibilityNote {
|
|||||||
#[note(ast_passes::individual_foreign_items)]
|
#[note(ast_passes::individual_foreign_items)]
|
||||||
IndividualForeignItems,
|
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,
|
||||||
|
}
|
||||||
|
@ -21,3 +21,9 @@ ast_passes_invalid_visibility =
|
|||||||
.implied = `pub` not permitted here because it's implied
|
.implied = `pub` not permitted here because it's implied
|
||||||
.individual_impl_items = place qualifiers on individual impl items instead
|
.individual_impl_items = place qualifiers on individual impl items instead
|
||||||
.individual_foreign_items = place qualifiers on individual foreign 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
|
||||||
|
Loading…
Reference in New Issue
Block a user