mirror of
https://github.com/rust-lang/cargo
synced 2024-10-02 14:04:23 +00:00
Don't accumulate feature and rustdoc flags twice (fixes #4790)
This commit is contained in:
parent
3992e5259b
commit
c057d9e206
|
@ -226,14 +226,15 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>,
|
|||
}
|
||||
|
||||
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)?;
|
||||
|
|
|
@ -105,3 +105,18 @@ fn rustdocflags_passed_to_rustdoc_through_cargo_test() {
|
|||
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));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue