@@ -13,7 +13,7 @@ use foundry_compilers_artifacts::{
1313} ;
1414use foundry_compilers_core:: {
1515 error:: { Result , SolcError , SolcIoError } ,
16- utils,
16+ utils:: { self , strip_prefix_owned } ,
1717} ;
1818use serde:: { Deserialize , Serialize } ;
1919use std:: {
@@ -661,27 +661,25 @@ impl ProjectPaths {
661661
662662 /// Removes `base` from all folders
663663 pub fn strip_prefix_all ( & mut self , base : & Path ) -> & mut Self {
664- if let Ok ( prefix ) = self . artifacts . strip_prefix ( base) {
665- self . artifacts = prefix . to_path_buf ( ) ;
664+ if let Ok ( stripped ) = self . artifacts . strip_prefix ( base) {
665+ self . artifacts = stripped . to_path_buf ( ) ;
666666 }
667- if let Ok ( prefix ) = self . build_infos . strip_prefix ( base) {
668- self . build_infos = prefix . to_path_buf ( ) ;
667+ if let Ok ( stripped ) = self . build_infos . strip_prefix ( base) {
668+ self . build_infos = stripped . to_path_buf ( ) ;
669669 }
670- if let Ok ( prefix ) = self . sources . strip_prefix ( base) {
671- self . sources = prefix . to_path_buf ( ) ;
670+ if let Ok ( stripped ) = self . sources . strip_prefix ( base) {
671+ self . sources = stripped . to_path_buf ( ) ;
672672 }
673- if let Ok ( prefix ) = self . tests . strip_prefix ( base) {
674- self . tests = prefix . to_path_buf ( ) ;
673+ if let Ok ( stripped ) = self . tests . strip_prefix ( base) {
674+ self . tests = stripped . to_path_buf ( ) ;
675675 }
676- if let Ok ( prefix ) = self . scripts . strip_prefix ( base) {
677- self . scripts = prefix . to_path_buf ( ) ;
676+ if let Ok ( stripped ) = self . scripts . strip_prefix ( base) {
677+ self . scripts = stripped . to_path_buf ( ) ;
678678 }
679- let libraries = std:: mem:: take ( & mut self . libraries ) ;
680- self . libraries . extend (
681- libraries
682- . into_iter ( )
683- . map ( |p| p. strip_prefix ( base) . map ( |p| p. to_path_buf ( ) ) . unwrap_or ( p) ) ,
684- ) ;
679+ self . libraries = std:: mem:: take ( & mut self . libraries )
680+ . into_iter ( )
681+ . map ( |path| strip_prefix_owned ( path, base) )
682+ . collect ( ) ;
685683 self
686684 }
687685}
0 commit comments