@@ -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 } ;
@@ -2436,10 +2439,12 @@ impl<'a> Parser<'a> {
24362439 fn ban_async_in_2015 ( & self , span : Span ) {
24372440 if span. rust_2015 ( ) {
24382441 let diag = self . diagnostic ( ) ;
2439- struct_span_err ! ( diag, span, E0670 , "`async fn` is not permitted in Rust 2015" )
2440- . span_label ( span, "to use `async fn`, switch to Rust 2018 or later" )
2441- . help_use_latest_edition ( )
2442- . emit ( ) ;
2442+
2443+ let mut e =
2444+ struct_span_err ! ( diag, span, E0670 , "`async fn` is not permitted in Rust 2015" ) ;
2445+ e. span_label ( span, "to use `async fn`, switch to Rust 2018 or later" ) ;
2446+ HelpUseLatestEdition :: new ( ) . add_to_diagnostic ( & mut e) ;
2447+ e. emit ( ) ;
24432448 }
24442449 }
24452450
0 commit comments