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.
This commit is contained in:
Weihang Lo 2025-07-23 16:56:18 +00:00 committed by GitHub
commit dfcf4c2cbd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 54 additions and 2 deletions

View File

@ -254,8 +254,12 @@ fn parse_edge_kinds(
|es| {
es.flat_map(|e| e.split(','))
.filter(|e| {
no_proc_macro = *e == "no-proc-macro";
!no_proc_macro
if *e == "no-proc-macro" {
no_proc_macro = true;
false
} else {
true
}
})
.collect()
},

View File

@ -2318,3 +2318,51 @@ foo v1.0.0 ([ROOT]/foo)
"#]])
.run();
}
#[cargo_test]
fn no_proc_macro_order() {
Package::new("dep", "1.0.0").publish();
Package::new("pm", "1.0.0").proc_macro(true).publish();
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
[dependencies]
pm = "1.0"
dep = "1.0"
"#,
)
.file("src/lib.rs", "")
.build();
p.cargo("tree")
.with_stdout_data(str![[r#"
foo v0.1.0 ([ROOT]/foo)
dep v1.0.0
pm v1.0.0 (proc-macro)
"#]])
.run();
// no-proc-macro combined with other edge kinds
p.cargo("tree -e normal,no-proc-macro")
.with_stdout_data(str![[r#"
foo v0.1.0 ([ROOT]/foo)
dep v1.0.0
"#]])
.run();
// change flag order, expecting the same output
p.cargo("tree -e no-proc-macro,normal")
.with_stdout_data(str![[r#"
foo v0.1.0 ([ROOT]/foo)
dep v1.0.0
"#]])
.run();
}