Rust 1.27.0
Language
- Removed 'proc' from the reserved keywords list. This allows
proc
to be used as an identifier. - The dyn syntax is now available. This syntax is equivalent to the bare
Trait
syntax, and should make it clearer when being used in tandem withimpl Trait
because it is equivalent to the following syntax:&Trait == &dyn Trait
,&mut Trait == &mut dyn Trait
, andBox<Trait> == Box<dyn Trait>
. - Attributes on generic parameters such as types and lifetimes are now stable. e.g.
fn foo<#[lifetime_attr] 'a, #[type_attr] T: 'a>() {}
- The
#[must_use]
attribute can now also be used on functions as well as types. It provides a lint that by default warns users when the value returned by a function has not been used.
Compiler
Libraries
- SIMD (Single Instruction Multiple Data) on x86/x86_64 is now stable. This includes
arch::x86
&arch::x86_64
modules which contain SIMD intrinsics, a new macro calledis_x86_feature_detected!
, the#[target_feature(enable="")]
attribute, and addingtarget_feature = ""
to thecfg
attribute. - A lot of methods for
[u8]
,f32
, andf64
previously only available in std are now available in core. - The generic
Rhs
type parameter onops::{Shl, ShlAssign, Shr}
now defaults toSelf
. std::str::replace
now has the#[must_use]
attribute to clarify that the operation isn't done in place.Clone::clone
,Iterator::collect
, andToOwned::to_owned
now have the#[must_use]
attribute to warn about unused potentially expensive allocations.
Stabilized APIs
DoubleEndedIterator::rfind
DoubleEndedIterator::rfold
DoubleEndedIterator::try_rfold
Duration::from_micros
Duration::from_nanos
Duration::subsec_micros
Duration::subsec_millis
HashMap::remove_entry
Iterator::try_fold
Iterator::try_for_each
NonNull::cast
Option::filter
String::replace_range
Take::set_limit
hint::unreachable_unchecked
os::unix::process::parent_id
ptr::swap_nonoverlapping
slice::rsplit_mut
slice::rsplit
slice::swap_with_slice
Cargo
cargo-metadata
now includesauthors
,categories
,keywords
,readme
, andrepository
fields.cargo-metadata
now includes a package'smetadata
table.- Added the
--target-dir
optional argument. This allows you to specify a different directory thantarget
for placing compilation artifacts. - Cargo will be adding automatic target inference for binaries, benchmarks, examples, and tests in the Rust 2018 edition. If your project specifies specific targets, e.g. using
[[bin]]
, and have other binaries in locations where cargo would infer a binary, Cargo will produce a warning. You can disable this feature ahead of time by setting any of the following to false:autobins
,autobenches
,autoexamples
,autotests
. - Cargo will now cache compiler information. This can be disabled by setting
CARGO_CACHE_RUSTC_INFO=0
in your environment.
Misc
- Added “The Rustc book” into the official documentation. “The Rustc book” documents and teaches how to use the rustc compiler.
- All books available on
doc.rust-lang.org
are now searchable.
Compatibility Notes
- Calling a
CharExt
orStrExt
method directly on core will no longer work. e.g.::core::prelude::v1::StrExt::is_empty("")
will not compile,"".is_empty()
will still compile. Debug
output onatomic::{AtomicBool, AtomicIsize, AtomicPtr, AtomicUsize}
will only print the inner type. E.g.print!("{:?}", AtomicBool::new(true))
will printtrue
, notAtomicBool(true)
.- The maximum number for
repr(align(N))
is now 2²⁹. Previously you could enter higher numbers but they were not supported by LLVM. Up to 512MB alignment should cover all use cases. - The
.description()
method on thestd::error::Error
trait has been soft-deprecated. It is no longer required to implement it.