@@ -150,7 +150,7 @@ impl<'cfg> PathSource<'cfg> {
150150 }
151151 } ;
152152
153- let mut filter = |path : & Path , is_dir : bool | {
153+ let filter = |path : & Path , is_dir : bool | {
154154 let relative_path = match path. strip_prefix ( root) {
155155 Ok ( p) => p,
156156 Err ( _) => return false ,
@@ -169,10 +169,10 @@ impl<'cfg> PathSource<'cfg> {
169169 // Attempt Git-prepopulate only if no `include` (see rust-lang/cargo#4135).
170170 if no_include_option {
171171 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) ;
173173 }
174174 }
175- self . list_files_walk ( pkg, & mut filter)
175+ self . list_files_walk ( pkg, & filter)
176176 }
177177
178178 /// Returns `Some(git2::Repository)` if found sibling `Cargo.toml` and `.git`
@@ -222,7 +222,7 @@ impl<'cfg> PathSource<'cfg> {
222222 & self ,
223223 pkg : & Package ,
224224 repo : & git2:: Repository ,
225- filter : & mut dyn FnMut ( & Path , bool ) -> bool ,
225+ filter : & dyn Fn ( & Path , bool ) -> bool ,
226226 ) -> CargoResult < Vec < PathBuf > > {
227227 warn ! ( "list_files_git {}" , pkg. package_id( ) ) ;
228228 let index = repo. index ( ) ?;
@@ -376,7 +376,7 @@ impl<'cfg> PathSource<'cfg> {
376376 fn list_files_walk (
377377 & self ,
378378 pkg : & Package ,
379- filter : & mut dyn FnMut ( & Path , bool ) -> bool ,
379+ filter : & dyn Fn ( & Path , bool ) -> bool ,
380380 ) -> CargoResult < Vec < PathBuf > > {
381381 let mut ret = Vec :: new ( ) ;
382382 self . walk ( pkg. root ( ) , & mut ret, true , filter) ?;
@@ -388,7 +388,7 @@ impl<'cfg> PathSource<'cfg> {
388388 path : & Path ,
389389 ret : & mut Vec < PathBuf > ,
390390 is_root : bool ,
391- filter : & mut dyn FnMut ( & Path , bool ) -> bool ,
391+ filter : & dyn Fn ( & Path , bool ) -> bool ,
392392 ) -> CargoResult < ( ) > {
393393 let walkdir = WalkDir :: new ( path)
394394 . follow_links ( true )
@@ -432,7 +432,11 @@ impl<'cfg> PathSource<'cfg> {
432432 self . config . shell ( ) . warn ( err) ?;
433433 }
434434 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.
436440 // Don't worry about error skipping here, the callers would
437441 // still hit the IO error if they do access it thereafter.
438442 Some ( path) => ret. push ( path. to_path_buf ( ) ) ,
0 commit comments