Rust versions / 1.18
Rust release · Jun 8, 2017
Rust 1.18: what's new, what was stabilized
Short answerRust 1.18 was released on Jun 8, 2017: 2 language stabilizations ([Stabilize pub(restricted)][40556] pub can now accept a module path to); 7 newly stable APIs (Child::try_wait, HashMap::retain, HashSet::retain, PeekMut::pop, ...); 8 compatibility notes that can affect existing code.
← Rust 1.17All versionsRust 1.19 →
Language features stabilized
- [Stabilize pub(restricted)][40556] pub can now accept a module path to
- [Stabilize #![windows_subsystem] attribute][40870] conservative exposure of the
7 APIs stabilized
Child::try_wait, HashMap::retain, HashSet::retain, PeekMut::pop, TcpStream::peek, UdpSocket::peek, UdpSocket::peek_from
Can it break my build?
The release lists these compatibility notes. Most only affect rare code, but read them before you raise your toolchain in CI:
- [Changes to how the
0flag works in format!][40241] Padding zeroes are now - [Due to the struct field optimisation][40377], using
transmuteon structs - [The refactor of trait object type parsing][40043] fixed a bug where
+was - [Overlapping inherent
impls are now a hard error][40728] - [
PartialOrdandOrdmust agree on the ordering.][41270] - [
rustc main.rs -o out --emit=asm,llvm-ir][41085] Now will output - [ calling a function that returns
Selfwill no longer work][41805] when - [rustc now builds with a "pthreads" flavour of MinGW for Windows GNU][40805]
Use it
rustup update stable # get the newest release
rustup install 1.18 # or exactly this one
rustup override set 1.18 # pin a project to itTo require at least this version from users of your crate, set rust-version = "1.18" under [package] in Cargo.toml. Cargo then refuses to build it on older compilers with a clear message, and with resolver 3 (the default on the 2024 edition, Rust 1.85+) it also prefers dependency versions that support it.
Full release notes
Language
- [Stabilize pub(restricted)][40556]
pubcan now accept a module path to make the item visible to just that module tree. Also accepts the keywordcrateto make something public to the whole crate but not users of the library. Example:pub(crate) mod utils;. [RFC 1422]. - [Stabilize
#![windows_subsystem]attribute][40870] conservative exposure of the/SUBSYSTEMlinker flag on Windows platforms. [RFC 1665]. - [Refactor of trait object type parsing][40043] Now
tyin macros can accept types likeWrite + Send, trailing+are now supported in trait objects, and better error reporting for trait objects starting with?Sized. - [0e+10 is now a valid floating point literal][40589]
- [Now warns if you bind a lifetime parameter to 'static][40734]
- [Tuples, Enum variant fields, and structs with no
reprattribute or with#[repr(Rust)]are reordered to minimize padding and produce a smaller representation in some cases.][40377]
Compiler
- [rustc can now emit mir with
--emit mir][39891] - [Improved LLVM IR for trivial functions][40367]
- [Added explanation for E0090(Wrong number of lifetimes are supplied)][40723]
- [rustc compilation is now 15%-20% faster][41469] Thanks to optimisation opportunities found through profiling
- [Improved backtrace formatting when panicking][38165]
Libraries
- [Specialized
Vec::from_iterbeing passedvec::IntoIter][40731] if the iterator hasn't been advanced the originalVecis reassembled with no actual iteration or reallocation. - [Simplified HashMap Bucket interface][40561] provides performance improvements for iterating and cloning.
- [Specialize Vec::from_elem to use calloc][40409]
- [Fixed Race condition in fs::create_dir_all][39799]
- [No longer caching stdio on Windows][40516]
- [Optimized insertion sort in slice][40807] insertion sort in some cases 2.50%~ faster and in one case now 12.50% faster.
- [Optimized
AtomicBool::fetch_nand][41143]
Stabilized APIs
- [
Child::try_wait] - [
HashMap::retain] - [
HashSet::retain] - [
PeekMut::pop] - [
TcpStream::peek] - [
UdpSocket::peek] - [
UdpSocket::peek_from]
Cargo
- [Added partial Pijul support][cargo/3842] Pijul is a version control system in Rust. You can now create new cargo projects with Pijul using
cargo new --vcs pijul - [Now always emits build script warnings for crates that fail to build][cargo/3847]
- [Added Android build support][cargo/3885]
- [Added
--binsand--testsflags][cargo/3901] now you can build all programs of a certain type, for examplecargo build --binswill build all binaries. - [Added support for haiku][cargo/3952]
Misc
- [rustdoc can now use pulldown-cmark with the
--enable-commonmarkflag][40338] - [Rust now uses the official cross compiler for NetBSD][40612]
- [rustdoc now accepts
#at the start of files][40828] - [Fixed jemalloc support for musl][41168]
Compatibility Notes
- Changes to how the
0flag works in format! Padding zeroes are now always placed after the sign if it exists and before the digits. With the#flag the zeroes are placed after the prefix and before the digits. - Due to the struct field optimisation, using
transmuteon structs that have noreprattribute or#[repr(Rust)]will no longer work. This has always been undefined behavior, but is now more likely to break in practice. - The refactor of trait object type parsing fixed a bug where
+was receiving the wrong priority parsing things like&for<'a> Tr<'a> + Sendas&(for<'a> Tr<'a> + Send)instead of(&for<'a> Tr<'a>) + Send - Overlapping inherent
impls are now a hard error PartialOrdandOrdmust agree on the ordering.rustc main.rs -o out --emit=asm,llvm-irNow will outputout.asmandout.llinstead of only one of the filetypes.- calling a function that returns
Selfwill no longer work when the size ofSelfcannot be statically determined. - rustc now builds with a "pthreads" flavour of MinGW for Windows GNU this has caused a few regressions namely:
- Changed the link order of local static/dynamic libraries (respecting the order on given rather than having the compiler reorder).
- Changed how MinGW is linked, native code linked to dynamic libraries may require manually linking to the gcc support library (for the native code itself)
Release notes from the Rust project's RELEASES.md (MIT or Apache-2.0); summaries above are ours.
Up next
Next releaseRust 1.19Released Jul 20, 2017.Read it next →Also worth your time
Did this answer your question?