}
let feats = cx.resolve.features(unit.pkg.package_id());
- cx.compilation.cfgs.entry(unit.pkg.package_id().clone())
- .or_insert_with(HashSet::new)
- .extend(feats.iter().map(|feat| format!("feature=\"{}\"", feat)));
+ if !feats.is_empty() {
+ cx.compilation.cfgs.entry(unit.pkg.package_id().clone()).or_insert_with(|| {
+ feats.iter().map(|feat| format!("feature=\"{}\"", feat)).collect()
+ });
+ }
let rustdocflags = cx.rustdocflags_args(&unit)?;
if !rustdocflags.is_empty() {
cx.compilation.rustdocflags.entry(unit.pkg.package_id().clone())
- .or_insert_with(Vec::new)
- .extend(rustdocflags);
+ .or_insert(rustdocflags);
}
output_depinfo(&mut cx, unit)?;
assert_that(p.cargo("test").arg("--doc").env("RUSTDOCFLAGS", "--cfg do_not_choke"),
execs().with_status(0));
}
+
+#[test]
+fn rustdocflags_passed_to_rustdoc_through_cargo_test_only_once() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ "#)
+ .file("src/lib.rs", "")
+ .build();
+
+ assert_that(p.cargo("test").arg("--doc").env("RUSTDOCFLAGS", "--markdown-no-toc"),
+ execs().with_status(0));
+}