File tree Expand file tree Collapse file tree 3 files changed +57
-20
lines changed Expand file tree Collapse file tree 3 files changed +57
-20
lines changed Original file line number Diff line number Diff line change @@ -362,6 +362,10 @@ fn add_pkg(
362
362
if !opts. edge_kinds . contains ( & EdgeKind :: Dep ( dep. kind ( ) ) ) {
363
363
return false ;
364
364
}
365
+ // Filter out proc-macrcos if requested.
366
+ if opts. no_proc_macro && graph. package_for_id ( dep_id) . proc_macro ( ) {
367
+ return false ;
368
+ }
365
369
if dep. is_optional ( ) {
366
370
// If the new feature resolver does not enable this
367
371
// optional dep, then don't use it.
Original file line number Diff line number Diff line change @@ -267,7 +267,6 @@ fn print(
267
267
opts. prefix ,
268
268
opts. no_dedupe ,
269
269
opts. max_display_depth ,
270
- opts. no_proc_macro ,
271
270
& mut visited_deps,
272
271
& mut levels_continue,
273
272
& mut print_stack,
@@ -288,7 +287,6 @@ fn print_node<'a>(
288
287
prefix : Prefix ,
289
288
no_dedupe : bool ,
290
289
max_display_depth : u32 ,
291
- no_proc_macro : bool ,
292
290
visited_deps : & mut HashSet < usize > ,
293
291
levels_continue : & mut Vec < bool > ,
294
292
print_stack : & mut Vec < usize > ,
@@ -348,7 +346,6 @@ fn print_node<'a>(
348
346
prefix,
349
347
no_dedupe,
350
348
max_display_depth,
351
- no_proc_macro,
352
349
visited_deps,
353
350
levels_continue,
354
351
print_stack,
@@ -369,7 +366,6 @@ fn print_dependencies<'a>(
369
366
prefix : Prefix ,
370
367
no_dedupe : bool ,
371
368
max_display_depth : u32 ,
372
- no_proc_macro : bool ,
373
369
visited_deps : & mut HashSet < usize > ,
374
370
levels_continue : & mut Vec < bool > ,
375
371
print_stack : & mut Vec < usize > ,
@@ -405,19 +401,6 @@ fn print_dependencies<'a>(
405
401
406
402
let mut it = deps
407
403
. iter ( )
408
- . filter ( |dep| {
409
- // Filter out proc-macro dependencies.
410
- if no_proc_macro {
411
- match graph. node ( * * dep) {
412
- & Node :: Package { package_id, .. } => {
413
- !graph. package_for_id ( package_id) . proc_macro ( )
414
- }
415
- _ => true ,
416
- }
417
- } else {
418
- true
419
- }
420
- } )
421
404
. filter ( |dep| {
422
405
// Filter out packages to prune.
423
406
match graph. node ( * * dep) {
@@ -441,7 +424,6 @@ fn print_dependencies<'a>(
441
424
prefix,
442
425
no_dedupe,
443
426
max_display_depth,
444
- no_proc_macro,
445
427
visited_deps,
446
428
levels_continue,
447
429
print_stack,
Original file line number Diff line number Diff line change @@ -1085,6 +1085,59 @@ fn duplicates_with_target() {
1085
1085
p. cargo ( "tree -d --target=all" ) . with_stdout ( "" ) . run ( ) ;
1086
1086
}
1087
1087
1088
+ #[ cargo_test]
1089
+ fn duplicates_with_proc_macro ( ) {
1090
+ Package :: new ( "dupe-dep" , "1.0.0" ) . publish ( ) ;
1091
+ Package :: new ( "dupe-dep" , "2.0.0" ) . publish ( ) ;
1092
+ Package :: new ( "proc" , "1.0.0" )
1093
+ . proc_macro ( true )
1094
+ . dep ( "dupe-dep" , "1.0" )
1095
+ . publish ( ) ;
1096
+ let p = project ( )
1097
+ . file (
1098
+ "Cargo.toml" ,
1099
+ r#"
1100
+ [package]
1101
+ name = "foo"
1102
+ version = "0.1.0"
1103
+
1104
+ [dependencies]
1105
+ proc = "1.0"
1106
+ dupe-dep = "2.0"
1107
+ "# ,
1108
+ )
1109
+ . file ( "src/lib.rs" , "" )
1110
+ . build ( ) ;
1111
+
1112
+ p. cargo ( "tree" )
1113
+ . with_stdout (
1114
+ "\
1115
+ foo v0.1.0 ([..]/foo)
1116
+ ├── dupe-dep v2.0.0
1117
+ └── proc v1.0.0 (proc-macro)
1118
+ └── dupe-dep v1.0.0
1119
+ " ,
1120
+ )
1121
+ . run ( ) ;
1122
+
1123
+ p. cargo ( "tree --duplicates" )
1124
+ . with_stdout (
1125
+ "\
1126
+ dupe-dep v1.0.0
1127
+ └── proc v1.0.0 (proc-macro)
1128
+ └── foo v0.1.0 ([..]/foo)
1129
+
1130
+ dupe-dep v2.0.0
1131
+ └── foo v0.1.0 ([..]/foo)
1132
+ " ,
1133
+ )
1134
+ . run ( ) ;
1135
+
1136
+ p. cargo ( "tree --duplicates --edges no-proc-macro" )
1137
+ . with_stdout ( "" )
1138
+ . run ( ) ;
1139
+ }
1140
+
1088
1141
#[ cargo_test]
1089
1142
fn charset ( ) {
1090
1143
let p = make_simple_proj ( ) ;
@@ -1540,8 +1593,6 @@ somedep v1.0.0
1540
1593
"\
1541
1594
somedep v1.0.0
1542
1595
└── foo v0.1.0 ([..]/foo)
1543
-
1544
- somedep v1.0.0
1545
1596
" ,
1546
1597
)
1547
1598
. run ( ) ;
You can’t perform that action at this time.
0 commit comments