@@ -252,14 +252,12 @@ impl ::std::str::FromStr for WidthHeuristics {
252
252
253
253
/// A set of directories, files and modules that rustfmt should ignore.
254
254
#[ derive( Default , Deserialize , Serialize , Clone , Debug ) ]
255
- pub struct IgnoreList {
256
- directories : Option < HashSet < PathBuf > > ,
257
- files : Option < HashSet < PathBuf > > ,
258
- }
255
+ pub struct IgnoreList ( HashSet < PathBuf > ) ;
259
256
260
257
impl IgnoreList {
261
- fn add_prefix_inner ( set : & HashSet < PathBuf > , dir : & Path ) -> HashSet < PathBuf > {
262
- set. iter ( )
258
+ pub fn add_prefix ( & mut self , dir : & Path ) {
259
+ self . 0 = self . 0
260
+ . iter ( )
263
261
. map ( |s| {
264
262
if s. has_root ( ) {
265
263
s. clone ( )
@@ -269,29 +267,13 @@ impl IgnoreList {
269
267
path
270
268
}
271
269
} )
272
- . collect ( )
273
- }
274
-
275
- pub fn add_prefix( & mut self , dir : & Path ) {
276
- macro add_prefix_inner_with ( $( $field: ident) , * $( , ) * ) {
277
- $( if let Some ( set) = self . $field. as_mut ( ) {
278
- * set = IgnoreList :: add_prefix_inner ( set, dir) ;
279
- } ) *
280
- }
281
-
282
- add_prefix_inner_with ! ( directories, files) ;
270
+ . collect ( ) ;
283
271
}
284
272
285
- fn is_ignore_file ( & self , path : & Path ) -> bool {
286
- self . files . as_ref ( ) . map_or ( false , |set| set. contains ( path) )
287
- }
288
-
289
- fn is_under_ignore_dir ( & self , path : & Path ) -> bool {
290
- if let Some ( ref dirs) = self . directories {
291
- for dir in dirs {
292
- if path. starts_with ( dir) {
293
- return true ;
294
- }
273
+ fn skip_file_inner ( & self , file : & Path ) -> bool {
274
+ for path in & self . 0 {
275
+ if file. starts_with ( path) {
276
+ return true ;
295
277
}
296
278
}
297
279
@@ -300,7 +282,7 @@ impl IgnoreList {
300
282
301
283
pub fn skip_file ( & self , file : & FileName ) -> bool {
302
284
if let FileName :: Real ( ref path) = file {
303
- self . is_ignore_file ( path ) || self . is_under_ignore_dir ( path)
285
+ self . skip_file_inner ( path)
304
286
} else {
305
287
false
306
288
}
0 commit comments