@@ -26,6 +26,7 @@ use vfs::Vfs;
26
26
use std:: collections:: { BTreeMap , HashMap , HashSet } ;
27
27
use std:: env;
28
28
use std:: ffi:: OsString ;
29
+ use std:: fmt:: Write ;
29
30
use std:: fs:: { read_dir, remove_file} ;
30
31
use std:: path:: { Path , PathBuf } ;
31
32
use std:: process:: Command ;
@@ -347,7 +348,9 @@ impl Executor for RlsExecutor {
347
348
self . is_primary_crate ( id)
348
349
}
349
350
350
- fn exec ( & self , cargo_cmd : ProcessBuilder , id : & PackageId , target : & Target ) -> CargoResult < ( ) > {
351
+ fn exec ( & self , mut cargo_cmd : ProcessBuilder , id : & PackageId , target : & Target ) -> CargoResult < ( ) > {
352
+ // Use JSON output so that we can parse the rustc output.
353
+ cargo_cmd. arg ( "--error-format=json" ) ;
351
354
// Delete any stale data. We try and remove any json files with
352
355
// the same crate name as Cargo would emit. This includes files
353
356
// with the same crate name but different hashes, e.g., those
@@ -617,18 +620,15 @@ impl CargoOptions {
617
620
}
618
621
619
622
fn prepare_cargo_rustflags ( config : & Config ) -> String {
620
- let mut flags = "--error-format=json " . to_owned ( ) ;
623
+ let mut flags = env :: var ( "RUSTFLAGS" ) . unwrap_or_else ( |_| String :: new ( ) ) ;
621
624
622
- if let Some ( ref sysroot ) = config. sysroot {
623
- flags . push_str ( & format ! ( " --sysroot {}", sysroot ) ) ;
625
+ if let Some ( config_flags ) = & config. rustflags {
626
+ write ! ( flags , " {}", config_flags . as_str ( ) ) . unwrap ( ) ;
624
627
}
625
628
626
- flags = format ! (
627
- "{} {} {}" ,
628
- env:: var( "RUSTFLAGS" ) . unwrap_or_else( |_| String :: new( ) ) ,
629
- config. rustflags. as_ref( ) . map( |s| s. as_str( ) ) . unwrap_or( "" ) ,
630
- flags
631
- ) ;
629
+ if let Some ( sysroot) = & config. sysroot {
630
+ write ! ( flags, " --sysroot {}" , sysroot) . unwrap ( ) ;
631
+ }
632
632
633
633
dedup_flags ( & flags)
634
634
}
@@ -709,7 +709,6 @@ fn current_sysroot() -> Option<String> {
709
709
}
710
710
}
711
711
712
-
713
712
/// `flag_str` is a string of command line args for Rust. This function removes any
714
713
/// duplicate flags.
715
714
fn dedup_flags ( flag_str : & str ) -> String {
0 commit comments