Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Rust nightly in production

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)?

like image 834
ShmulikA Avatar asked May 09 '19 20:05

ShmulikA


1 Answers

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.

like image 142
user2722968 Avatar answered Nov 11 '22 00:11

user2722968