@@ -16,7 +16,10 @@ use rustc_ast::{EnumDef, FieldDef, Generics, TraitRef, Ty, TyKind, Variant, Vari
1616use rustc_ast:: { FnHeader , ForeignItem , Path , PathSegment , Visibility , VisibilityKind } ;
1717use rustc_ast:: { MacCall , MacDelimiter } ;
1818use 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+ } ;
2023use rustc_span:: edition:: Edition ;
2124use rustc_span:: lev_distance:: lev_distance;
2225use rustc_span:: source_map:: { self , Span } ;
@@ -2445,10 +2448,12 @@ impl<'a> Parser<'a> {
24452448 fn ban_async_in_2015 ( & self , span : Span ) {
24462449 if span. rust_2015 ( ) {
24472450 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 ( ) ;
24522457 }
24532458 }
24542459
0 commit comments