Skip to content

Commit 6d43fa6

Browse files
committed
refactor: simplify #10525 test case
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
1 parent 386645e commit 6d43fa6

File tree

1 file changed

+45
-67
lines changed

1 file changed

+45
-67
lines changed

tests/testsuite/artifact_dep.rs

Lines changed: 45 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2672,147 +2672,125 @@ fn decouple_same_target_transitive_dep_from_artifact_dep_lib() {
26722672
}
26732673

26742674
#[cargo_test]
2675-
fn issue_10525() {
2675+
fn decouple_same_target_transitive_dep_from_artifact_dep_and_proc_macro() {
26762676
let target = rustc_host();
26772677
let p = project()
26782678
.file(
26792679
"Cargo.toml",
26802680
&format!(
26812681
r#"
26822682
[package]
2683-
name = "mycrate"
2684-
version = "0.0.0"
2683+
name = "foo"
2684+
version = "0.1.0"
26852685
edition = "2021"
26862686
26872687
[dependencies]
2688-
structopt-derive = {{ path = "structopt-derive" }}
2689-
mybindep = {{ path = "mybindep", artifact = "bin", target = "{target}" }}
2688+
c = {{ path = "c" }}
2689+
bar = {{ path = "bar", artifact = "bin", target = "{target}" }}
26902690
"#
26912691
),
26922692
)
2693+
.file("src/lib.rs", "")
26932694
.file(
2694-
"src/main.rs",
2695-
r#"
2696-
fn main() {
2697-
env!("CARGO_BIN_FILE_MYBINDEP");
2698-
}
2699-
"#,
2700-
)
2701-
.file(
2702-
"mybindep/Cargo.toml",
2695+
"bar/Cargo.toml",
27032696
r#"
27042697
[package]
2705-
name = "mybindep"
2706-
version = "0.0.0"
2707-
edition = "2021"
2698+
name = "bar"
2699+
version = "0.1.0"
27082700
27092701
[dependencies]
2710-
clap_derive = { path = "../clap_derive" }
2702+
b = { path = "../b" }
27112703
"#,
27122704
)
2713-
.file("mybindep/src/main.rs", "fn main() {}")
2705+
.file("bar/src/main.rs", "fn main() {}")
27142706
.file(
2715-
"clap_derive/Cargo.toml",
2707+
"b/Cargo.toml",
27162708
r#"
27172709
[package]
2718-
name = "clap_derive"
2719-
version = "0.0.0"
2710+
name = "b"
2711+
version = "0.1.0"
27202712
edition = "2021"
27212713
27222714
[dependencies]
2723-
proc-macro-error = { path = "../proc-macro-error" }
2715+
a = { path = "../a" }
27242716
27252717
[lib]
27262718
proc-macro = true
27272719
"#,
27282720
)
2729-
.file("clap_derive/src/lib.rs", "")
2721+
.file("b/src/lib.rs", "")
27302722
.file(
2731-
"structopt-derive/Cargo.toml",
2723+
"c/Cargo.toml",
27322724
r#"
27332725
[package]
2734-
name = "structopt-derive"
2735-
version = "0.0.0"
2726+
name = "c"
2727+
version = "0.1.0"
27362728
edition = "2021"
27372729
27382730
[dependencies]
2739-
syn = { path = "../syn", features = ["parsing"] }
2740-
proc-macro-error = { path = "../proc-macro-error" }
2731+
d = { path = "../d", features = ["feature"] }
2732+
a = { path = "../a" }
27412733
27422734
[lib]
27432735
proc-macro = true
27442736
"#,
27452737
)
27462738
.file(
2747-
"structopt-derive/src/lib.rs",
2739+
"c/src/lib.rs",
27482740
r#"
2749-
use proc_macro_error::ResultExt;
2741+
use a::Trait;
27502742
2751-
fn _parse_structopt_attributes() {
2752-
Ok::<(), syn::Error>(()).unwrap_or_abort()
2743+
fn _c() {
2744+
d::D.a()
27532745
}
27542746
"#,
27552747
)
27562748
.file(
2757-
"proc-macro-error/Cargo.toml",
2749+
"a/Cargo.toml",
27582750
r#"
27592751
[package]
2760-
name = "proc-macro-error"
2761-
version = "0.0.0"
2762-
edition = "2021"
2752+
name = "a"
2753+
version = "0.1.0"
27632754
27642755
[dependencies]
2765-
syn = { path = "../syn" }
2756+
d = { path = "../d" }
27662757
"#,
27672758
)
27682759
.file(
2769-
"proc-macro-error/src/lib.rs",
2760+
"a/src/lib.rs",
27702761
r#"
2771-
pub trait ResultExt<T> {
2772-
fn unwrap_or_abort(self) -> T;
2762+
pub trait Trait {
2763+
fn a(&self) {}
27732764
}
27742765
2775-
impl<T, E: Into<Diagnostic>> ResultExt<T> for Result<T, E> {
2776-
fn unwrap_or_abort(self) -> T {
2777-
panic!()
2778-
}
2779-
}
2780-
2781-
pub struct Diagnostic;
2782-
2783-
impl From<syn::Error> for Diagnostic {
2784-
fn from(_: syn::Error) -> Self {
2785-
panic!()
2786-
}
2787-
}
2766+
impl Trait for d::D {}
27882767
"#,
27892768
)
27902769
.file(
2791-
"syn/Cargo.toml",
2770+
"d/Cargo.toml",
27922771
r#"
27932772
[package]
2794-
name = "syn"
2795-
version = "0.0.0"
2796-
edition = "2021"
2773+
name = "d"
2774+
version = "0.1.0"
27972775
27982776
[features]
2799-
parsing = []
2777+
feature = []
28002778
"#,
28012779
)
2802-
.file("syn/src/lib.rs", "pub struct Error;")
2780+
.file("d/src/lib.rs", "pub struct D;")
28032781
.build();
28042782

28052783
p.cargo("build -Z bindeps")
28062784
.masquerade_as_nightly_cargo(&["bindeps"])
28072785
.with_stderr_unordered(
28082786
"\
2809-
[COMPILING] mycrate v0.0.0 ([CWD])
2810-
[COMPILING] mybindep v0.0.0 ([CWD]/mybindep)
2811-
[COMPILING] clap_derive v0.0.0 ([CWD]/clap_derive)
2812-
[COMPILING] structopt-derive v0.0.0 ([CWD]/structopt-derive)
2813-
[COMPILING] proc-macro-error v0.0.0 ([CWD]/proc-macro-error)
2814-
[COMPILING] syn v0.0.0 ([CWD]/syn)
2815-
[FINISHED] dev [..]
2787+
[COMPILING] d v0.1.0 ([CWD]/d)
2788+
[COMPILING] a v0.1.0 ([CWD]/a)
2789+
[COMPILING] b v0.1.0 ([CWD]/b)
2790+
[COMPILING] c v0.1.0 ([CWD]/c)
2791+
[COMPILING] bar v0.1.0 ([CWD]/bar)
2792+
[COMPILING] foo v0.1.0 ([CWD])
2793+
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
28162794
",
28172795
)
28182796
.run();

0 commit comments

Comments
 (0)