@@ -16,7 +16,10 @@ use rustc_ast::{EnumDef, FieldDef, Generics, TraitRef, Ty, TyKind, Variant, Vari
16
16
use rustc_ast:: { FnHeader , ForeignItem , Path , PathSegment , Visibility , VisibilityKind } ;
17
17
use rustc_ast:: { MacCall , MacDelimiter } ;
18
18
use rustc_ast_pretty:: pprust;
19
- use rustc_errors:: { struct_span_err, Applicability , IntoDiagnostic , PResult , StashKey } ;
19
+ use rustc_errors:: {
20
+ struct_span_err, AddToDiagnostic , Applicability , HelpUseLatestEdition , IntoDiagnostic , PResult ,
21
+ StashKey ,
22
+ } ;
20
23
use rustc_span:: edition:: Edition ;
21
24
use rustc_span:: lev_distance:: lev_distance;
22
25
use rustc_span:: source_map:: { self , Span } ;
@@ -2445,10 +2448,12 @@ impl<'a> Parser<'a> {
2445
2448
fn ban_async_in_2015 ( & self , span : Span ) {
2446
2449
if span. rust_2015 ( ) {
2447
2450
let diag = self . diagnostic ( ) ;
2448
- struct_span_err ! ( diag, span, E0670 , "`async fn` is not permitted in Rust 2015" )
2449
- . span_label ( span, "to use `async fn`, switch to Rust 2018 or later" )
2450
- . help_use_latest_edition ( )
2451
- . emit ( ) ;
2451
+
2452
+ let mut e =
2453
+ struct_span_err ! ( diag, span, E0670 , "`async fn` is not permitted in Rust 2015" ) ;
2454
+ e. span_label ( span, "to use `async fn`, switch to Rust 2018 or later" ) ;
2455
+ HelpUseLatestEdition :: new ( ) . add_to_diagnostic ( & mut e) ;
2456
+ e. emit ( ) ;
2452
2457
}
2453
2458
}
2454
2459
0 commit comments