Crate that requires nightly toolchain

Hello!

I have a crate that need to be compiled with nightly because it use internally ( not in the user interface ) a feature that is a nightly-only experimental API ( core::ffi::c_size_t ).

I'm looking for a way to add this requirement in the crate. Users that use the crate, can use the stable core version until a newer version of my crate that need the nightly core. I don't want to force the user to use the nightly when he compile it's crate, but only when mine is compiled.

How can I add this information in my crate correctly to let cargo call the nightly only for my crate that is a dependency of a crate that don't requires to be build with nightly?

Thank you

1 Like

You can't. Nightly propagates through dependencies. If your dependency requires nightly to build, your project will, too. The feature your dependency uses could be changed or removed between compiler versions, causing the dependency to break, which is not acceptable for the stable toolchain.

Here is a link to an answer from @shepmaster on SO which describes this much better than I could:

3 Likes

Ok I got it. Thank you @jofas for your help.

1 Like

I'd suggest just putting

type c_size_t = usize;

in your crate that would otherwise require nightly. This is identical to the definition in core::ffi and is correct for all actually supported platforms.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.