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> {
287
287
288
288
fn check_trait_fn_not_async ( & self , fn_span : Span , asyncness : Async ) {
289
289
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 } ) ;
300
291
}
301
292
}
302
293
Original file line number Diff line number Diff line change @@ -71,3 +71,14 @@ pub enum InvalidVisibilityNote {
71
71
#[ note( ast_passes:: individual_foreign_items) ]
72
72
IndividualForeignItems ,
73
73
}
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 =
21
21
.implied = `pub` not permitted here because it's implied
22
22
.individual_impl_items = place qualifiers on individual impl items instead
23
23
.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