Skip to content

Commit 16ffc05

Browse files
committed
Auto merge of #4976 - mbrubeck:doc-check, r=alexcrichton
cargo doc: Generate rmeta files for dependencies instead of compiling rlibs This makes `cargo doc` require only metadata (`.rmeta` files) instead of compiled libraries (`.rlib` files) for dependencies. This makes `cargo doc` faster in cases where rlibs are not already built and/or metadata is already available. Unfortunately, this is not a win for every workflow. In the case where the user has already compiled but has not generated metadata, it makes `cargo doc` do extra work. This is probably a common case, though tools like RLS and `cargo check` mean that many developers *will* have up-to-date metadata available. It would become an unequivocal win if `cargo build` and `cargo check` re-used shared metadata (#3501). For now, starting from a clean working directory, the following sequences of commands will become: * `cargo doc`: faster * `cargo build; cargo doc`: slower * `cargo check; cargo doc`: faster * `cargo build --release; cargo doc`: faster * `cargo check; cargo build; cargo doc`: no change
2 parents df089f4 + 9bb9dbd commit 16ffc05

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/cargo/ops/cargo_rustc/context.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
940940
ret.push(Unit {
941941
pkg: dep,
942942
target: lib,
943-
profile: self.lib_profile(),
943+
profile: self.lib_or_check_profile(unit, lib),
944944
kind: unit.kind.for_target(lib),
945945
});
946946
if self.build_config.doc_all {
@@ -1055,11 +1055,12 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
10551055
}
10561056

10571057
pub fn lib_or_check_profile(&self, unit: &Unit, target: &Target) -> &'a Profile {
1058-
if unit.profile.check && !target.is_custom_build() && !target.for_host() {
1059-
&self.profiles.check
1060-
} else {
1061-
self.lib_profile()
1058+
if !target.is_custom_build() && !target.for_host() {
1059+
if unit.profile.check || (unit.profile.doc && !unit.profile.test) {
1060+
return &self.profiles.check
1061+
}
10621062
}
1063+
self.lib_profile()
10631064
}
10641065

10651066
pub fn build_script_profile(&self, _pkg: &PackageId) -> &'a Profile {

0 commit comments

Comments
 (0)