Using Rust nightly in production
Asked Answered
F

1

11

Can someone explain to me how "production" Rust nightly is?

I want to use the PyO3 crate which uses the specialization feature that needs nightly Rust.

Does using a nightly version of Rust is production ready? I understand that things might break in future releases and API changes might be introduced but in terms of quality/testing/production readiness is nightly safe?

From this thread on Rust users it seems I should be fine as long as I limit my non-stable features usage (e.g. only to specialization)?

Fractionate answered 9/5, 2019 at 20:2 Comment(1)
Note: Pyo3 moved to stable in 2020 github.com/PyO3/pyo3/issues/5Disquietude
P
16

Obviously, there are no stability guarantees on nightly, which makes this question a duplicate of the one asked by George Berkeley once.

However, the nightly compiler is very stable: Every single, even the most mundane, change to the master branch (from which nightly is pulled) goes through CI, which executes the full test suite, which has to pass. There is no "we will fix this later" on master if the change breaks things that worked before. Secondly, big changes - like the recent changes to std::collections and std::sync - go through crater-runs where a decent portion of the publicly available Rust code is built; if the PR would break things that weren't broken before, it does not land in nightly. Last but not least many rust projects use scheduled CI on nightly, where the project at hand and it's dependencies are built and tested once a month. Projects like rocket run on nightly all the time and if a regression or a bug is introduced in nightly, it is noticed very quickly. All of this means that it is highly unlikely that your front suddenly falls off on nightly

Things are different for the unstable features that require nightly, though. The semantics can change, and code that once worked may fail to compile more or less suddenly; it is usually highly unlikely, however, that changes will cause silent failures, previously defined behavior to become undefined and the like.

A common strategy, therefore, is to pick a specific version of nightly (let's say "2019-05-09") and stick with that version for a whole while.

Addon: My intention was to make clear that there is a difference between "can nightly compile things reliably?" and "are the things compiled by nightly reliable?" I'd make a strong argument for both, with the emphasis on the second point: 1) Yes, most of the time nightly will be able to compile your code. 2) It is extremely unlikely that things compiled by nightly are unreliable due to subtle changes in behavior or outright miscompilations.

Pauly answered 9/5, 2019 at 21:41 Comment(4)
thanks for detailed answer, my real concern is about prod usage. For example, I wouldnt use python beta version on prod and docs clearly states so. In rust some crates like pyo3 uses features from nightly, does it means these crates are not suitable for prod use?Fractionate
"In rust some crates like pyo3 uses features from nightly, does it means these crates are not suitable for prod use?" That's (obviously) up to you. It comes to your requirements to the "prod" environment.Upbraid
@chipo isnt the rust lang or community have guidelines / recommendations on using nightly rust on prod systems? In python or other popular languages its pretty clear. Also i dont know of any popular python packages requires unstable build or unstable features like pyo3, all the nightly concept in rust is new to me and i try to make the correct decision for my projects but fail to find any answer except the one from rust users postFractionate
Thanks for the addon section update now its more clearFractionate

© 2022 - 2024 — McMap. All rights reserved.