File tree 1 file changed +48
-0
lines changed
1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -4541,6 +4541,54 @@ fn cdylib_final_outputs() {
4541
4541
}
4542
4542
}
4543
4543
4544
+ #[ cargo_test]
4545
+ // NOTE: Windows MSVC and wasm32-unknown-emscripten do not use metadata. Skip them.
4546
+ // See <https://github.com/rust-lang/cargo/issues/9325#issuecomment-1030662699>
4547
+ #[ cfg( not( all( target_os = "windows" , target_env = "msvc" ) ) ) ]
4548
+ fn no_dep_info_collision_when_cdylib_and_bin_coexist ( ) {
4549
+ let p = project ( )
4550
+ . file (
4551
+ "Cargo.toml" ,
4552
+ r#"
4553
+ [package]
4554
+ name = "foo"
4555
+ version = "1.0.0"
4556
+
4557
+ [lib]
4558
+ crate-type = ["cdylib"]
4559
+ "# ,
4560
+ )
4561
+ . file ( "src/main.rs" , "fn main() {}" )
4562
+ . file ( "src/lib.rs" , "" )
4563
+ . build ( ) ;
4564
+
4565
+ p. cargo ( "build -v" )
4566
+ . with_stderr_unordered (
4567
+ "\
4568
+ [COMPILING] foo v1.0.0 ([CWD])
4569
+ [RUNNING] `rustc [..] --crate-type bin [..] -C metadata=[..]`
4570
+ [RUNNING] `rustc [..] --crate-type cdylib [..] -C metadata=[..]`
4571
+ [FINISHED] [..]
4572
+ " ,
4573
+ )
4574
+ . run ( ) ;
4575
+
4576
+ let deps_dir = p. target_debug_dir ( ) . join ( "deps" ) ;
4577
+ assert ! ( deps_dir. join( "foo.d" ) . exists( ) ) ;
4578
+ let dep_info_count = deps_dir
4579
+ . read_dir ( )
4580
+ . unwrap ( )
4581
+ . filter ( |e| {
4582
+ let filename = e. as_ref ( ) . unwrap ( ) . file_name ( ) ;
4583
+ let filename = filename. to_str ( ) . unwrap ( ) ;
4584
+ filename. starts_with ( "foo" ) && filename. ends_with ( ".d" )
4585
+ } )
4586
+ . count ( ) ;
4587
+ // cdylib -> foo.d
4588
+ // bin -> foo-<meta>.d
4589
+ assert_eq ! ( dep_info_count, 2 ) ;
4590
+ }
4591
+
4544
4592
#[ cargo_test]
4545
4593
fn deterministic_cfg_flags ( ) {
4546
4594
// This bug is non-deterministic.
You can’t perform that action at this time.
0 commit comments