@@ -283,8 +283,6 @@ impl CargoWorkspace {
283
283
}
284
284
CargoFeatures :: Selected { features, no_default_features } => {
285
285
if * no_default_features {
286
- // FIXME: `NoDefaultFeatures` is mutual exclusive with `SomeFeatures`
287
- // https://github.com/oli-obk/cargo_metadata/issues/79
288
286
meta. features ( CargoOpt :: NoDefaultFeatures ) ;
289
287
}
290
288
if !features. is_empty ( ) {
@@ -329,18 +327,21 @@ impl CargoWorkspace {
329
327
let ws_members = & meta. workspace_members ;
330
328
331
329
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 {
333
331
let cargo_metadata:: Package {
334
- id,
335
- edition,
336
332
name,
337
- manifest_path,
338
333
version,
339
- metadata,
334
+ id,
335
+ source,
336
+ targets : meta_targets,
337
+ features,
338
+ manifest_path,
340
339
repository,
340
+ edition,
341
+ metadata,
341
342
..
342
343
} = meta_pkg;
343
- let meta = from_value :: < PackageMetadata > ( metadata. clone ( ) ) . unwrap_or_default ( ) ;
344
+ let meta = from_value :: < PackageMetadata > ( metadata) . unwrap_or_default ( ) ;
344
345
let edition = match edition {
345
346
cargo_metadata:: Edition :: E2015 => Edition :: Edition2015 ,
346
347
cargo_metadata:: Edition :: E2018 => Edition :: Edition2018 ,
@@ -352,35 +353,36 @@ impl CargoWorkspace {
352
353
} ;
353
354
// We treat packages without source as "local" packages. That includes all members of
354
355
// 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) ;
357
358
358
359
let pkg = packages. alloc ( PackageData {
359
360
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 ( ) ,
363
364
targets : Vec :: new ( ) ,
364
365
is_local,
365
366
is_member,
366
367
edition,
367
- repository : repository . clone ( ) ,
368
+ repository,
368
369
dependencies : Vec :: new ( ) ,
369
- features : meta_pkg . features . clone ( ) . into_iter ( ) . collect ( ) ,
370
+ features : features. into_iter ( ) . collect ( ) ,
370
371
active_features : Vec :: new ( ) ,
371
372
metadata : meta. rust_analyzer . unwrap_or_default ( ) ,
372
373
} ) ;
373
374
let pkg_data = & mut packages[ pkg] ;
374
375
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;
377
379
let tgt = targets. alloc ( TargetData {
378
380
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,
384
386
} ) ;
385
387
pkg_data. targets . push ( tgt) ;
386
388
}
0 commit comments