Rust 1.43.0
Language
- Fixed using binary operations with
&{number}
(e.g.&1.0
) not having the type inferred correctly. - Attributes such as
#[cfg()]
can now be used onif
expressions.
Syntax only changes
- Allow
type Foo: Ord
syntactically. - Fuse associated and extern items up to defaultness.
- Syntactically allow
self
in allfn
contexts. - Merge
fn
syntax + cleanup item parsing. item
macro fragments can be interpolated intotrait
s,impl
s, andextern
blocks. For example, you may now write:macro_rules! mac_trait { ($i:item) => { trait T { $i } } } mac_trait! { fn foo() {} }
These are still rejected semantically, so you will likely receive an error but these changes can be seen and parsed by macros and conditional compilation.
Compiler
- You can now pass multiple lint flags to rustc to override the previous flags. For example;
rustc -D unused -A unused-variables
denies everything in theunused
lint group exceptunused-variables
which is explicitly allowed. However, passingrustc -A unused-variables -D unused
denies everything in theunused
lint group includingunused-variables
since the allow flag is specified before the deny flag (and therefore overridden). - rustc will now prefer your system MinGW libraries over its bundled libraries if they are available on
windows-gnu
. - rustc now buffers errors/warnings printed in JSON.
Libraries
Arc<[T; N]>
,Box<[T; N]>
, andRc<[T; N]>
, now implementTryFrom<Arc<[T]>>
,TryFrom<Box<[T]>>
, andTryFrom<Rc<[T]>>
respectively. Note These conversions are only available whenN
is0..=32
.- You can now use associated constants on floats and integers directly, rather than having to import the module. e.g. You can now write
u32::MAX
orf32::NAN
with no imports. u8::is_ascii
is nowconst
.String
now implementsAsMut<str>
.- Added the
primitive
module tostd
andcore
. This module reexports Rust's primitive types. This is mainly useful in macros where you want avoid these types being shadowed. - Relaxed some of the trait bounds on
HashMap
andHashSet
. string::FromUtf8Error
now implementsClone + Eq
.
Stabilized APIs
Cargo
- You can now set config
[profile]
s in your.cargo/config
, or through your environment. - Cargo will now set
CARGO_BIN_EXE_<name>
pointing to a binary's executable path when running integration tests or benchmarks.<name>
is the name of your binary as-is e.g. If you wanted the executable path for a binary namedmy-program
you would useenv!("CARGO_BIN_EXE_my-program")
.
Misc
- Certain checks in the
const_err
lint were deemed unrelated to const evaluation, and have been moved to theunconditional_panic
andarithmetic_overflow
lints.
Compatibility Notes
- Having trailing syntax in the
assert!
macro is now a hard error. This has been a warning since 1.36.0. - Fixed
Self
not having the correctly inferred type. This incorrectly led to some instances being accepted, and now correctly emits a hard error.
Internal Only
These changes provide no direct user facing benefits, but represent significant improvements to the internals and overall performance of rustc
and related tools.
- All components are now built with
opt-level=3
instead of2
. - Improved how rustc generates drop code.
- Improved performance from
#[inline]
-ing certain hot functions. - traits: preallocate 2 Vecs of known initial size
- Avoid exponential behaviour when relating types
- Skip
Drop
terminators for enum variants without drop glue - Improve performance of coherence checks
- Deduplicate types in the generator witness
- Invert control in struct_lint_level.