4 ms·
I'm a bit confused by this. I thought (probably incorrectly) that the point of Rust editions was that if you targeted Rust 2015, it would compile with Rust v1.0
by cornstalks 8y ago
I'm a bit confused by this. I thought (probably incorrectly) that the point of Rust editions was that if you targeted Rust 2015, it would compile with Rust v1.0.
But if you enable NLL in Rust 2015 mode, that code will no longer compile with Rust v1.0. Which means we're still back at square 1 (meaning each crate has to specify which compiler version it requires).
Could you help enlighten me on why this is safe to backport to Rust 2015?
- steveklabnik 8y ago“Rust 2015” does not mean “Rust 1.0.” Editions are a way to opt into changes that would be breaking. New features land in Rust 2015 unless they require breaking changes, and if they do, they must wait until the next edition to land, because otherwise they’d be breaking.
- kibwen 8y agoI think you're talking about forward compatibility, which is distinct from backward compatibility. With backward compatibility, old programs will work with new versions of the compiler (alternatively, for web browsers, "old websites will work with new versions of the browser" (or for operating systems, "old binaries will work with new versions of the OS" (or for game consoles, "old games will work with new versions of the console", etc.))). In this case, code written as of Rust 1.0 should continue compiling with Rust 2015, respective of the compatibility guarantee ( https://blog.rust-lang.org/2014/10/30/Stability.html https://blog.rust-lang.org/2014/10/30/Stability.html ). By this definition, Rust is backwards-compatible. What Rust is not, and has never been, is forwards-compatible. Very few systems in the wild are forwards-compatible. A C++ compiler from 2003 is not able to compile C++17 programs, and is thus not forwards-compatible. Likewise, web browsers from 2003 cannot render web pages from 2018, Windows ME cannot run binaries compiled for Windows 10, PS2 cannot play PS4 games, and so on. > meaning each crate has to specify which compiler version it requires Every Rust crate that does not specify a compiler version is compiled in 2015 mode. It must be this way, for backwards-compatibility. However, when you run `cargo new`, cargo should automatically insert the directive specifying the most recent edition supported by your compiler. In this way, Rust can gradually push the ecosystem forward without any additional burden to the user and without leaving behind any code that doesn't update.