Skip to content

Commit b8849dc

Browse files
committed
add test for duplicate crate-type arg
1 parent 3e96f1a commit b8849dc

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/testsuite/rustc.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,3 +855,53 @@ fn precedence() {
855855
"#]])
856856
.run();
857857
}
858+
859+
#[cargo_test]
860+
fn build_with_duplicate_crate_types() {
861+
let p = project().file("src/lib.rs", "").build();
862+
863+
p
864+
.cargo("rustc -v --crate-type staticlib --crate-type staticlib")
865+
.with_stderr_data(str![[r#"
866+
[WARNING] output filename collision.
867+
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)`.
868+
Colliding filename is: [ROOT]/foo/target/debug/deps/libfoo-[HASH].a
869+
The targets should have unique names.
870+
Consider changing their names to be unique or compiling them separately.
871+
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
872+
[WARNING] output filename collision.
873+
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)`.
874+
Colliding filename is: [ROOT]/foo/target/debug/libfoo.a
875+
The targets should have unique names.
876+
Consider changing their names to be unique or compiling them separately.
877+
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
878+
[COMPILING] foo v0.0.1 ([ROOT]/foo)
879+
[RUNNING] `rustc [..]future-incompat --crate-type staticlib --crate-type staticlib --emit[..]
880+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
881+
882+
"#]])
883+
.run();
884+
885+
p.cargo("rustc -v --crate-type staticlib --crate-type staticlib")
886+
.with_status(101)
887+
.with_stderr_data(str![[r#"
888+
[WARNING] output filename collision.
889+
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)`.
890+
Colliding filename is: [ROOT]/foo/target/debug/deps/libfoo-[HASH].a
891+
The targets should have unique names.
892+
Consider changing their names to be unique or compiling them separately.
893+
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
894+
[WARNING] output filename collision.
895+
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)`.
896+
Colliding filename is: [ROOT]/foo/target/debug/libfoo.a
897+
The targets should have unique names.
898+
Consider changing their names to be unique or compiling them separately.
899+
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
900+
901+
thread 'main' panicked at src/cargo/core/compiler/fingerprint/mod.rs:1180:13:
902+
assertion failed: mtimes.insert(output.clone(), mtime).is_none()
903+
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
904+
905+
"#]])
906+
.run();
907+
}

0 commit comments

Comments
 (0)