@@ -13,7 +13,6 @@ use cargo_metadata::{BuildScript, CargoOpt, Message, MetadataCommand, PackageId}
1313use ra_arena:: { Arena , Idx } ;
1414use ra_db:: Edition ;
1515use rustc_hash:: FxHashMap ;
16- use serde:: Deserialize ;
1716
1817/// `CargoWorkspace` represents the logical structure of, well, a Cargo
1918/// workspace. It pretty closely mirrors `cargo metadata` output.
@@ -43,9 +42,8 @@ impl ops::Index<Target> for CargoWorkspace {
4342 }
4443}
4544
46- #[ derive( Deserialize , Clone , Debug , PartialEq , Eq ) ]
47- #[ serde( rename_all = "camelCase" , default ) ]
48- pub struct CargoFeatures {
45+ #[ derive( Clone , Debug , PartialEq , Eq ) ]
46+ pub struct CargoConfig {
4947 /// Do not activate the `default` feature.
5048 pub no_default_features : bool ,
5149
@@ -60,9 +58,9 @@ pub struct CargoFeatures {
6058 pub load_out_dirs_from_check : bool ,
6159}
6260
63- impl Default for CargoFeatures {
61+ impl Default for CargoConfig {
6462 fn default ( ) -> Self {
65- CargoFeatures {
63+ CargoConfig {
6664 no_default_features : false ,
6765 all_features : true ,
6866 features : Vec :: new ( ) ,
@@ -141,7 +139,7 @@ impl PackageData {
141139impl CargoWorkspace {
142140 pub fn from_cargo_metadata (
143141 cargo_toml : & Path ,
144- cargo_features : & CargoFeatures ,
142+ cargo_features : & CargoConfig ,
145143 ) -> Result < CargoWorkspace > {
146144 let mut meta = MetadataCommand :: new ( ) ;
147145 meta. manifest_path ( cargo_toml) ;
@@ -275,7 +273,7 @@ pub struct ExternResources {
275273
276274pub fn load_extern_resources (
277275 cargo_toml : & Path ,
278- cargo_features : & CargoFeatures ,
276+ cargo_features : & CargoConfig ,
279277) -> Result < ExternResources > {
280278 let mut cmd = Command :: new ( cargo_binary ( ) ) ;
281279 cmd. args ( & [ "check" , "--message-format=json" , "--manifest-path" ] ) . arg ( cargo_toml) ;
@@ -293,9 +291,8 @@ pub fn load_extern_resources(
293291
294292 let mut res = ExternResources :: default ( ) ;
295293
296- let stdout = String :: from_utf8 ( output. stdout ) ?;
297- for line in stdout. lines ( ) {
298- if let Ok ( message) = serde_json:: from_str :: < cargo_metadata:: Message > ( & line) {
294+ for message in cargo_metadata:: parse_messages ( output. stdout . as_slice ( ) ) {
295+ if let Ok ( message) = message {
299296 match message {
300297 Message :: BuildScriptExecuted ( BuildScript { package_id, out_dir, .. } ) => {
301298 res. out_dirs . insert ( package_id, out_dir) ;
0 commit comments