Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"use of unstable library feature 'collections'" using nightly

Tags:

rust

This

fn main() {

    let test = "Foo".to_string();
    test.to_lowercase();

}

produces an error

error: use of unstable library feature 'collections'
       test.to_lowercase();
            ^~~~~~~~~~~~~~

but I am using

rustc 1.2.0-nightly (f76d9bcfc 2015-05-28) (built 2015-05-28)

and according to http://doc.rust-lang.org/1.0.0/book/release-channels.html unstable features are enabled on nightly. I've also tried stable and beta, but the error is exactly the same. So what's the issue here?

like image 463
Caballero Avatar asked May 28 '15 12:05

Caballero


2 Answers

You need to explicitly opt-in by placing #![feature(collections)] at the top of your crate's root source file. Using a nightly compiler merely permits you to use unstable features, it doesn't automatically enable them.

See also this related SO question.

like image 141
DK. Avatar answered Oct 13 '22 00:10

DK.


If you look below the error message (on nightly), there's a hint as to what you need to do to activate this feature (just because it's in the nightly, doesn't mean the feature is active)

<anon>:3:10: 3:24 help: add #![feature(collections)] to the crate attributes to enable
error: aborting due to previous error

Always read the full error message, especially the note: and help: parts. These often tell you how to fix the error.

like image 27
oli_obk Avatar answered Oct 13 '22 00:10

oli_obk