@@ -6,13 +6,13 @@ use crate::maybe_whole;
66
77use rustc_ast_pretty:: pprust;
88use rustc_errors:: { struct_span_err, Applicability , DiagnosticBuilder , PResult , StashKey } ;
9- use rustc_span:: source_map:: { self , respan , Span } ;
9+ use rustc_span:: source_map:: { self , Span } ;
1010use rustc_span:: symbol:: { kw, sym, Symbol } ;
1111use rustc_span:: BytePos ;
1212use syntax:: ast:: { self , AttrKind , AttrStyle , AttrVec , Attribute , Ident , DUMMY_NODE_ID } ;
1313use syntax:: ast:: { AssocItem , AssocItemKind , Item , ItemKind , UseTree , UseTreeKind } ;
14+ use syntax:: ast:: { Async , Const , Defaultness , Extern , IsAuto , PathSegment , StrLit , Unsafe } ;
1415use syntax:: ast:: { BindingMode , Block , FnDecl , FnSig , Mac , MacArgs , MacDelimiter , Param , SelfKind } ;
15- use syntax:: ast:: { Const , Defaultness , Extern , IsAsync , IsAuto , PathSegment , StrLit , Unsafe } ;
1616use syntax:: ast:: { EnumDef , Generics , StructField , TraitRef , Ty , TyKind , Variant , VariantData } ;
1717use syntax:: ast:: { FnHeader , ForeignItem , ForeignItemKind , Mutability , Visibility , VisibilityKind } ;
1818use syntax:: ptr:: P ;
@@ -105,10 +105,9 @@ impl<'a> Parser<'a> {
105105
106106 if self . eat_keyword ( kw:: Fn ) {
107107 // EXTERN FUNCTION ITEM
108- let fn_span = self . prev_span ;
109108 let header = FnHeader {
110109 unsafety : Unsafe :: No ,
111- asyncness : respan ( fn_span , IsAsync :: NotAsync ) ,
110+ asyncness : Async :: No ,
112111 constness : Const :: No ,
113112 ext : Extern :: from_abi ( abi) ,
114113 } ;
@@ -140,12 +139,7 @@ impl<'a> Parser<'a> {
140139 let ext = self . parse_extern ( ) ?;
141140 self . expect_keyword ( kw:: Fn ) ?;
142141
143- let header = FnHeader {
144- unsafety,
145- asyncness : respan ( const_span, IsAsync :: NotAsync ) ,
146- constness,
147- ext,
148- } ;
142+ let header = FnHeader { unsafety, asyncness : Async :: No , constness, ext } ;
149143 return self . parse_item_fn ( lo, vis, attrs, header) ;
150144 }
151145
@@ -172,16 +166,9 @@ impl<'a> Parser<'a> {
172166 let async_span = self . token . span ;
173167 if self . is_keyword_ahead ( 1 , & [ kw:: Fn ] ) || self . is_keyword_ahead ( 2 , & [ kw:: Fn ] ) {
174168 // ASYNC FUNCTION ITEM
175- self . bump ( ) ; // `async`
169+ let asyncness = self . parse_asyncness ( ) ; // `async`
176170 let unsafety = self . parse_unsafety ( ) ; // `unsafe`?
177171 self . expect_keyword ( kw:: Fn ) ?; // `fn`
178- let asyncness = respan (
179- async_span,
180- IsAsync :: Async {
181- closure_id : DUMMY_NODE_ID ,
182- return_impl_trait_id : DUMMY_NODE_ID ,
183- } ,
184- ) ;
185172 self . ban_async_in_2015 ( async_span) ;
186173 let header =
187174 FnHeader { unsafety, asyncness, constness : Const :: No , ext : Extern :: None } ;
@@ -211,13 +198,7 @@ impl<'a> Parser<'a> {
211198 if self . check_keyword ( kw:: Fn ) {
212199 // FUNCTION ITEM
213200 self . bump ( ) ;
214- let fn_span = self . prev_span ;
215- let header = FnHeader {
216- unsafety : Unsafe :: No ,
217- asyncness : respan ( fn_span, IsAsync :: NotAsync ) ,
218- constness : Const :: No ,
219- ext : Extern :: None ,
220- } ;
201+ let header = FnHeader :: default ( ) ;
221202 return self . parse_item_fn ( lo, vis, attrs, header) ;
222203 }
223204
@@ -230,13 +211,7 @@ impl<'a> Parser<'a> {
230211 self . check ( & token:: OpenDelim ( token:: Brace ) ) ;
231212 let ext = self . parse_extern ( ) ?;
232213 self . expect_keyword ( kw:: Fn ) ?;
233- let fn_span = self . prev_span ;
234- let header = FnHeader {
235- unsafety,
236- asyncness : respan ( fn_span, IsAsync :: NotAsync ) ,
237- constness : Const :: No ,
238- ext,
239- } ;
214+ let header = FnHeader { unsafety, asyncness : Async :: No , constness : Const :: No , ext } ;
240215 return self . parse_item_fn ( lo, vis, attrs, header) ;
241216 }
242217
@@ -1788,10 +1763,9 @@ impl<'a> Parser<'a> {
17881763 fn parse_fn_front_matter ( & mut self ) -> PResult < ' a , FnHeader > {
17891764 let constness = self . parse_constness ( ) ;
17901765 let asyncness = self . parse_asyncness ( ) ;
1791- if let IsAsync :: Async { .. } = asyncness {
1792- self . ban_async_in_2015 ( self . prev_span ) ;
1766+ if let Async :: Yes { span , .. } = asyncness {
1767+ self . ban_async_in_2015 ( span ) ;
17931768 }
1794- let asyncness = respan ( self . prev_span , asyncness) ;
17951769 let unsafety = self . parse_unsafety ( ) ;
17961770 let ( constness, unsafety, ext) = if let Const :: Yes ( _) = constness {
17971771 ( constness, unsafety, Extern :: None )
0 commit comments