@@ -463,7 +463,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
463463 self . invalid_visibility ( & impl_item. vis , None ) ;
464464 if let ImplItemKind :: Method ( ref sig, _) = impl_item. node {
465465 self . check_trait_fn_not_const ( sig. header . constness ) ;
466- self . check_trait_fn_not_async ( impl_item. span , sig. header . asyncness ) ;
466+ self . check_trait_fn_not_async ( impl_item. span , sig. header . asyncness . node ) ;
467467 }
468468 }
469469 }
@@ -482,9 +482,10 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
482482 . note ( "only trait implementations may be annotated with default" ) . emit ( ) ;
483483 }
484484 }
485- ItemKind :: Fn ( _, header, ref generics, _) => {
485+ ItemKind :: Fn ( _, ref header, ref generics, _) => {
486486 // We currently do not permit const generics in `const fn`, as
487487 // this is tantamount to allowing compile-time dependent typing.
488+ self . visit_fn_header ( header) ;
488489 if header. constness . node == Constness :: Const {
489490 // Look for const generics and error if we find any.
490491 for param in & generics. params {
@@ -535,7 +536,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
535536 self . no_questions_in_bounds ( bounds, "supertraits" , true ) ;
536537 for trait_item in trait_items {
537538 if let TraitItemKind :: Method ( ref sig, ref block) = trait_item. node {
538- self . check_trait_fn_not_async ( trait_item. span , sig. header . asyncness ) ;
539+ self . check_trait_fn_not_async ( trait_item. span , sig. header . asyncness . node ) ;
539540 self . check_trait_fn_not_const ( sig. header . constness ) ;
540541 if block. is_none ( ) {
541542 self . check_decl_no_pat ( & sig. decl , |span, mut_ident| {
@@ -702,6 +703,13 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
702703 . span_bug ( mac. span , "macro invocation missed in expansion; did you forget to override \
703704 the relevant `fold_*()` method in `PlaceholderExpander`?") ;
704705 }
706+
707+ fn visit_fn_header ( & mut self , header : & ' a FnHeader ) {
708+ if header. asyncness . node . is_async ( ) && self . session . rust_2015 ( ) {
709+ struct_span_err ! ( self . session, header. asyncness. span, E0670 ,
710+ "`async fn` is not permitted in the 2015 edition" ) . emit ( ) ;
711+ }
712+ }
705713}
706714
707715pub fn check_crate ( session : & Session , krate : & Crate ) -> ( bool , bool ) {
0 commit comments