@@ -283,8 +283,6 @@ impl CargoWorkspace {
283283 }
284284 CargoFeatures :: Selected { features, no_default_features } => {
285285 if * no_default_features {
286- // FIXME: `NoDefaultFeatures` is mutual exclusive with `SomeFeatures`
287- // https://github.com/oli-obk/cargo_metadata/issues/79
288286 meta. features ( CargoOpt :: NoDefaultFeatures ) ;
289287 }
290288 if !features. is_empty ( ) {
@@ -329,18 +327,21 @@ impl CargoWorkspace {
329327 let ws_members = & meta. workspace_members ;
330328
331329 meta. packages . sort_by ( |a, b| a. id . cmp ( & b. id ) ) ;
332- for meta_pkg in & meta. packages {
330+ for meta_pkg in meta. packages {
333331 let cargo_metadata:: Package {
334- id,
335- edition,
336332 name,
337- manifest_path,
338333 version,
339- metadata,
334+ id,
335+ source,
336+ targets : meta_targets,
337+ features,
338+ manifest_path,
340339 repository,
340+ edition,
341+ metadata,
341342 ..
342343 } = meta_pkg;
343- let meta = from_value :: < PackageMetadata > ( metadata. clone ( ) ) . unwrap_or_default ( ) ;
344+ let meta = from_value :: < PackageMetadata > ( metadata) . unwrap_or_default ( ) ;
344345 let edition = match edition {
345346 cargo_metadata:: Edition :: E2015 => Edition :: Edition2015 ,
346347 cargo_metadata:: Edition :: E2018 => Edition :: Edition2018 ,
@@ -352,35 +353,36 @@ impl CargoWorkspace {
352353 } ;
353354 // We treat packages without source as "local" packages. That includes all members of
354355 // the current workspace, as well as any path dependency outside the workspace.
355- let is_local = meta_pkg . source . is_none ( ) ;
356- let is_member = ws_members. contains ( id) ;
356+ let is_local = source. is_none ( ) ;
357+ let is_member = ws_members. contains ( & id) ;
357358
358359 let pkg = packages. alloc ( PackageData {
359360 id : id. repr . clone ( ) ,
360- name : name . clone ( ) ,
361- version : version . clone ( ) ,
362- manifest : AbsPathBuf :: assert ( PathBuf :: from ( & manifest_path) ) . try_into ( ) . unwrap ( ) ,
361+ name,
362+ version,
363+ manifest : AbsPathBuf :: assert ( manifest_path. into ( ) ) . try_into ( ) . unwrap ( ) ,
363364 targets : Vec :: new ( ) ,
364365 is_local,
365366 is_member,
366367 edition,
367- repository : repository . clone ( ) ,
368+ repository,
368369 dependencies : Vec :: new ( ) ,
369- features : meta_pkg . features . clone ( ) . into_iter ( ) . collect ( ) ,
370+ features : features. into_iter ( ) . collect ( ) ,
370371 active_features : Vec :: new ( ) ,
371372 metadata : meta. rust_analyzer . unwrap_or_default ( ) ,
372373 } ) ;
373374 let pkg_data = & mut packages[ pkg] ;
374375 pkg_by_id. insert ( id, pkg) ;
375- for meta_tgt in & meta_pkg. targets {
376- let is_proc_macro = meta_tgt. kind . as_slice ( ) == [ "proc-macro" ] ;
376+ for meta_tgt in meta_targets {
377+ let cargo_metadata:: Target { name, kind, required_features, src_path, .. } =
378+ meta_tgt;
377379 let tgt = targets. alloc ( TargetData {
378380 package : pkg,
379- name : meta_tgt . name . clone ( ) ,
380- root : AbsPathBuf :: assert ( PathBuf :: from ( & meta_tgt . src_path ) ) ,
381- kind : TargetKind :: new ( meta_tgt . kind . as_slice ( ) ) ,
382- is_proc_macro,
383- required_features : meta_tgt . required_features . clone ( ) ,
381+ name,
382+ root : AbsPathBuf :: assert ( src_path. into ( ) ) ,
383+ kind : TargetKind :: new ( & kind) ,
384+ is_proc_macro : & * kind == [ "proc-macro" ] ,
385+ required_features,
384386 } ) ;
385387 pkg_data. targets . push ( tgt) ;
386388 }
0 commit comments