Skip to content

Commit 36de02f

Browse files
committed
fix: deduplicate and update snapshot
1 parent b8849dc commit 36de02f

File tree

2 files changed

+17
-42
lines changed

2 files changed

+17
-42
lines changed

src/bin/cargo/commands/rustc.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,17 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
9292
return Ok(());
9393
}
9494

95-
let crate_types = args
96-
.get_many::<String>(CRATE_TYPE_ARG_NAME)
97-
.into_iter()
98-
.flatten()
99-
.flat_map(|s| s.split(','))
100-
.filter(|s| !s.is_empty())
101-
.map(String::from)
102-
.collect::<Vec<String>>();
95+
let crate_types = {
96+
let mut seen = std::collections::HashSet::new();
97+
args.get_many::<String>(CRATE_TYPE_ARG_NAME)
98+
.into_iter()
99+
.flatten()
100+
.flat_map(|s| s.split(','))
101+
.filter(|s| !s.is_empty())
102+
.map(String::from)
103+
.filter(|s| seen.insert(s.clone()))
104+
.collect::<Vec<String>>()
105+
};
103106

104107
compile_opts.target_rustc_crate_types = if crate_types.is_empty() {
105108
None

tests/testsuite/rustc.rs

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -860,48 +860,20 @@ fn precedence() {
860860
fn build_with_duplicate_crate_types() {
861861
let p = project().file("src/lib.rs", "").build();
862862

863-
p
864-
.cargo("rustc -v --crate-type staticlib --crate-type staticlib")
863+
p.cargo("rustc -v --crate-type staticlib --crate-type staticlib")
865864
.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>.
878865
[COMPILING] foo v0.0.1 ([ROOT]/foo)
879-
[RUNNING] `rustc [..]future-incompat --crate-type staticlib --crate-type staticlib --emit[..]
866+
[RUNNING] `rustc [..] --crate-type staticlib --emit[..]
880867
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
881868
882869
"#]])
883870
.run();
884871

885872
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
873+
.with_stderr_data(str![[r#"
874+
[FRESH] foo v0.0.1 ([ROOT]/foo)
875+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
904876
905877
"#]])
906-
.run();
878+
.run();
907879
}

0 commit comments

Comments
 (0)