File tree Expand file tree Collapse file tree 1 file changed +130
-0
lines changed Expand file tree Collapse file tree 1 file changed +130
-0
lines changed Original file line number Diff line number Diff line change @@ -2342,3 +2342,133 @@ fn calc_bin_artifact_fingerprint() {
2342
2342
)
2343
2343
. run ( ) ;
2344
2344
}
2345
+
2346
+ #[ cargo_test]
2347
+ fn same_target_transitive_dependency_deduplication ( ) {
2348
+ // See:
2349
+ // - https://github.com/rust-lang/cargo/issues/10837
2350
+ // - https://github.com/rust-lang/cargo/issues/11463
2351
+ let target = rustc_host ( ) ;
2352
+ let p = project ( )
2353
+ . file (
2354
+ "Cargo.toml" ,
2355
+ & format ! (
2356
+ r#"
2357
+ [package]
2358
+ name = "foo"
2359
+ version = "0.1.0"
2360
+ edition = "2021"
2361
+
2362
+ [dependencies]
2363
+ a = {{ workspace = true }}
2364
+ bar = {{ path = "bar", artifact = "bin", target = "{target}" }}
2365
+
2366
+ [workspace.dependencies]
2367
+ a = {{ path = "a" }}
2368
+ b = {{ path = "b" }}
2369
+ c = {{ path = "c" }}
2370
+ "#
2371
+ ) ,
2372
+ )
2373
+ . file (
2374
+ "src/main.rs" ,
2375
+ r#"
2376
+ fn main() {}
2377
+ "# ,
2378
+ )
2379
+ . file (
2380
+ "bar/Cargo.toml" ,
2381
+ r#"
2382
+ [package]
2383
+ name = "bar"
2384
+ version = "0.1.0"
2385
+
2386
+ [dependencies]
2387
+ a = { workspace = true, features = ["feature"] }
2388
+ "# ,
2389
+ )
2390
+ . file (
2391
+ "bar/src/main.rs" ,
2392
+ r#"
2393
+ fn main() {}
2394
+ "# ,
2395
+ )
2396
+ . file (
2397
+ "a/Cargo.toml" ,
2398
+ r#"
2399
+ [package]
2400
+ name = "a"
2401
+ version = "0.1.0"
2402
+ edition = "2021"
2403
+
2404
+ [dependencies]
2405
+ b = { workspace = true }
2406
+ c = { workspace = true }
2407
+
2408
+ [features]
2409
+ feature = ["c/feature"]
2410
+ "# ,
2411
+ )
2412
+ . file (
2413
+ "a/src/lib.rs" ,
2414
+ r#"
2415
+ use b::Trait as _;
2416
+
2417
+ pub fn use_b_trait(x: &impl c::Trait) {
2418
+ x.b();
2419
+ }
2420
+ "# ,
2421
+ )
2422
+ . file (
2423
+ "b/Cargo.toml" ,
2424
+ r#"
2425
+ [package]
2426
+ name = "b"
2427
+ version = "0.1.0"
2428
+
2429
+ [dependencies]
2430
+ c = { workspace = true }
2431
+ "# ,
2432
+ )
2433
+ . file (
2434
+ "b/src/lib.rs" ,
2435
+ r#"
2436
+ pub trait Trait {
2437
+ fn b(&self) {}
2438
+ }
2439
+
2440
+ impl<T: c::Trait> Trait for T {}
2441
+ "# ,
2442
+ )
2443
+ . file (
2444
+ "c/Cargo.toml" ,
2445
+ r#"
2446
+ [package]
2447
+ name = "c"
2448
+ version = "0.1.0"
2449
+
2450
+ [features]
2451
+ feature = []
2452
+ "# ,
2453
+ )
2454
+ . file (
2455
+ "c/src/lib.rs" ,
2456
+ r#"
2457
+ pub trait Trait {}
2458
+ "# ,
2459
+ )
2460
+ . build ( ) ;
2461
+ p. cargo ( "build -Z bindeps" )
2462
+ . masquerade_as_nightly_cargo ( & [ "bindeps" ] )
2463
+ . with_stderr (
2464
+ "\
2465
+ [COMPILING] c v0.1.0 ([CWD]/c)
2466
+ [COMPILING] b v0.1.0 ([CWD]/b)
2467
+ [COMPILING] a v0.1.0 ([CWD]/a)
2468
+ [COMPILING] bar v0.1.0 ([CWD]/bar)
2469
+ [COMPILING] foo v0.1.0 ([CWD])
2470
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
2471
+ " ,
2472
+ )
2473
+ . run ( ) ;
2474
+ }
You can’t perform that action at this time.
0 commit comments