Caballero
Caballero

Reputation: 12101

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

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?

Upvotes: 35

Views: 53119

Answers (3)

Anjum....
Anjum....

Reputation: 4204

I was getting below error when I create

cargo generate --git https://github.com/rustwasm/wasm-pack-template
error[E0658]: use of unstable library feature 'bool_to_option'
   --> /Users/anjum/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-generate-0.17.3/src/user_parsed_input.rs:182:22
    |
182 |                     .then_some(true)
    |                      ^^^^^^^^^
    |
    = note: see issue #80967 <https://github.com/rust-lang/rust/issues/80967> for more information

error[E0658]: use of unstable library feature 'bool_to_option'
   --> /Users/anjum/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-generate-0.17.3/src/user_parsed_input.rs:350:38
    |
350 |     (path.exists() && path.is_dir()).then_some(path)
    |                                      ^^^^^^^^^
    |
    = note: see issue #80967 <https://github.com/rust-lang/rust/issues/80967> for more information

after updating the core rust with below all worked perfectly fine.

rustup update

Upvotes: 2

oli_obk
oli_obk

Reputation: 31173

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.

Upvotes: 13

DK.
DK.

Reputation: 58975

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.

Upvotes: 47

Related Questions