@@ -608,26 +608,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
608
608
}
609
609
}
610
610
self . no_questions_in_bounds ( bounds, "supertraits" , true ) ;
611
- for trait_item in trait_items {
612
- if let TraitItemKind :: Method ( ref sig, ref block) = trait_item. kind {
613
- self . check_fn_decl ( & sig. decl ) ;
614
- self . check_trait_fn_not_async ( trait_item. span , sig. header . asyncness . node ) ;
615
- self . check_trait_fn_not_const ( sig. header . constness ) ;
616
- if block. is_none ( ) {
617
- Self :: check_decl_no_pat ( & sig. decl , |span, mut_ident| {
618
- if mut_ident {
619
- self . lint_buffer . buffer_lint (
620
- lint:: builtin:: PATTERNS_IN_FNS_WITHOUT_BODY ,
621
- trait_item. id , span,
622
- "patterns aren't allowed in methods without bodies" ) ;
623
- } else {
624
- struct_span_err ! ( self . session, span, E0642 ,
625
- "patterns aren't allowed in methods without bodies" ) . emit ( ) ;
626
- }
627
- } ) ;
628
- }
629
- }
630
- }
631
611
}
632
612
ItemKind :: Mod ( _) => {
633
613
// Ensure that `path` attributes on modules are recorded as used (cf. issue #35584).
@@ -812,6 +792,29 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
812
792
fn visit_trait_item ( & mut self , ti : & ' a AssocItem ) {
813
793
self . invalid_visibility ( & ti. vis , None ) ;
814
794
self . check_defaultness ( ti. span , ti. defaultness ) ;
795
+
796
+ if let AssocItemKind :: Method ( sig, block) = & ti. kind {
797
+ self . check_fn_decl ( & sig. decl ) ;
798
+ self . check_trait_fn_not_async ( ti. span , sig. header . asyncness . node ) ;
799
+ self . check_trait_fn_not_const ( sig. header . constness ) ;
800
+ if block. is_none ( ) {
801
+ Self :: check_decl_no_pat ( & sig. decl , |span, mut_ident| {
802
+ if mut_ident {
803
+ self . lint_buffer . buffer_lint (
804
+ lint:: builtin:: PATTERNS_IN_FNS_WITHOUT_BODY ,
805
+ ti. id , span,
806
+ "patterns aren't allowed in methods without bodies"
807
+ ) ;
808
+ } else {
809
+ struct_span_err ! (
810
+ self . session, span, E0642 ,
811
+ "patterns aren't allowed in methods without bodies"
812
+ ) . emit ( ) ;
813
+ }
814
+ } ) ;
815
+ }
816
+ }
817
+
815
818
visit:: walk_trait_item ( self , ti) ;
816
819
}
817
820
0 commit comments