Skip to content

Commit 6354bb3

Browse files
committed
Auto merge of #12908 - weihanglo:profile-merge-trim-paths, r=epage
fix: merge `trim-paths` from different profiles
2 parents 5613aac + 7535971 commit 6354bb3

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3007,6 +3007,10 @@ impl TomlProfile {
30073007
if let Some(v) = &profile.strip {
30083008
self.strip = Some(v.clone());
30093009
}
3010+
3011+
if let Some(v) = &profile.trim_paths {
3012+
self.trim_paths = Some(v.clone())
3013+
}
30103014
}
30113015
}
30123016

tests/testsuite/profile_trim_paths.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,41 @@ fn multiple_options() {
165165
.run();
166166
}
167167

168+
#[cargo_test(nightly, reason = "-Zremap-path-scope is unstable")]
169+
fn profile_merge_works() {
170+
let p = project()
171+
.file(
172+
"Cargo.toml",
173+
r#"
174+
[package]
175+
name = "foo"
176+
version = "0.0.1"
177+
178+
[profile.dev]
179+
trim-paths = ["macro"]
180+
181+
[profile.custom]
182+
inherits = "dev"
183+
trim-paths = ["diagnostics"]
184+
"#,
185+
)
186+
.file("src/lib.rs", "")
187+
.build();
188+
189+
p.cargo("build -v -Ztrim-paths --profile custom")
190+
.masquerade_as_nightly_cargo(&["-Ztrim-paths"])
191+
.with_stderr(
192+
"\
193+
[COMPILING] foo v0.0.1 ([CWD])
194+
[RUNNING] `rustc [..]\
195+
-Zremap-path-scope=diagnostics \
196+
--remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
197+
--remap-path-prefix=[CWD]= [..]
198+
[FINISHED] custom [..]",
199+
)
200+
.run();
201+
}
202+
168203
#[cargo_test(nightly, reason = "-Zremap-path-scope is unstable")]
169204
fn registry_dependency() {
170205
Package::new("bar", "0.0.1")

0 commit comments

Comments
 (0)