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;
/// 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`.
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};
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);
}
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.
.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
// --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 [..]
+"),
);
}
// --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 [..]
+"),
);
}