diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index f6d6c5ea5e1..46f76f42a6e 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -3007,6 +3007,10 @@ impl TomlProfile { if let Some(v) = &profile.strip { self.strip = Some(v.clone()); } + + if let Some(v) = &profile.trim_paths { + self.trim_paths = Some(v.clone()) + } } } diff --git a/tests/testsuite/profile_trim_paths.rs b/tests/testsuite/profile_trim_paths.rs index f264253c936..1d24c159be7 100644 --- a/tests/testsuite/profile_trim_paths.rs +++ b/tests/testsuite/profile_trim_paths.rs @@ -165,6 +165,41 @@ fn multiple_options() { .run(); } +#[cargo_test(nightly, reason = "-Zremap-path-scope is unstable")] +fn profile_merge_works() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + + [profile.dev] + trim-paths = ["macro"] + + [profile.custom] + inherits = "dev" + trim-paths = ["diagnostics"] + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("build -v -Ztrim-paths --profile custom") + .masquerade_as_nightly_cargo(&["-Ztrim-paths"]) + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc [..]\ + -Zremap-path-scope=diagnostics \ + --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \ + --remap-path-prefix=[CWD]= [..] +[FINISHED] custom [..]", + ) + .run(); +} + #[cargo_test(nightly, reason = "-Zremap-path-scope is unstable")] fn registry_dependency() { Package::new("bar", "0.0.1")