@@ -38,14 +38,14 @@ impl MissionLocation {
3838 package_directory = match package_directory. parent ( ) {
3939 Some ( dir) => dir. to_path_buf ( ) ,
4040 None => {
41- return Err ( anyhow ! (
41+ bail ! (
4242 "Cargo.toml file not found.\n \
4343 bacon must be launched \n \
4444 * in a rust project directory\n \
4545 * or with a rust project directory given in argument\n \
4646 (a rust project directory contains a Cargo.toml file or has such parent)\n \
4747 "
48- ) ) ;
48+ ) ;
4949 }
5050 } ;
5151 } ;
@@ -88,6 +88,7 @@ impl Mission {
8888 job_name : Option < & str > ,
8989 settings : Settings ,
9090 ) -> Result < Self > {
91+ let package_name = location. package_name ( ) ;
9192 let add_all_src = location. intended_is_package ;
9293 let ( job_name, job) = package_config
9394 . get_job ( job_name)
@@ -126,12 +127,11 @@ impl Mission {
126127 }
127128 }
128129
129- let cargo_execution_directory = location. package_directory . to_path_buf ( ) ;
130- let package_name = location. package_name ( ) ;
130+ let cargo_execution_directory = location. package_directory ;
131131 Ok ( Mission {
132132 package_name,
133- cargo_execution_directory,
134133 job_name,
134+ cargo_execution_directory,
135135 job,
136136 files_to_watch,
137137 directories_to_watch,
@@ -162,43 +162,58 @@ impl Mission {
162162 let mut features_done = false ;
163163 let mut last_is_features = false ;
164164 for arg in tokens {
165- let mut arg = arg. to_string ( ) ;
166165 if last_is_features {
167- // arg is expected there to be the list of features
168- features_done = true ;
169- match ( & self . settings . features , self . settings . no_default_features ) {
170- ( Some ( features) , false ) => {
171- // we take the features of both the job and the args
172- arg = merge_features ( & arg, & features) ;
173- }
174- ( Some ( features) , true ) => {
175- // arg add features and remove the job ones
176- arg = features. clone ( ) ;
177- }
178- ( None , true ) => {
179- // arg just remove the job features
180- arg = "" . to_string ( )
181- }
182- ( None , false ) => {
183- // nothing to change
166+ if self . settings . all_features {
167+ debug ! ( "ignoring features given along --all-features" ) ;
168+ } else {
169+ features_done = true ;
170+ // arg is expected there to be the list of features
171+ match ( & self . settings . features , self . settings . no_default_features ) {
172+ ( Some ( features) , false ) => {
173+ // we take the features of both the job and the args
174+ command. arg ( "--features" ) ;
175+ command. arg ( merge_features ( arg, & features) ) ;
176+ }
177+ ( Some ( features) , true ) => {
178+ // arg add features and remove the job ones
179+ command. arg ( "--features" ) ;
180+ command. arg ( & features) ;
181+ }
182+ ( None , true ) => {
183+ // we pass no feature
184+ }
185+ ( None , false ) => {
186+ // nothing to change
187+ command. arg ( "--features" ) ;
188+ command. arg ( arg) ;
189+ }
184190 }
185191 }
186192 last_is_features = false ;
187193 } else if arg == "--no-default-features" {
188194 no_default_features_done = true ;
189195 last_is_features = false ;
196+ command. arg ( arg) ;
190197 } else if arg == "--features" {
191198 last_is_features = true ;
199+ } else {
200+ command. arg ( arg) ;
192201 }
193- command. arg ( arg) ;
194202 }
195203 if self . settings . no_default_features && !no_default_features_done {
196204 command. arg ( "--no-default-features" ) ;
197205 }
206+ if self . settings . all_features {
207+ command. arg ( "--all-features" ) ;
208+ }
198209 if !features_done {
199210 if let Some ( features) = & self . settings . features {
200- command. arg ( "--features" ) ;
201- command. arg ( features) ;
211+ if self . settings . all_features {
212+ debug ! ( "not using features because of --all-features" ) ;
213+ } else {
214+ command. arg ( "--features" ) ;
215+ command. arg ( features) ;
216+ }
202217 }
203218 }
204219 command. current_dir ( & self . cargo_execution_directory ) ;
@@ -220,5 +235,5 @@ fn merge_features(a: &str, b: &str) -> String {
220235 for feature in b. split ( ',' ) {
221236 features. insert ( feature) ;
222237 }
223- features. iter ( ) . map ( | & s|s ) . collect :: < Vec < & str > > ( ) . join ( "," )
238+ features. iter ( ) . copied ( ) . collect :: < Vec < & str > > ( ) . join ( "," )
224239}
0 commit comments