mirror of
https://github.com/rust-lang/cargo
synced 2024-10-13 19:22:33 +00:00
parent
cafc37f135
commit
3dbae343ac
|
@ -5,7 +5,7 @@ use std::path::PathBuf;
|
|||
use semver::Version;
|
||||
use lazycell::LazyCell;
|
||||
|
||||
use core::{Package, PackageId, Target, TargetKind};
|
||||
use core::{Feature, Package, PackageId, Target, TargetKind};
|
||||
use util::{self, join_paths, process, CargoResult, Config, ProcessBuilder};
|
||||
use super::BuildContext;
|
||||
|
||||
|
@ -93,12 +93,23 @@ impl<'cfg> Compilation<'cfg> {
|
|||
|
||||
/// See `process`.
|
||||
pub fn rustc_process(&self, pkg: &Package) -> CargoResult<ProcessBuilder> {
|
||||
self.fill_env(self.rustc_process.clone(), pkg, true)
|
||||
let mut p = self.fill_env(self.rustc_process.clone(), pkg, true)?;
|
||||
let manifest = pkg.manifest();
|
||||
if manifest.features().is_enabled(Feature::edition()) {
|
||||
p.arg(format!("--edition={}", manifest.edition()));
|
||||
}
|
||||
Ok(p)
|
||||
}
|
||||
|
||||
/// See `process`.
|
||||
pub fn rustdoc_process(&self, pkg: &Package) -> CargoResult<ProcessBuilder> {
|
||||
self.fill_env(process(&*self.config.rustdoc()?), pkg, false)
|
||||
let mut p = self.fill_env(process(&*self.config.rustdoc()?), pkg, false)?;
|
||||
let manifest = pkg.manifest();
|
||||
if manifest.features().is_enabled(Feature::edition()) {
|
||||
p.arg("-Zunstable-options");
|
||||
p.arg(format!("--edition={}", &manifest.edition()));
|
||||
}
|
||||
Ok(p)
|
||||
}
|
||||
|
||||
/// See `process`.
|
||||
|
|
|
@ -10,7 +10,7 @@ use serde_json;
|
|||
|
||||
use core::profiles::{Lto, Profile};
|
||||
use core::shell::ColorChoice;
|
||||
use core::{Feature, PackageId, Target};
|
||||
use core::{PackageId, Target};
|
||||
use util::errors::{CargoResult, CargoResultExt, Internal};
|
||||
use util::paths;
|
||||
use util::{self, machine_message, Freshness, ProcessBuilder};
|
||||
|
@ -596,13 +596,6 @@ fn rustdoc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoResult
|
|||
rustdoc.arg("--cfg").arg(&format!("feature=\"{}\"", feat));
|
||||
}
|
||||
|
||||
let manifest = unit.pkg.manifest();
|
||||
|
||||
if manifest.features().is_enabled(Feature::edition()) {
|
||||
rustdoc.arg("-Zunstable-options");
|
||||
rustdoc.arg(format!("--edition={}", &manifest.edition()));
|
||||
}
|
||||
|
||||
if let Some(ref args) = bcx.extra_args_for(unit) {
|
||||
rustdoc.args(args);
|
||||
}
|
||||
|
@ -739,11 +732,6 @@ fn build_base_args<'a, 'cfg>(
|
|||
cmd.arg("-C").arg(format!("panic={}", panic));
|
||||
}
|
||||
}
|
||||
let manifest = unit.pkg.manifest();
|
||||
|
||||
if manifest.features().is_enabled(Feature::edition()) {
|
||||
cmd.arg(format!("--edition={}", manifest.edition()));
|
||||
}
|
||||
|
||||
// Disable LTO for host builds as prefer_dynamic and it are mutually
|
||||
// exclusive.
|
||||
|
|
|
@ -1508,6 +1508,13 @@ fn doc_edition() {
|
|||
.with_status(0)
|
||||
.with_stderr_contains("[RUNNING] `rustdoc [..]-Zunstable-options --edition=2018[..]"),
|
||||
);
|
||||
|
||||
assert_that(
|
||||
p.cargo("test -v").masquerade_as_nightly_cargo(),
|
||||
execs()
|
||||
.with_status(0)
|
||||
.with_stderr_contains("[RUNNING] `rustdoc [..]-Zunstable-options --edition=2018[..]")
|
||||
);
|
||||
}
|
||||
|
||||
// Tests an issue where depending on different versions of the same crate depending on `cfg`s
|
||||
|
|
|
@ -1122,14 +1122,10 @@ fn test_edition() {
|
|||
// --edition is still in flux and we're not passing -Zunstable-options
|
||||
// from Cargo so it will probably error. Only partially match the output
|
||||
// until stuff stabilizes
|
||||
.with_stderr_contains(format!("\
|
||||
[COMPILING] foo v0.0.1 ({url})
|
||||
[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib \
|
||||
--emit=dep-info,link --edition=2018 -C debuginfo=2 \
|
||||
-C metadata=[..] \
|
||||
--out-dir [..] \
|
||||
-L dependency={dir}[/]target[/]debug[/]deps`
|
||||
", dir = p.root().display(), url = p.url())),
|
||||
.with_stderr_contains("\
|
||||
[COMPILING] foo v0.0.1 ([..])
|
||||
[RUNNING] `rustc [..]--edition=2018 [..]
|
||||
"),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1156,14 +1152,10 @@ fn test_edition_missing() {
|
|||
// --edition is still in flux and we're not passing -Zunstable-options
|
||||
// from Cargo so it will probably error. Only partially match the output
|
||||
// until stuff stabilizes
|
||||
.with_stderr_contains(format!("\
|
||||
[COMPILING] foo v0.0.1 ({url})
|
||||
[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib \
|
||||
--emit=dep-info,link --edition=2015 -C debuginfo=2 \
|
||||
-C metadata=[..] \
|
||||
--out-dir [..] \
|
||||
-L dependency={dir}[/]target[/]debug[/]deps`
|
||||
", dir = p.root().display(), url = p.url())),
|
||||
.with_stderr_contains("\
|
||||
[COMPILING] foo v0.0.1 ([..])
|
||||
[RUNNING] `rustc [..]--edition=2015 [..]
|
||||
"),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue