Rust Nightly or Stable with Rustup and "may not be used" error

When writing one of my pet projects or rather, a very simple automation matter in Rust, I fell into many pits. Usually full of snakes (of my own lack of knowledge of rust), but this one struck me as relatively interesting.

The stable compiler does not allow you to use unstable APIs/features. You have to use the nightly release branch.

If you know node, this is probably the equivalent of having to run V8 with harmony flags.

Rustup easily enables you to install the nightly branch of rust and to use it by default:

rustup install nightly
rustup default nightly

If you want to revert back to using rust stable, you can run:

rustup default stable

Note that you can also override the Rust release branch per project.

Here an example how you set the project directory you're in right now to use nightly:

rustup override add nightly

#![feature] may not be used on the stable release channel

This is the specific error I ran into while trying out rust-embed to embed a few simple text/config files in my binary.

error[E0554]: #![feature] may not be used on the stable release channel
 --> src/
2 | #![feature(attr_literals)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

error: Could not compile `shaft`.
Tagged with: #rust #rustup

Thank you for reading! If you have any comments, additions or questions, please tweet or toot them at me!