diff --git a/tests/testsuite/artifact_dep.rs b/tests/testsuite/artifact_dep.rs index 5f33a43d720f..e4806a084405 100644 --- a/tests/testsuite/artifact_dep.rs +++ b/tests/testsuite/artifact_dep.rs @@ -2672,3 +2672,259 @@ fn same_target_transitive_dependency_deduplication_lib() { ) .run(); } + +#[cargo_test] +fn issue_10525() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "mycrate" + version = "0.0.0" + edition = "2021" + + [dependencies] + structopt-derive = { path = "structopt-derive" } + mybindep = { path = "mybindep", artifact = "bin", target = "x86_64-unknown-linux-gnu" } + "#, + ) + .file( + "src/main.rs", + r#" + fn main() { + env!("CARGO_BIN_FILE_MYBINDEP"); + } + "#, + ) + .file( + "mybindep/Cargo.toml", + r#" + [package] + name = "mybindep" + version = "0.0.0" + edition = "2021" + + [dependencies] + clap_derive = { path = "../clap_derive" } + "#, + ) + .file("mybindep/src/main.rs", "fn main() {}") + .file( + "clap_derive/Cargo.toml", + r#" + [package] + name = "clap_derive" + version = "0.0.0" + edition = "2021" + + [dependencies] + proc-macro-error = { path = "../proc-macro-error" } + + [lib] + proc-macro = true + "#, + ) + .file("clap_derive/src/lib.rs", "") + .file( + "structopt-derive/Cargo.toml", + r#" + [package] + name = "structopt-derive" + version = "0.0.0" + edition = "2021" + + [dependencies] + syn = { path = "../syn", features = ["parsing"] } + proc-macro-error = { path = "../proc-macro-error" } + + [lib] + proc-macro = true + "#, + ) + .file( + "structopt-derive/src/lib.rs", + r#" + use proc_macro_error::ResultExt; + + fn _parse_structopt_attributes() { + Ok::<(), syn::Error>(()).unwrap_or_abort() + } + "#, + ) + .file( + "proc-macro-error/Cargo.toml", + r#" + [package] + name = "proc-macro-error" + version = "0.0.0" + edition = "2021" + + [dependencies] + syn = { path = "../syn" } + "#, + ) + .file( + "proc-macro-error/src/lib.rs", + r#" + pub trait ResultExt { + fn unwrap_or_abort(self) -> T; + } + + impl> ResultExt for Result { + fn unwrap_or_abort(self) -> T { + panic!() + } + } + + pub struct Diagnostic; + + impl From for Diagnostic { + fn from(_: syn::Error) -> Self { + panic!() + } + } + "#, + ) + .file( + "syn/Cargo.toml", + r#" + [package] + name = "syn" + version = "0.0.0" + edition = "2021" + + [features] + parsing = [] + "#, + ) + .file("syn/src/lib.rs", "pub struct Error;") + .build(); + + p.cargo("build -Z bindeps") + .masquerade_as_nightly_cargo(&["bindeps"]) + .with_stderr_unordered( + "\ +[COMPILING] mycrate v0.0.0 ([CWD]) +[COMPILING] mybindep v0.0.0 ([CWD]/mybindep) +[COMPILING] clap_derive v0.0.0 ([CWD]/clap_derive) +[COMPILING] structopt-derive v0.0.0 ([CWD]/structopt-derive) +[COMPILING] proc-macro-error v0.0.0 ([CWD]/proc-macro-error) +[COMPILING] syn v0.0.0 ([CWD]/syn) +[FINISHED] dev [..] +", + ) + .run(); +} + +#[cargo_test] +fn issue_10837() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "mycrate" + version = "0.0.0" + edition = "2021" + + [dependencies] + indexmap = { path = "indexmap" } + serde = { path = "serde", features = ["alloc"] } + wasmtime-environ = { path = "wasmtime-environ", lib = true, artifact = "bin", target = "x86_64-unknown-linux-gnu" } + "#, + ) + .file("src/lib.rs", "") + .file( + "indexmap/Cargo.toml", + r#" + [package] + name = "indexmap" + version = "0.0.0" + edition = "2021" + + [dependencies] + serde = { path = "../serde", optional = true } + "#, + ) + .file( + "indexmap/src/lib.rs", + r#" + pub struct IndexMap; + + #[cfg(feature = "serde")] + impl serde::Serialize for IndexMap { + fn serialize(&self, _: T) {} + } + "#, + ) + .file( + "serde/Cargo.toml", + r#" + [package] + name = "serde" + version = "0.0.0" + edition = "2021" + + [features] + alloc = [] + "#, + ) + .file( + "serde/src/lib.rs", + r#" + pub trait Serialize { + fn serialize(&self, serializer: S); + } + + pub trait Serializer { + fn serialize_field(&self, value: &T); + } + "#, + ) + .file( + "wasmtime-environ/Cargo.toml", + r#" + [package] + name = "wasmtime-environ" + version = "0.0.0" + edition = "2021" + + [dependencies] + indexmap = { path = "../indexmap", features = ["serde"] } + serde = { path = "../serde" } + "#, + ) + .file( + "wasmtime-environ/src/lib.rs", + r#" + use indexmap::IndexMap; + use serde::{Serialize, Serializer}; + + struct Module { + exports: IndexMap, + } + + impl Serialize for Module { + fn serialize(&self, serializer: T) { + serializer.serialize_field(&self.exports); + } + } + "#, + ) + .file("wasmtime-environ/src/main.rs", "fn main() {}") + .build(); + + p.cargo("build -Z bindeps") + .masquerade_as_nightly_cargo(&["bindeps"]) + .with_stderr_unordered( + "\ +[COMPILING] mycrate v0.0.0 ([CWD]) +[COMPILING] indexmap v0.0.0 ([CWD]/indexmap) +[COMPILING] serde v0.0.0 ([CWD]/serde) +[COMPILING] wasmtime-environ v0.0.0 ([CWD]/wasmtime-environ) +[FINISHED] dev [..] +", + ) + .run(); +}