|
|
Subscribe / Log in / New account

editions

editions

Posted Aug 21, 2024 16:05 UTC (Wed) by mrugiero (guest, #153040)
In reply to: editions by tialaramex
Parent article: FreeBSD considers Rust in the base system

One caveat that I see is missing from the editions discussion is that for this kind of project where stability is the most valued asset you should stick to at most current-1: the current edition is technically live and, while always backwards compatible, it's not necessarily forward compatible, as extensions are allowed to some degree. The same is true for the stdlib. You may find yourself in the situation where you happily coded locally with Rust 1.80 and used a feature that 1.78 doesn't have, but base uses 1.78, so you broke the build, even though both used the same allowed edition. Luckily all prior editions are already frozen because new development happens in current.


to post comments

editions

Posted Aug 22, 2024 8:21 UTC (Thu) by taladar (subscriber, #68407) [Link]

That is because Rust is not designed to use an old compiler. It is designed for the new compiler to always be able to handle your old code.

editions

Posted Aug 22, 2024 12:26 UTC (Thu) by khim (subscriber, #9252) [Link]

> One caveat that I see is missing from the editions discussion is that for this kind of project where stability is the most valued asset you should stick to at most current-1: the current edition is technically live and, while always backwards compatible, it's not necessarily forward compatible, as extensions are allowed to some degree.

That's true for all editions, including the very first Rust 2015 edition. One example: Rust 2015 got NLL is year 2022, one year after Rust 2021 got it and four years after Rust 2018 got it — which means, ironically enough, that if you want to backport some code written for Rust 2015 in year 2024 it may be easier to port it to Rust 2018 than to stay with Rust 2015 if you want to use old compiler.

The only way to stay with old version of Rust compiler is to, essentially, fork everything and stay in your own little island.

> Luckily all prior editions are already frozen because new development happens in current.

I recommend you to find someone who told you this blatant lie and kick him. All prior edition have to stay compatible with all prior code (with some small caveats), but they are not frozen and they are not meant to be frozen.

Edition compatibility over time

Posted Aug 22, 2024 12:33 UTC (Thu) by farnz (subscriber, #17727) [Link]

One caveat that I see is missing from the editions discussion is that for this kind of project where stability is the most valued asset you should stick to at most current-1: the current edition is technically live and, while always backwards compatible, it's not necessarily forward compatible, as extensions are allowed to some degree

This is also not completely true; the old edition is also technically live, since, while it's not permitted to change the meaning of code that compiled under old compilers except across an edition boundary, it's permissible for a new compiler to accept code under an old edition that an old compiler rejected. So, I can write Rust 2015 code with compiler 1.80 that will not be accepted by compiler 1.50, for example, because the new compiler accepts more code than the old one did (borrow checker changes, changes to core and std to name new examples).

editions

Posted Aug 22, 2024 13:12 UTC (Thu) by laarmen (subscriber, #63948) [Link]

> Luckily all prior editions are already frozen because new development happens in current.

The scenario you describe could very well still happen even using an older edition. Even if your Rust code uses the 2018 edition, the 1.80 compiler will happily let you use stdlib APIs introduced in the 1.80 dev cycle. Editions are about incompatible changes to the syntax, changes to the default import, etc. They're not about freezing the language (in the wider sense) in time.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds