Skip to content

Commit aa6f442

Browse files
committed
fix: deduplicate and update snapshot
1 parent 68bfc2b commit aa6f442

File tree

2 files changed

+12
-21
lines changed

2 files changed

+12
-21
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: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -863,20 +863,8 @@ fn build_with_duplicate_crate_types() {
863863
// Test with duplicate crate types specified directly
864864
p.cargo("rustc -v --crate-type staticlib --crate-type staticlib")
865865
.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>.
878866
[COMPILING] foo v0.0.1 ([ROOT]/foo)
879-
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type staticlib --crate-type staticlib --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=dcf68b69dfd9ec09 -C extra-filename=-39c09aba69cca326 --out-dir [ROOT]/foo/target/debug/deps -L dependency=[ROOT]/foo/target/debug/deps`
867+
[RUNNING] `rustc [..]future-incompat --crate-type staticlib --emit[..]
880868
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
881869
882870
"#]])

0 commit comments

Comments
 (0)