@@ -463,7 +463,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
463
463
self . invalid_visibility ( & impl_item. vis , None ) ;
464
464
if let ImplItemKind :: Method ( ref sig, _) = impl_item. node {
465
465
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 ) ;
467
467
}
468
468
}
469
469
}
@@ -482,9 +482,10 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
482
482
. note ( "only trait implementations may be annotated with default" ) . emit ( ) ;
483
483
}
484
484
}
485
- ItemKind :: Fn ( _, header, ref generics, _) => {
485
+ ItemKind :: Fn ( _, ref header, ref generics, _) => {
486
486
// We currently do not permit const generics in `const fn`, as
487
487
// this is tantamount to allowing compile-time dependent typing.
488
+ self . visit_fn_header ( header) ;
488
489
if header. constness . node == Constness :: Const {
489
490
// Look for const generics and error if we find any.
490
491
for param in & generics. params {
@@ -535,7 +536,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
535
536
self . no_questions_in_bounds ( bounds, "supertraits" , true ) ;
536
537
for trait_item in trait_items {
537
538
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 ) ;
539
540
self . check_trait_fn_not_const ( sig. header . constness ) ;
540
541
if block. is_none ( ) {
541
542
self . check_decl_no_pat ( & sig. decl , |span, mut_ident| {
@@ -702,6 +703,13 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
702
703
. span_bug ( mac. span , "macro invocation missed in expansion; did you forget to override \
703
704
the relevant `fold_*()` method in `PlaceholderExpander`?") ;
704
705
}
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
+ }
705
713
}
706
714
707
715
pub fn check_crate ( session : & Session , krate : & Crate ) -> ( bool , bool ) {
0 commit comments