@@ -13,6 +13,7 @@ use edition::Edition;
1313use parse:: { token, ParseSess } ;
1414use smallvec:: SmallVec ;
1515use errors:: Applicability ;
16+ use util:: move_map:: MoveMap ;
1617
1718use ptr:: P ;
1819
@@ -220,19 +221,19 @@ impl<'a> StripUnconfigured<'a> {
220221 pub fn configure_foreign_mod ( & mut self , foreign_mod : ast:: ForeignMod ) -> ast:: ForeignMod {
221222 ast:: ForeignMod {
222223 abi : foreign_mod. abi ,
223- items : foreign_mod. items . into_iter ( ) . filter_map ( |item| self . configure ( item) ) . collect ( ) ,
224+ items : foreign_mod. items . move_flat_map ( |item| self . configure ( item) ) ,
224225 }
225226 }
226227
227228 fn configure_variant_data ( & mut self , vdata : ast:: VariantData ) -> ast:: VariantData {
228229 match vdata {
229230 ast:: VariantData :: Struct ( fields, id) => {
230- let fields = fields. into_iter ( ) . filter_map ( |field| self . configure ( field) ) ;
231- ast:: VariantData :: Struct ( fields. collect ( ) , id)
231+ let fields = fields. move_flat_map ( |field| self . configure ( field) ) ;
232+ ast:: VariantData :: Struct ( fields, id)
232233 }
233234 ast:: VariantData :: Tuple ( fields, id) => {
234- let fields = fields. into_iter ( ) . filter_map ( |field| self . configure ( field) ) ;
235- ast:: VariantData :: Tuple ( fields. collect ( ) , id)
235+ let fields = fields. move_flat_map ( |field| self . configure ( field) ) ;
236+ ast:: VariantData :: Tuple ( fields, id)
236237 }
237238 ast:: VariantData :: Unit ( id) => ast:: VariantData :: Unit ( id)
238239 }
@@ -247,7 +248,7 @@ impl<'a> StripUnconfigured<'a> {
247248 ast:: ItemKind :: Union ( self . configure_variant_data ( def) , generics)
248249 }
249250 ast:: ItemKind :: Enum ( def, generics) => {
250- let variants = def. variants . into_iter ( ) . filter_map ( |v| {
251+ let variants = def. variants . move_flat_map ( |v| {
251252 self . configure ( v) . map ( |v| {
252253 Spanned {
253254 node : ast:: Variant_ {
@@ -260,9 +261,7 @@ impl<'a> StripUnconfigured<'a> {
260261 }
261262 } )
262263 } ) ;
263- ast:: ItemKind :: Enum ( ast:: EnumDef {
264- variants : variants. collect ( ) ,
265- } , generics)
264+ ast:: ItemKind :: Enum ( ast:: EnumDef { variants } , generics)
266265 }
267266 item => item,
268267 }
@@ -271,15 +270,11 @@ impl<'a> StripUnconfigured<'a> {
271270 pub fn configure_expr_kind ( & mut self , expr_kind : ast:: ExprKind ) -> ast:: ExprKind {
272271 match expr_kind {
273272 ast:: ExprKind :: Match ( m, arms) => {
274- let arms = arms. into_iter ( ) . filter_map ( |a| self . configure ( a) ) . collect ( ) ;
273+ let arms = arms. move_flat_map ( |a| self . configure ( a) ) ;
275274 ast:: ExprKind :: Match ( m, arms)
276275 }
277276 ast:: ExprKind :: Struct ( path, fields, base) => {
278- let fields = fields. into_iter ( )
279- . filter_map ( |field| {
280- self . configure ( field)
281- } )
282- . collect ( ) ;
277+ let fields = fields. move_flat_map ( |field| self . configure ( field) ) ;
283278 ast:: ExprKind :: Struct ( path, fields, base)
284279 }
285280 _ => expr_kind,
@@ -304,22 +299,10 @@ impl<'a> StripUnconfigured<'a> {
304299 self . process_cfg_attrs ( expr)
305300 }
306301
307- pub fn configure_stmt ( & mut self , stmt : ast:: Stmt ) -> Option < ast:: Stmt > {
308- self . configure ( stmt)
309- }
310-
311- pub fn configure_struct_expr_field ( & mut self , field : ast:: Field ) -> Option < ast:: Field > {
312- self . configure ( field)
313- }
314-
315302 pub fn configure_pat ( & mut self , pattern : P < ast:: Pat > ) -> P < ast:: Pat > {
316303 pattern. map ( |mut pattern| {
317304 if let ast:: PatKind :: Struct ( path, fields, etc) = pattern. node {
318- let fields = fields. into_iter ( )
319- . filter_map ( |field| {
320- self . configure ( field)
321- } )
322- . collect ( ) ;
305+ let fields = fields. move_flat_map ( |field| self . configure ( field) ) ;
323306 pattern. node = ast:: PatKind :: Struct ( path, fields, etc) ;
324307 }
325308 pattern
@@ -367,10 +350,7 @@ impl<'a> fold::Folder for StripUnconfigured<'a> {
367350 }
368351
369352 fn fold_stmt ( & mut self , stmt : ast:: Stmt ) -> SmallVec < [ ast:: Stmt ; 1 ] > {
370- match self . configure_stmt ( stmt) {
371- Some ( stmt) => fold:: noop_fold_stmt ( stmt, self ) ,
372- None => return SmallVec :: new ( ) ,
373- }
353+ fold:: noop_fold_stmt ( configure ! ( self , stmt) , self )
374354 }
375355
376356 fn fold_item ( & mut self , item : P < ast:: Item > ) -> SmallVec < [ P < ast:: Item > ; 1 ] > {
0 commit comments