@@ -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,10 +42,8 @@ impl ops::Index<Target> for CargoWorkspace {
4342 }
4443}
4544
46- // TODO: rename to CargoConfig, kill `rename_all`, kill serde dep?
47- #[ derive( Deserialize , Clone , Debug , PartialEq , Eq ) ]
48- #[ serde( rename_all = "camelCase" , default ) ]
49- pub struct CargoFeatures {
45+ #[ derive( Clone , Debug , PartialEq , Eq ) ]
46+ pub struct CargoConfig {
5047 /// Do not activate the `default` feature.
5148 pub no_default_features : bool ,
5249
@@ -61,9 +58,9 @@ pub struct CargoFeatures {
6158 pub load_out_dirs_from_check : bool ,
6259}
6360
64- impl Default for CargoFeatures {
61+ impl Default for CargoConfig {
6562 fn default ( ) -> Self {
66- CargoFeatures {
63+ CargoConfig {
6764 no_default_features : false ,
6865 all_features : true ,
6966 features : Vec :: new ( ) ,
@@ -142,7 +139,7 @@ impl PackageData {
142139impl CargoWorkspace {
143140 pub fn from_cargo_metadata (
144141 cargo_toml : & Path ,
145- cargo_features : & CargoFeatures ,
142+ cargo_features : & CargoConfig ,
146143 ) -> Result < CargoWorkspace > {
147144 let mut meta = MetadataCommand :: new ( ) ;
148145 meta. manifest_path ( cargo_toml) ;
@@ -276,7 +273,7 @@ pub struct ExternResources {
276273
277274pub fn load_extern_resources (
278275 cargo_toml : & Path ,
279- cargo_features : & CargoFeatures ,
276+ cargo_features : & CargoConfig ,
280277) -> Result < ExternResources > {
281278 let mut cmd = Command :: new ( cargo_binary ( ) ) ;
282279 cmd. args ( & [ "check" , "--message-format=json" , "--manifest-path" ] ) . arg ( cargo_toml) ;
@@ -294,9 +291,8 @@ pub fn load_extern_resources(
294291
295292 let mut res = ExternResources :: default ( ) ;
296293
297- let stdout = String :: from_utf8 ( output. stdout ) ?;
298- for line in stdout. lines ( ) {
299- 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 {
300296 match message {
301297 Message :: BuildScriptExecuted ( BuildScript { package_id, out_dir, .. } ) => {
302298 res. out_dirs . insert ( package_id, out_dir) ;
0 commit comments