Skip to content

Commit 02625ba

Browse files
committed
make sure we use the check profile where possible for lib deps.
Fixes #3418
1 parent ddb5c32 commit 02625ba

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/cargo/ops/cargo_rustc/context.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
169169
kind: Kind)
170170
-> CargoResult<()> {
171171
let rustflags = env_args(self.config,
172-
&self.build_config,
173-
kind,
174-
"RUSTFLAGS")?;
172+
&self.build_config,
173+
kind,
174+
"RUSTFLAGS")?;
175175
let mut process = self.config.rustc()?.process();
176176
process.arg("-")
177177
.arg("--crate-name").arg("___")
@@ -613,17 +613,10 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
613613
match self.get_package(id) {
614614
Ok(pkg) => {
615615
pkg.targets().iter().find(|t| t.is_lib()).map(|t| {
616-
let profile = if unit.profile.check &&
617-
!t.is_custom_build()
618-
&& !t.for_host() {
619-
&self.profiles.check
620-
} else {
621-
self.lib_profile()
622-
};
623616
let unit = Unit {
624617
pkg: pkg,
625618
target: t,
626-
profile: profile,
619+
profile: self.lib_or_check_profile(unit, t),
627620
kind: unit.kind.for_target(t),
628621
};
629622
Ok(unit)
@@ -780,7 +773,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
780773
Unit {
781774
pkg: unit.pkg,
782775
target: t,
783-
profile: self.lib_profile(),
776+
profile: self.lib_or_check_profile(unit, t),
784777
kind: unit.kind.for_target(t),
785778
}
786779
})
@@ -848,6 +841,14 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
848841
}
849842
}
850843

844+
pub fn lib_or_check_profile(&self, unit: &Unit, target: &Target) -> &'a Profile {
845+
if unit.profile.check && !target.is_custom_build() && !target.for_host() {
846+
&self.profiles.check
847+
} else {
848+
self.lib_profile()
849+
}
850+
}
851+
851852
pub fn build_script_profile(&self, _pkg: &PackageId) -> &'a Profile {
852853
// TODO: should build scripts always be built with the same library
853854
// profile? How is this controlled at the CLI layer?

0 commit comments

Comments
 (0)