File tree Expand file tree Collapse file tree 3 files changed +18
-10
lines changed
rustc_error_messages/locales/en-US Expand file tree Collapse file tree 3 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -287,16 +287,7 @@ impl<'a> AstValidator<'a> {
287287
288288 fn check_trait_fn_not_async ( & self , fn_span : Span , asyncness : Async ) {
289289 if let Async :: Yes { span, .. } = asyncness {
290- struct_span_err ! (
291- self . session,
292- fn_span,
293- E0706 ,
294- "functions in traits cannot be declared `async`"
295- )
296- . span_label ( span, "`async` because of this" )
297- . note ( "`async` trait functions are not currently supported" )
298- . note ( "consider using the `async-trait` crate: https://crates.io/crates/async-trait" )
299- . emit ( ) ;
290+ self . session . emit_err ( TraitFnAsync { fn_span, span } ) ;
300291 }
301292 }
302293
Original file line number Diff line number Diff line change @@ -71,3 +71,14 @@ pub enum InvalidVisibilityNote {
7171 #[ note( ast_passes:: individual_foreign_items) ]
7272 IndividualForeignItems ,
7373}
74+
75+ #[ derive( SessionDiagnostic ) ]
76+ #[ error( ast_passes:: trait_fn_async, code = "E0706" ) ]
77+ #[ note]
78+ #[ note( ast_passes:: note2) ]
79+ pub struct TraitFnAsync {
80+ #[ primary_span]
81+ pub fn_span : Span ,
82+ #[ label]
83+ pub span : Span ,
84+ }
Original file line number Diff line number Diff line change @@ -21,3 +21,9 @@ ast_passes_invalid_visibility =
2121 .implied = `pub` not permitted here because it's implied
2222 .individual_impl_items = place qualifiers on individual impl items instead
2323 .individual_foreign_items = place qualifiers on individual foreign items instead
24+
25+ ast_passes_trait_fn_async =
26+ functions in traits cannot be declared `async`
27+ .label = `async` because of this
28+ .note = `async` trait functions are not currently supported
29+ .note2 = consider using the `async-trait` crate: https://crates.io/crates/async-trait
You can’t perform that action at this time.
0 commit comments