Version 1.28.0 (2018-08-02)
Language
- The
#[repr(transparent)]attribute is now stable. This attribute allows a Rust newtype wrapper (struct NewType<T>(T);) to be represented as the inner type across Foreign Function Interface (FFI) boundaries. - The keywords
pure,sizeof,alignof, andoffsetofhave been unreserved and can now be used as identifiers. - The
GlobalAlloctrait and#[global_allocator]attribute are now stable. This will allow users to specify a global allocator for their program. - Unit test functions marked with the
#[test]attribute can now returnResult<(), E: Debug>in addition to(). - The
lifetimespecifier formacro_rules!is now stable. This allows macros to easily target lifetimes.
Compiler
- The
sandzoptimisation levels are now stable. These optimisations prioritise making smaller binary sizes.zis the same asswith the exception that it does not vectorise loops, which typically results in an even smaller binary. - The short error format is now stable. Specified with
--error-format=shortthis option will provide a more compressed output of rust error messages. - Added a lint warning when you have duplicated
macro_exports. - Reduced the number of allocations in the macro parser. This can improve compile times of macro heavy crates on average by 5%.
Libraries
- Implemented
Defaultfor&mut str. - Implemented
From<bool>for all integer and unsigned number types. - Implemented
Extendfor(). - The
Debugimplementation oftime::Durationshould now be more easily human readable. Previously aDurationof one second would printed asDuration { secs: 1, nanos: 0 }and will now be printed as1s. - Implemented
From<&String>forCow<str>,From<&Vec<T>>forCow<[T]>,From<Cow<CStr>>forCString,From<CString>, From<CStr>, From<&CString>forCow<CStr>,From<OsString>, From<OsStr>, From<&OsString>forCow<OsStr>,From<&PathBuf>forCow<Path>, andFrom<Cow<Path>>forPathBuf. - Implemented
ShlandShrforWrapping<u128>andWrapping<i128>. DirEntry::metadatanow usesfstatatinstead oflstatwhen possible. This can provide up to a 40% speed increase.- Improved error messages when using
format!.
Stabilized APIs
Iterator::step_byPath::ancestorsSystemTime::UNIX_EPOCHalloc::GlobalAllocalloc::Layoutalloc::LayoutErralloc::Systemalloc::allocalloc::alloc_zeroedalloc::deallocalloc::reallocalloc::handle_alloc_errorbtree_map::Entry::or_defaultfmt::Alignmenthash_map::Entry::or_defaultiter::repeat_withnum::NonZeroUsizenum::NonZeroU128num::NonZeroU16num::NonZeroU32num::NonZeroU64num::NonZeroU8ops::RangeBoundsslice::SliceIndexslice::from_mutslice::from_ref{Any + Send + Sync}::downcast_mut{Any + Send + Sync}::downcast_ref{Any + Send + Sync}::is
Cargo
- Cargo will now no longer allow you to publish crates with build scripts that
modify the
srcdirectory. Thesrcdirectory in a crate should be considered to be immutable.
Misc
- The
suggestion_applicabilityfield inrustc's json output is now stable. This will allow dev tools to check whether a code suggestion would apply to them.
Compatibility Notes
- Rust will consider trait objects with duplicated constraints to be the same
type as without the duplicated constraint. For example the below code will
now fail to compile.
#![allow(unused)] fn main() { trait Trait {} impl Trait + Send { fn test(&self) { println!("one"); } //~ ERROR duplicate definitions with name `test` } impl Trait + Send + Send { fn test(&self) { println!("two"); } } }