@@ -150,7 +150,7 @@ impl<'cfg> PathSource<'cfg> {
150
150
}
151
151
} ;
152
152
153
- let mut filter = |path : & Path , is_dir : bool | {
153
+ let filter = |path : & Path , is_dir : bool | {
154
154
let relative_path = match path. strip_prefix ( root) {
155
155
Ok ( p) => p,
156
156
Err ( _) => return false ,
@@ -169,10 +169,10 @@ impl<'cfg> PathSource<'cfg> {
169
169
// Attempt Git-prepopulate only if no `include` (see rust-lang/cargo#4135).
170
170
if no_include_option {
171
171
if let Some ( repo) = git_repo {
172
- return self . list_files_git ( pkg, & repo, & mut filter) ;
172
+ return self . list_files_git ( pkg, & repo, & filter) ;
173
173
}
174
174
}
175
- self . list_files_walk ( pkg, & mut filter)
175
+ self . list_files_walk ( pkg, & filter)
176
176
}
177
177
178
178
/// Returns `Some(git2::Repository)` if found sibling `Cargo.toml` and `.git`
@@ -222,7 +222,7 @@ impl<'cfg> PathSource<'cfg> {
222
222
& self ,
223
223
pkg : & Package ,
224
224
repo : & git2:: Repository ,
225
- filter : & mut dyn FnMut ( & Path , bool ) -> bool ,
225
+ filter : & dyn Fn ( & Path , bool ) -> bool ,
226
226
) -> CargoResult < Vec < PathBuf > > {
227
227
warn ! ( "list_files_git {}" , pkg. package_id( ) ) ;
228
228
let index = repo. index ( ) ?;
@@ -376,7 +376,7 @@ impl<'cfg> PathSource<'cfg> {
376
376
fn list_files_walk (
377
377
& self ,
378
378
pkg : & Package ,
379
- filter : & mut dyn FnMut ( & Path , bool ) -> bool ,
379
+ filter : & dyn Fn ( & Path , bool ) -> bool ,
380
380
) -> CargoResult < Vec < PathBuf > > {
381
381
let mut ret = Vec :: new ( ) ;
382
382
self . walk ( pkg. root ( ) , & mut ret, true , filter) ?;
@@ -388,7 +388,7 @@ impl<'cfg> PathSource<'cfg> {
388
388
path : & Path ,
389
389
ret : & mut Vec < PathBuf > ,
390
390
is_root : bool ,
391
- filter : & mut dyn FnMut ( & Path , bool ) -> bool ,
391
+ filter : & dyn Fn ( & Path , bool ) -> bool ,
392
392
) -> CargoResult < ( ) > {
393
393
let walkdir = WalkDir :: new ( path)
394
394
. follow_links ( true )
@@ -432,7 +432,11 @@ impl<'cfg> PathSource<'cfg> {
432
432
self . config . shell ( ) . warn ( err) ?;
433
433
}
434
434
Err ( err) => match err. path ( ) {
435
- // If the error occurs with a path, simply recover from it.
435
+ // If an error occurs with a path, filter it again.
436
+ // If it is excluded, Just ignore it in this case.
437
+ // See issue rust-lang/cargo#10917
438
+ Some ( path) if !filter ( path, path. is_dir ( ) ) => { }
439
+ // Otherwise, simply recover from it.
436
440
// Don't worry about error skipping here, the callers would
437
441
// still hit the IO error if they do access it thereafter.
438
442
Some ( path) => ret. push ( path. to_path_buf ( ) ) ,
0 commit comments