@@ -786,14 +786,17 @@ impl<'a> ReplaceBodyWithLoop<'a> {
786
786
false
787
787
}
788
788
}
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
+ }
789
793
}
790
794
791
795
impl < ' a > MutVisitor for ReplaceBodyWithLoop < ' a > {
792
796
fn visit_item_kind ( & mut self , i : & mut ast:: ItemKind ) {
793
797
let is_const = match i {
794
798
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) ,
797
800
_ => false ,
798
801
} ;
799
802
self . run ( is_const, |s| noop_visit_item_kind ( i, s) )
@@ -802,8 +805,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
802
805
fn flat_map_trait_item ( & mut self , i : ast:: TraitItem ) -> SmallVec < [ ast:: TraitItem ; 1 ] > {
803
806
let is_const = match i. kind {
804
807
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) ,
807
809
_ => false ,
808
810
} ;
809
811
self . run ( is_const, |s| noop_flat_map_trait_item ( i, s) )
@@ -812,8 +814,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
812
814
fn flat_map_impl_item ( & mut self , i : ast:: ImplItem ) -> SmallVec < [ ast:: ImplItem ; 1 ] > {
813
815
let is_const = match i. kind {
814
816
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) ,
817
818
_ => false ,
818
819
} ;
819
820
self . run ( is_const, |s| noop_flat_map_impl_item ( i, s) )
0 commit comments