Skip to main content

CliUnstable

Struct CliUnstable 

Source
pub struct CliUnstable {
Show 19 fields pub print_im_a_teapot: bool, pub unstable_options: bool, pub no_index_update: bool, pub avoid_dev_deps: bool, pub minimal_versions: bool, pub package_features: bool, pub advanced_env: bool, pub config_include: bool, pub dual_proc_macros: bool, pub mtime_on_use: bool, pub named_profiles: bool, pub binary_dep_depinfo: bool, pub build_std: Option<Vec<String>>, pub timings: Option<Vec<String>>, pub doctest_xcompile: bool, pub panic_abort_tests: bool, pub jobserver_per_rustc: bool, pub features: Option<Vec<String>>, pub crate_versions: bool,
}
Expand description

A parsed representation 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!

Fields§

§print_im_a_teapot: bool§unstable_options: bool§no_index_update: bool§avoid_dev_deps: bool§minimal_versions: bool§package_features: bool§advanced_env: bool§config_include: bool§dual_proc_macros: bool§mtime_on_use: bool§named_profiles: bool§binary_dep_depinfo: bool§build_std: Option<Vec<String>>§timings: Option<Vec<String>>§doctest_xcompile: bool§panic_abort_tests: bool§jobserver_per_rustc: bool§features: Option<Vec<String>>§crate_versions: bool

Implementations§

Source§

impl CliUnstable

Source

pub fn parse(&mut self, flags: &[String]) -> CargoResult<()>

Source

pub fn fail_if_stable_opt(&self, flag: &str, issue: u32) -> CargoResult<()>

Generates an error if -Z unstable-options was not used. Intended to be used when a user passes a command-line flag that requires -Z unstable-options.

Trait Implementations§

Source§

impl Debug for CliUnstable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CliUnstable

Source§

fn default() -> CliUnstable

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.