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:
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
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
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.