PSA: Feature staging will be fully activated in the next nightly


#1

The Rust compiler is about to get even more picky about unstable features. Here’s what you need to know.

For the first 1.0 alpha feature staging, where unstable features are allowed only in nightly releases, was only partially enforced to ease the transition. Now, in time for the beta, it is going to be fully enforced.

Two changes landed recently:

  1. Most importantly, on nightlies it is now an error to use unstable library features without declaring them. As a result, all crates that cannot compile with stable Rust will soon be required to say so explicitly with feature attributes.

  2. In beta and stable releases, it is an error to use unstable features.

The first is going to cause several types of pain for those using unstable features, but here’s how to cope: firstly, when simply compiling your code normally, rustc will tell you if you are using unstable features and how to fix the problem by applying #![feature(foo)] at the crate level.

That’s the easy case. Next, when compiling with --test rustc may tell you about unstable features. It may be that your tests are exercising unstable libraries that the crate normally does not. In that case you must conditionally apply the feature attribute like #![cfg_attr(test, feature(foo))].

Finally, the worst case. If your doctests use unstable features then they will all need to be annotated. Putting # #![feature(foo)] at the top of the doctest should work in all cases, but there are some hacks in rustdoc to make that so.


#2

I guess it’s the 2015-03-25 (built 2015-03-26) nightly?

Or is it 2015-03-24 (built 2015-03-25)?


#3

The current nightly is rustc 1.0.0-nightly (123a754cb 2015-03-24) (built 2015-03-25)

The next nightly, assuming there are no problems, will be built tonight, and show up tomorrow morning, subject to your time zone, of course.


#4

Actually, I mis-understood @brson’s use of ‘next’. It does seem that it is in the current nightly, (123a754cb 2015-03-24) (built 2015-03-25).

For a simple program to see if your version has this,

fn main() {
    let s = "hello world";
    s.words();
}

will fail to compile now, without the flag.