File tree Expand file tree Collapse file tree 2 files changed +33
-8
lines changed Expand file tree Collapse file tree 2 files changed +33
-8
lines changed Original file line number Diff line number Diff line change @@ -92,14 +92,17 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
92
92
return Ok ( ( ) ) ;
93
93
}
94
94
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
+ } ;
103
106
104
107
compile_opts. target_rustc_crate_types = if crate_types. is_empty ( ) {
105
108
None
Original file line number Diff line number Diff line change @@ -855,3 +855,25 @@ fn precedence() {
855
855
"# ] ] )
856
856
. run ( ) ;
857
857
}
858
+
859
+ #[ cargo_test]
860
+ fn build_with_duplicate_crate_types ( ) {
861
+ let p = project ( ) . file ( "src/lib.rs" , "" ) . build ( ) ;
862
+
863
+ p. cargo ( "rustc -v --crate-type staticlib --crate-type staticlib" )
864
+ . with_stderr_data ( str![ [ r#"
865
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
866
+ [RUNNING] `rustc [..] --crate-type staticlib --emit[..]
867
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
868
+
869
+ "# ] ] )
870
+ . run ( ) ;
871
+
872
+ p. cargo ( "rustc -v --crate-type staticlib --crate-type staticlib" )
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
876
+
877
+ "# ] ] )
878
+ . run ( ) ;
879
+ }
You can’t perform that action at this time.
0 commit comments