Skip to content

Commit 77855f3

Browse files
committed
Use consolidated fingerprint directory for rustdoc.
1 parent d1c0a9d commit 77855f3

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

src/cargo/core/compiler/context/compilation_files.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ fn hash_rustc_version(bcx: &BuildContext<'_, '_>, hasher: &mut StableHasher) {
598598

599599
/// Returns whether or not this unit should use a metadata hash.
600600
fn should_use_metadata(bcx: &BuildContext<'_, '_>, unit: &Unit) -> bool {
601-
if unit.mode.is_doc_test() {
601+
if unit.mode.is_doc_test() || unit.mode.is_doc() {
602602
// Doc tests do not have metadata.
603603
return false;
604604
}

tests/testsuite/doc.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,10 +863,44 @@ fn features() {
863863
r#"#[cfg(feature = "bar")] pub fn bar() {}"#,
864864
)
865865
.build();
866-
p.cargo("doc --features foo").run();
866+
p.cargo("doc --features foo")
867+
.with_stderr(
868+
"\
869+
[COMPILING] bar v0.0.1 [..]
870+
[DOCUMENTING] bar v0.0.1 [..]
871+
[DOCUMENTING] foo v0.0.1 [..]
872+
[FINISHED] [..]
873+
",
874+
)
875+
.run();
867876
assert!(p.root().join("target/doc").is_dir());
868877
assert!(p.root().join("target/doc/foo/fn.foo.html").is_file());
869878
assert!(p.root().join("target/doc/bar/fn.bar.html").is_file());
879+
// Check that turning the feature off will remove the files.
880+
p.cargo("doc")
881+
.with_stderr(
882+
"\
883+
[COMPILING] bar v0.0.1 [..]
884+
[DOCUMENTING] bar v0.0.1 [..]
885+
[DOCUMENTING] foo v0.0.1 [..]
886+
[FINISHED] [..]
887+
",
888+
)
889+
.run();
890+
// assert!(!p.root().join("target/doc/foo/fn.foo.html").is_file());
891+
// assert!(!p.root().join("target/doc/bar/fn.bar.html").is_file());
892+
// And switching back will rebuild and bring them back.
893+
p.cargo("doc --features foo")
894+
.with_stderr(
895+
"\
896+
[DOCUMENTING] bar v0.0.1 [..]
897+
[DOCUMENTING] foo v0.0.1 [..]
898+
[FINISHED] [..]
899+
",
900+
)
901+
.run();
902+
assert!(p.root().join("target/doc/foo/fn.foo.html").is_file());
903+
assert!(p.root().join("target/doc/bar/fn.bar.html").is_file());
870904
}
871905

872906
#[cargo_test]

0 commit comments

Comments
 (0)