@@ -647,8 +647,17 @@ impl Validate for PartialSources {
647647 type Output = Sources ;
648648 type Error = Error ;
649649 fn validate ( self , package_name : & str , pre_output : bool ) -> Result < Sources > {
650- let post_glob_files : Vec < PartialSourceFile > = self
650+ let post_env_files : Vec < PartialSourceFile > = self
651651 . files
652+ . into_iter ( )
653+ . map ( |file| match file {
654+ PartialSourceFile :: File ( file) => {
655+ Ok ( PartialSourceFile :: File ( env_string_from_string ( file) ?) )
656+ }
657+ other => Ok ( other) ,
658+ } )
659+ . collect :: < Result < Vec < _ > > > ( ) ?;
660+ let post_glob_files: Vec < PartialSourceFile > = post_env_files
652661 . into_iter ( )
653662 . map ( |pre_glob_file| {
654663 if let PartialSourceFile :: File ( _) = pre_glob_file {
@@ -779,10 +788,7 @@ impl Validate for PartialSourceFile {
779788 type Error = Error ;
780789 fn validate ( self , package_name : & str , pre_output : bool ) -> Result < SourceFile > {
781790 match self {
782- PartialSourceFile :: File ( path) => {
783- let env_path_buf = env_path_from_string ( path. clone ( ) ) ?;
784- Ok ( SourceFile :: File ( env_path_buf) )
785- }
791+ PartialSourceFile :: File ( path) => Ok ( SourceFile :: File ( PathBuf :: from ( path) ) ) ,
786792 PartialSourceFile :: Group ( srcs) => Ok ( SourceFile :: Group ( Box :: new (
787793 srcs. validate ( package_name, pre_output) ?,
788794 ) ) ) ,
@@ -1281,18 +1287,20 @@ pub enum LockedSource {
12811287}
12821288
12831289#[ cfg( unix) ]
1284- pub ( crate ) fn env_path_from_string ( path_str : String ) -> Result < PathBuf > {
1285- Ok ( PathBuf :: from (
1286- subst:: substitute ( & path_str, & subst:: Env ) . map_err ( |cause| {
1287- Error :: chain (
1288- format ! ( "Unable to substitute with env: {}" , path_str) ,
1289- cause,
1290- )
1291- } ) ?,
1292- ) )
1290+ fn env_string_from_string ( path_str : String ) -> Result < String > {
1291+ subst:: substitute ( & path_str, & subst:: Env ) . map_err ( |cause| {
1292+ Error :: chain (
1293+ format ! ( "Unable to substitute with env: {}" , path_str) ,
1294+ cause,
1295+ )
1296+ } )
12931297}
12941298
12951299#[ cfg( windows) ]
1300+ fn env_string_from_string ( path_str : String ) -> Result < String > {
1301+ Ok ( path_str)
1302+ }
1303+
12961304pub ( crate ) fn env_path_from_string ( path_str : String ) -> Result < PathBuf > {
1297- Ok ( PathBuf :: from ( path_str) )
1305+ Ok ( PathBuf :: from ( env_string_from_string ( path_str) ? ) )
12981306}
0 commit comments