File tree 1 file changed +23
-2
lines changed
1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change 1
- use std:: cmp;
2
1
use std:: collections:: { BTreeMap , HashSet } ;
3
2
use std:: fs:: File ;
4
3
use std:: io:: { self , BufRead } ;
@@ -7,6 +6,7 @@ use std::path::PathBuf;
7
6
use std:: str;
8
7
use std:: task:: Poll ;
9
8
use std:: time:: Duration ;
9
+ use std:: { cmp, str} ;
10
10
11
11
use anyhow:: { anyhow, bail, format_err, Context as _} ;
12
12
use cargo_util:: paths;
@@ -366,13 +366,34 @@ fn transmit(
366
366
return Ok ( ( ) ) ;
367
367
}
368
368
369
+ fn is_deps_feature ( deps : Vec < NewCrateDependency > , feature : & str ) -> bool {
370
+ if !feature. contains ( '/' ) {
371
+ return true ;
372
+ }
373
+ let mut iter = feature. split ( '/' ) ;
374
+ let dep_name = iter. next ( ) . unwrap ( ) ;
375
+ let feature_name = iter. next ( ) . unwrap ( ) ;
376
+ for dep in deps. iter ( ) {
377
+ if dep. name == dep_name {
378
+ if dep. features . contains ( & feature_name. to_string ( ) ) {
379
+ return true ;
380
+ }
381
+ }
382
+ }
383
+ false
384
+ }
385
+
369
386
let string_features = match manifest. original ( ) . features ( ) {
370
387
Some ( features) => features
371
388
. iter ( )
372
389
. map ( |( feat, values) | {
373
390
(
374
391
feat. to_string ( ) ,
375
- values. iter ( ) . map ( |fv| fv. to_string ( ) ) . collect ( ) ,
392
+ values
393
+ . iter ( )
394
+ . map ( |fv| fv. to_string ( ) )
395
+ . filter ( |feat| is_deps_feature ( deps. clone ( ) , feat) )
396
+ . collect ( ) ,
376
397
)
377
398
} )
378
399
. collect :: < BTreeMap < String , Vec < String > > > ( ) ,
You can’t perform that action at this time.
0 commit comments