[][src]Module cargo::core::features

Support for nightly features in Cargo itself.

This file is the version of feature_gate.rs in upstream Rust for Cargo itself and is intended to be the avenue for which new features in Cargo are gated by default and then eventually stabilized. All known stable and unstable features are tracked in this file.

If you're reading this then you're likely interested in adding a feature to Cargo, and the good news is that it shouldn't be too hard! To do this you'll want to follow these steps:

  1. Add your feature. Do this by searching for "look here" in this file and expanding the macro invocation that lists all features with your new feature.

  2. Find the appropriate place to place the feature gate in Cargo itself. If you're extending the manifest format you'll likely just want to modify the Manifest::feature_gate function, but otherwise you may wish to place the feature gate elsewhere in Cargo.

  3. To actually perform the feature gate, you'll want to have code that looks like:

This example deliberately fails to compile
use core::{Feature, Features};

let feature = Feature::launch_into_space();
package.manifest().features().require(feature).chain_err(|| {
    "launching Cargo into space right now is unstable and may result in \
     unintended damage to your codebase, use with caution"
})?;

Notably you'll notice the require function called with your Feature, and then you use chain_err to tack on more context for why the feature was required when the feature isn't activated.

  1. Update the unstable documentation at src/doc/src/reference/unstable.md to include a short description of how to use your new feature. When the feature is stabilized, be sure that the Cargo Guide or Reference is updated to fully document the feature and remove the entry from the Unstable section.

And hopefully that's it! Bear with us though that this is, at the time of this writing, a very new feature in Cargo. If the process differs from this we'll be sure to update this documentation!

Structs

CliUnstable

A parsed representation of all unstable flags that Cargo accepts.

Feature
Features

Enums

Edition

The edition of the compiler (RFC 2052)

Constants

SEE_CHANNELS

Functions

channel

Returns the current release channel ("stable", "beta", "nightly", "dev").

enable_nightly_features

Forcibly enables nightly features for this thread.

maybe_allow_nightly_features

Allows nightly features to be enabled for this thread, but only if the development channel is nightly or dev.

nightly_features_allowed

This is a little complicated. This should return false if: