@@ -786,14 +786,17 @@ impl<'a> ReplaceBodyWithLoop<'a> {
786786 false
787787 }
788788 }
789+
790+ fn is_sig_const ( sig : & ast:: FnSig ) -> bool {
791+ sig. header . constness . node == ast:: Constness :: Const || Self :: should_ignore_fn ( & sig. decl )
792+ }
789793}
790794
791795impl < ' a > MutVisitor for ReplaceBodyWithLoop < ' a > {
792796 fn visit_item_kind ( & mut self , i : & mut ast:: ItemKind ) {
793797 let is_const = match i {
794798 ast:: ItemKind :: Static ( ..) | ast:: ItemKind :: Const ( ..) => true ,
795- ast:: ItemKind :: Fn ( ref decl, ref header, _, _) =>
796- header. constness . node == ast:: Constness :: Const || Self :: should_ignore_fn ( decl) ,
799+ ast:: ItemKind :: Fn ( ref sig, _, _) => Self :: is_sig_const ( sig) ,
797800 _ => false ,
798801 } ;
799802 self . run ( is_const, |s| noop_visit_item_kind ( i, s) )
@@ -802,8 +805,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
802805 fn flat_map_trait_item ( & mut self , i : ast:: TraitItem ) -> SmallVec < [ ast:: TraitItem ; 1 ] > {
803806 let is_const = match i. kind {
804807 ast:: TraitItemKind :: Const ( ..) => true ,
805- ast:: TraitItemKind :: Method ( ast:: FnSig { ref decl, ref header, .. } , _) =>
806- header. constness . node == ast:: Constness :: Const || Self :: should_ignore_fn ( decl) ,
808+ ast:: TraitItemKind :: Method ( ref sig, _) => Self :: is_sig_const ( sig) ,
807809 _ => false ,
808810 } ;
809811 self . run ( is_const, |s| noop_flat_map_trait_item ( i, s) )
@@ -812,8 +814,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
812814 fn flat_map_impl_item ( & mut self , i : ast:: ImplItem ) -> SmallVec < [ ast:: ImplItem ; 1 ] > {
813815 let is_const = match i. kind {
814816 ast:: ImplItemKind :: Const ( ..) => true ,
815- ast:: ImplItemKind :: Method ( ast:: FnSig { ref decl, ref header, .. } , _) =>
816- header. constness . node == ast:: Constness :: Const || Self :: should_ignore_fn ( decl) ,
817+ ast:: ImplItemKind :: Method ( ref sig, _) => Self :: is_sig_const ( sig) ,
817818 _ => false ,
818819 } ;
819820 self . run ( is_const, |s| noop_flat_map_impl_item ( i, s) )
0 commit comments