Skip to content

Commit dfcf4c2

Browse files
authored
fix: no-proc-macro is overridden by subsequent edges (#15764)
### What does this PR try to resolve? To close #15763. ### How to test and review this PR? See steps in #15763.
2 parents 9b5231f + 2654f29 commit dfcf4c2

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

src/bin/cargo/commands/tree.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,12 @@ fn parse_edge_kinds(
254254
|es| {
255255
es.flat_map(|e| e.split(','))
256256
.filter(|e| {
257-
no_proc_macro = *e == "no-proc-macro";
258-
!no_proc_macro
257+
if *e == "no-proc-macro" {
258+
no_proc_macro = true;
259+
false
260+
} else {
261+
true
262+
}
259263
})
260264
.collect()
261265
},

tests/testsuite/cargo_tree/deps.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2318,3 +2318,51 @@ foo v1.0.0 ([ROOT]/foo)
23182318
"#]])
23192319
.run();
23202320
}
2321+
2322+
#[cargo_test]
2323+
fn no_proc_macro_order() {
2324+
Package::new("dep", "1.0.0").publish();
2325+
Package::new("pm", "1.0.0").proc_macro(true).publish();
2326+
let p = project()
2327+
.file(
2328+
"Cargo.toml",
2329+
r#"
2330+
[package]
2331+
name = "foo"
2332+
version = "0.1.0"
2333+
2334+
[dependencies]
2335+
pm = "1.0"
2336+
dep = "1.0"
2337+
"#,
2338+
)
2339+
.file("src/lib.rs", "")
2340+
.build();
2341+
2342+
p.cargo("tree")
2343+
.with_stdout_data(str![[r#"
2344+
foo v0.1.0 ([ROOT]/foo)
2345+
├── dep v1.0.0
2346+
└── pm v1.0.0 (proc-macro)
2347+
2348+
"#]])
2349+
.run();
2350+
2351+
// no-proc-macro combined with other edge kinds
2352+
p.cargo("tree -e normal,no-proc-macro")
2353+
.with_stdout_data(str![[r#"
2354+
foo v0.1.0 ([ROOT]/foo)
2355+
└── dep v1.0.0
2356+
2357+
"#]])
2358+
.run();
2359+
2360+
// change flag order, expecting the same output
2361+
p.cargo("tree -e no-proc-macro,normal")
2362+
.with_stdout_data(str![[r#"
2363+
foo v0.1.0 ([ROOT]/foo)
2364+
└── dep v1.0.0
2365+
2366+
"#]])
2367+
.run();
2368+
}

0 commit comments

Comments
 (0)