Using Rust nightly in production

﹥>﹥吖頭↗ 提交于 2020-12-04 03:13:57

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/56066765/using-rust-nightly-in-production

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!