arg_args: Vec<String>,
flag_all: bool,
flag_exclude: Vec<String>,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--no-fail-fast Run all benchmarks regardless of failure
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
All of the trailing arguments are passed to the benchmark binaries generated
for filtering benchmarks and generally providing options configuring how they
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
let ws = Workspace::new(&root, config)?;
flag_frozen: bool,
flag_all: bool,
flag_exclude: Vec<String>,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--message-format FMT Error format: human, json [default: human]
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
If the --package argument is given, then SPEC is a package id specification
which indicates which package should be built. If it is not given, then the
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
let ws = Workspace::new(&root, config)?;
arg_args: Vec<String>,
flag_locked: bool,
flag_frozen: bool,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
const USAGE: &'static str = "
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
Some common cargo commands are (see all commands with --list):
build Compile the current project
flags.flag_quiet,
&flags.flag_color,
flags.flag_frozen,
- flags.flag_locked)?;
+ flags.flag_locked,
+ &flags.flag_z)?;
init_git_transports(config);
let _token = cargo::util::job::setup();
--message-format FMT Error format: human, json [default: human]
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
If the --package argument is given, then SPEC is a package id specification
which indicates which package should be built. If it is not given, then the
flag_frozen: bool,
flag_all: bool,
flag_exclude: Vec<String>,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub fn execute(options: Options, config: &Config) -> CliResult {
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
let ws = Workspace::new(&root, config)?;
flag_release: bool,
flag_frozen: bool,
flag_locked: bool,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
If the --package argument is given, then SPEC is a package id specification
which indicates which package's artifacts should be cleaned out. If it is not
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
let opts = ops::CleanOptions {
flag_frozen: bool,
flag_locked: bool,
flag_all: bool,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--message-format FMT Error format: human, json [default: human]
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
By default the documentation for the local package and all dependencies is
built. The output is all placed in `target/doc` in rustdoc's usual format.
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
let ws = Workspace::new(&root, config)?;
flag_color: Option<String>,
flag_frozen: bool,
flag_locked: bool,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
If a lockfile is available, this command will ensure that all of the git
dependencies and/or registries dependencies are downloaded and locally
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
let ws = Workspace::new(&root, config)?;
ops::fetch(&ws)?;
flag_color: Option<String>,
flag_frozen: bool,
flag_locked: bool,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
";
pub fn execute(options: Options, config: &Config) -> CliResult {
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
let ws = Workspace::new(&root, config)?;
flag_color: Option<String>,
flag_frozen: bool,
flag_locked: bool,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
";
pub fn execute(options: Options, config: &Config) -> CliResult {
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let Options { flag_url: url, flag_reference: reference, .. } = options;
let url = url.to_url()?;
flag_vcs: Option<ops::VersionControl>,
flag_frozen: bool,
flag_locked: bool,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
";
pub fn execute(options: Options, config: &Config) -> CliResult {
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let Options { flag_bin, flag_lib, arg_path, flag_name, flag_vcs, .. } = options;
flag_rev: Option<String>,
flag_path: Option<String>,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
This command manages Cargo's local set of installed binary crates. Only packages
which have [[bin]] targets can be installed, and all binaries are installed into
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let compile_opts = ops::CompileOptions {
config: config,
flag_color: Option<String>,
flag_frozen: bool,
flag_locked: bool,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
";
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let token = match options.arg_token.clone() {
Some(token) => token,
None => {
flag_verbose: u32,
flag_frozen: bool,
flag_locked: bool,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
";
pub fn execute(options: Options, config: &Config) -> CliResult {
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let manifest = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
if options.flag_format_version.is_none() {
flag_vcs: Option<ops::VersionControl>,
flag_frozen: bool,
flag_locked: bool,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
";
pub fn execute(options: Options, config: &Config) -> CliResult {
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let Options { flag_bin, flag_lib, arg_path, flag_name, flag_vcs, .. } = options;
flag_list: bool,
flag_frozen: bool,
flag_locked: bool,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
This command will modify the owners for a package on the specified registry (or
default). Note that owners of a package can upload new versions, yank old
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let opts = ops::OwnersOptions {
krate: options.arg_crate,
token: options.flag_token,
flag_jobs: Option<u32>,
flag_frozen: bool,
flag_locked: bool,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
";
pub fn execute(options: Options, config: &Config) -> CliResult {
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
let ws = Workspace::new(&root, config)?;
ops::package(&ws, &ops::PackageOpts {
flag_locked: bool,
flag_package: Option<String>,
arg_spec: Option<String>,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
Given a <spec> argument, print out the fully qualified package id specifier.
This command will generate an error if <spec> is ambiguous as to which package
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let root = find_root_manifest_for_wd(options.flag_manifest_path.clone(), config.cwd())?;
let ws = Workspace::new(&root, config)?;
flag_dry_run: bool,
flag_frozen: bool,
flag_locked: bool,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
";
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
-
-
+ options.flag_locked,
+ &options.flag_z)?;
let Options {
flag_token: token,
flag_frozen: bool,
flag_locked: bool,
arg_args: Vec<String>,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--message-format FMT Error format: human, json [default: human]
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
If neither `--bin` nor `--example` are given, then if the project only has one
bin target it will be run. Otherwise `--bin` specifies the bin target to run,
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
flag_profile: Option<String>,
flag_frozen: bool,
flag_locked: bool,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--message-format FMT Error format: human, json [default: human]
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
The specified target for the current package (or package specified by SPEC if
provided) will be compiled along with all of its dependencies. The specified
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let root = find_root_manifest_for_wd(options.flag_manifest_path,
config.cwd())?;
flag_all_targets: bool,
flag_frozen: bool,
flag_locked: bool,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--message-format FMT Error format: human, json [default: human]
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
The specified target for the current package (or package specified by SPEC if
provided) will be documented with the specified <opts>... being passed to the
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let root = find_root_manifest_for_wd(options.flag_manifest_path,
config.cwd())?;
flag_frozen: bool,
flag_locked: bool,
arg_query: Vec<String>,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--limit LIMIT Limit the number of results (default: 10, max: 100)
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
";
pub fn execute(options: Options, config: &Config) -> CliResult {
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let Options {
flag_index: index,
flag_host: host, // TODO: Depricated, remove
flag_locked: bool,
flag_all: bool,
flag_exclude: Vec<String>,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--no-fail-fast Run all tests regardless of failure
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
All of the trailing arguments are passed to the test binaries generated for
filtering tests and generally providing options configuring how they run. For
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
let ws = Workspace::new(&root, config)?;
flag_color: Option<String>,
flag_frozen: bool,
flag_locked: bool,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
arg_spec: String,
}
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
The argument SPEC is a package id specification (see `cargo help pkgid`) to
specify which crate should be uninstalled. By default all binaries are
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let root = options.flag_root.as_ref().map(|s| &s[..]);
ops::uninstall(root, &options.arg_spec, &options.flag_bin, config)?;
flag_color: Option<String>,
flag_frozen: bool,
flag_locked: bool,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
This command requires that a `Cargo.lock` already exists as generated by
`cargo build` or related commands.
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
let update_opts = ops::UpdateOptions {
flag_color: Option<String>,
flag_frozen: bool,
flag_locked: bool,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub const USAGE: &'static str = "
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
";
pub fn execute(args: Flags, config: &Config) -> CliResult {
args.flag_quiet,
&args.flag_color,
args.flag_frozen,
- args.flag_locked)?;
+ args.flag_locked,
+ &args.flag_z)?;
let mut contents = String::new();
let filename = args.flag_manifest_path.unwrap_or("Cargo.toml".into());
flag_undo: bool,
flag_frozen: bool,
flag_locked: bool,
+ #[serde(rename = "flag_Z")]
+ flag_z: Vec<String>,
}
pub static USAGE: &'static str = "
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
+ -Z FLAG ... Unstable (nightly-only) flags to Cargo
The yank command removes a previously pushed crate's version from the server's
index. This command does not delete any data, and the crate will still be
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
- options.flag_locked)?;
+ options.flag_locked,
+ &options.flag_z)?;
ops::yank(config,
options.arg_crate,
options.flag_vers,
impl Feature {
$(
pub fn $feature() -> &'static Feature {
- fn get(features: &Features) -> &bool {
- &features.$feature
+ fn get(features: &Features) -> bool {
+ features.$feature
}
static FEAT: Feature = Feature {
name: stringify!($feature),
&FEAT
}
)*
+
+ fn is_enabled(&self, features: &Features) -> bool {
+ (self.get)(features)
+ }
}
impl Features {
pub struct Feature {
name: &'static str,
- get: fn(&Features) -> &bool,
+ get: fn(&Features) -> bool,
}
impl Features {
}
pub fn require(&self, feature: &Feature) -> CargoResult<()> {
- if *(feature.get)(self) {
+ if feature.is_enabled(self) {
Ok(())
} else {
let feature = feature.name.replace("_", "-");
}
}
+/// A parsed represetnation of all unstable flags that Cargo accepts.
+///
+/// Cargo, like `rustc`, accepts a suite of `-Z` flags which are intended for
+/// gating unstable functionality to Cargo. These flags are only available on
+/// the nightly channel of Cargo.
+///
+/// This struct doesn't have quite the same convenience macro that the features
+/// have above, but the procedure should still be relatively stable for adding a
+/// new unstable flag:
+///
+/// 1. First, add a field to this `CliUnstable` structure. All flags are allowed
+/// to have a value as the `-Z` flags are either of the form `-Z foo` or
+/// `-Z foo=bar`, and it's up to you how to parse `bar`.
+///
+/// 2. Add an arm to the match statement in `CliUnstable::add` below to match on
+/// your new flag. The key (`k`) is what you're matching on and the value is
+/// in `v`.
+///
+/// 3. (optional) Add a new parsing function to parse your datatype. As of now
+/// there's an example for `bool`, but more can be added!
+///
+/// 4. In Cargo use `config.cli_unstable()` to get a reference to this structure
+/// and then test for your flag or your value and act accordingly.
+///
+/// If you have any trouble with this, please let us know!
+#[derive(Default, Debug)]
+pub struct CliUnstable {
+ pub print_im_a_teapot: bool,
+}
+
+impl CliUnstable {
+ pub fn parse(&mut self, flags: &[String]) -> CargoResult<()> {
+ if flags.len() > 0 && !nightly_features_allowed() {
+ bail!("the `-Z` flag is only accepted on the nightly channel of Cargo")
+ }
+ for flag in flags {
+ self.add(flag)?;
+ }
+ Ok(())
+ }
+
+ fn add(&mut self, flag: &str) -> CargoResult<()> {
+ let mut parts = flag.splitn(2, '=');
+ let k = parts.next().unwrap();
+ let v = parts.next();
+
+ fn parse_bool(value: Option<&str>) -> CargoResult<bool> {
+ match value {
+ None |
+ Some("yes") => Ok(true),
+ Some("no") => Ok(false),
+ Some(s) => bail!("expected `no` or `yes`, found: {}", s),
+ }
+ }
+
+ match k {
+ "print-im-a-teapot" => self.print_im_a_teapot = parse_bool(v)?,
+ _ => bail!("unknown `-Z` flag specified: {}", k),
+ }
+
+ Ok(())
+ }
+}
+
fn channel() -> String {
env::var("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS").unwrap_or_else(|_| {
::version().cfg_info.map(|c| c.release_channel)
use core::{Dependency, PackageId, Summary, SourceId, PackageIdSpec};
use core::{WorkspaceConfig, Features, Feature};
+use util::Config;
use util::toml::TomlManifest;
use util::errors::*;
Ok(())
}
+
+ // Just a helper function to test out `-Z` flags on Cargo
+ pub fn print_teapot(&self, config: &Config) {
+ if let Some(teapot) = self.im_a_teapot {
+ if config.cli_unstable().print_im_a_teapot {
+ println!("im-a-teapot = {}", teapot);
+ }
+ }
+ }
}
impl VirtualManifest {
pub use self::dependency::Dependency;
-pub use self::features::{Features, Feature};
+pub use self::features::{Features, Feature, CliUnstable};
pub use self::manifest::{EitherManifest, VirtualManifest};
pub use self::manifest::{Manifest, Target, TargetKind, Profile, LibKind, Profiles};
pub use self::package::{Package, PackageSet};
}
} else {
let root_package = ws.current()?;
+ root_package.manifest().print_teapot(ws.config());
let all_features = resolve_all_features(&resolve_with_overrides,
root_package.package_id());
generate_targets(root_package, profiles, mode, filter, &all_features, release)?;
-use std::cell::{RefCell, RefMut, Cell};
+use std::cell::{RefCell, RefMut, Cell, Ref};
use std::collections::HashSet;
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::collections::hash_map::HashMap;
use std::str::FromStr;
use std::sync::{Once, ONCE_INIT};
-use core::Shell;
+use core::{Shell, CliUnstable};
use core::shell::Verbosity;
use jobserver;
use serde::{Serialize, Serializer};
frozen: Cell<bool>,
locked: Cell<bool>,
jobserver: Option<jobserver::Client>,
+ cli_flags: RefCell<CliUnstable>,
}
impl Config {
Some((*GLOBAL_JOBSERVER).clone())
}
},
+ cli_flags: RefCell::new(CliUnstable::default()),
}
}
quiet: Option<bool>,
color: &Option<String>,
frozen: bool,
- locked: bool) -> CargoResult<()> {
+ locked: bool,
+ unstable_flags: &[String]) -> CargoResult<()> {
let extra_verbose = verbose >= 2;
let verbose = if verbose == 0 {None} else {Some(true)};
self.extra_verbose.set(extra_verbose);
self.frozen.set(frozen);
self.locked.set(locked);
+ self.cli_flags.borrow_mut().parse(unstable_flags)?;
Ok(())
}
+ pub fn cli_unstable(&self) -> Ref<CliUnstable> {
+ self.cli_flags.borrow()
+ }
+
pub fn extra_verbose(&self) -> bool {
self.extra_verbose.get()
}
"));
}
+#[test]
+fn nightly_feature_requires_nightly_in_dep() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "b"
+ version = "0.0.1"
+ authors = []
+
+ [dependencies]
+ a = { path = "a" }
+ "#)
+ .file("src/lib.rs", "")
+ .file("a/Cargo.toml", r#"
+ [package]
+ name = "a"
+ version = "0.0.1"
+ authors = []
+ im-a-teapot = true
+ cargo-features = ["test-dummy-unstable"]
+ "#)
+ .file("a/src/lib.rs", "");
+ assert_that(p.cargo_process("build")
+ .masquerade_as_nightly_cargo(),
+ execs().with_status(0)
+ .with_stderr("\
+[COMPILING] a [..]
+[COMPILING] b [..]
+[FINISHED] [..]
+"));
+
+ assert_that(p.cargo("build"),
+ execs().with_status(101)
+ .with_stderr("\
+error: failed to load source for a dependency on `a`
+
+Caused by:
+ Unable to update [..]
+
+Caused by:
+ failed to parse manifest at `[..]`
+
+Caused by:
+ the cargo feature `test-dummy-unstable` requires a nightly version of Cargo, \
+ but this is the `stable` channel
+"));
+}
+
#[test]
fn cant_publish() {
let p = project("foo")
but this is the `stable` channel
"));
}
+
+#[test]
+fn z_flags_rejected() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "a"
+ version = "0.0.1"
+ authors = []
+ im-a-teapot = true
+ cargo-features = ["test-dummy-unstable"]
+ "#)
+ .file("src/lib.rs", "");
+ assert_that(p.cargo_process("build")
+ .arg("-Zprint-im-a-teapot"),
+ execs().with_status(101)
+ .with_stderr("\
+error: the `-Z` flag is only accepted on the nightly channel of Cargo
+"));
+
+ assert_that(p.cargo("build")
+ .masquerade_as_nightly_cargo()
+ .arg("-Zarg"),
+ execs().with_status(101)
+ .with_stderr("\
+error: unknown `-Z` flag specified: arg
+"));
+
+ assert_that(p.cargo("build")
+ .masquerade_as_nightly_cargo()
+ .arg("-Zprint-im-a-teapot"),
+ execs().with_status(0)
+ .with_stdout("im-a-teapot = true\n")
+ .with_stderr("\
+[COMPILING] a [..]
+[FINISHED] [..]
+"));
+}
+
+#[test]
+fn publish_rejected() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "a"
+ version = "0.0.1"
+ authors = []
+ cargo-features = ["test-dummy-unstable"]
+ "#)
+ .file("src/lib.rs", "");
+ assert_that(p.cargo_process("package")
+ .masquerade_as_nightly_cargo(),
+ execs().with_status(101)
+ .with_stderr("\
+error: cannot package or publish crates which activate nightly-only cargo features
+"));
+}