From b8849dcb749a8b0e3ae814b4ab45b5b771ee5395 Mon Sep 17 00:00:00 2001 From: Frank Wang <1454884738@qq.com> Date: Sat, 15 Mar 2025 17:51:18 -0500 Subject: [PATCH] add test for duplicate crate-type arg --- tests/testsuite/rustc.rs | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/testsuite/rustc.rs b/tests/testsuite/rustc.rs index 124877f54..ea3828cb9 100644 --- a/tests/testsuite/rustc.rs +++ b/tests/testsuite/rustc.rs @@ -855,3 +855,53 @@ fn precedence() { "#]]) .run(); } + +#[cargo_test] +fn build_with_duplicate_crate_types() { + let p = project().file("src/lib.rs", "").build(); + + p + .cargo("rustc -v --crate-type staticlib --crate-type staticlib") + .with_stderr_data(str![[r#" +[WARNING] output filename collision. +The lib target `foo` in package `foo v0.0.1 ([ROOT]/foo)` has the same output filename as the lib target `foo` in package `foo v0.0.1 ([ROOT]/foo)`. +Colliding filename is: [ROOT]/foo/target/debug/deps/libfoo-[HASH].a +The targets should have unique names. +Consider changing their names to be unique or compiling them separately. +This may become a hard error in the future; see . +[WARNING] output filename collision. +The lib target `foo` in package `foo v0.0.1 ([ROOT]/foo)` has the same output filename as the lib target `foo` in package `foo v0.0.1 ([ROOT]/foo)`. +Colliding filename is: [ROOT]/foo/target/debug/libfoo.a +The targets should have unique names. +Consider changing their names to be unique or compiling them separately. +This may become a hard error in the future; see . +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `rustc [..]future-incompat --crate-type staticlib --crate-type staticlib --emit[..] +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) + .run(); + + p.cargo("rustc -v --crate-type staticlib --crate-type staticlib") + .with_status(101) + .with_stderr_data(str![[r#" +[WARNING] output filename collision. +The lib target `foo` in package `foo v0.0.1 ([ROOT]/foo)` has the same output filename as the lib target `foo` in package `foo v0.0.1 ([ROOT]/foo)`. +Colliding filename is: [ROOT]/foo/target/debug/deps/libfoo-[HASH].a +The targets should have unique names. +Consider changing their names to be unique or compiling them separately. +This may become a hard error in the future; see . +[WARNING] output filename collision. +The lib target `foo` in package `foo v0.0.1 ([ROOT]/foo)` has the same output filename as the lib target `foo` in package `foo v0.0.1 ([ROOT]/foo)`. +Colliding filename is: [ROOT]/foo/target/debug/libfoo.a +The targets should have unique names. +Consider changing their names to be unique or compiling them separately. +This may become a hard error in the future; see . + +thread 'main' panicked at src/cargo/core/compiler/fingerprint/mod.rs:1180:13: +assertion failed: mtimes.insert(output.clone(), mtime).is_none() +[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace + +"#]]) + .run(); +}