Update Jan 11, 2023 tracked by Updatify
Rust 1.66.1
- Added validation of SSH host keys for git URLs in Cargo (CVE-2022-46176)
Rust is a general-purpose programming language which emphasizes performance, type safety, concurrency, and memory safety.
Update Jan 11, 2023 tracked by Updatify
Update Dec 15, 2022 tracked by Updatify
repr(Int) enums #[repr(u8)]
enum Foo {
A(u8) = 0,
B(i8) = 1,
C(bool) = 42,
}
must_use on impl Trait for supertraits This makes impl ExactSizeIterator respect the existing #[must_use] annotation on Iterator. ..=X in patterns clippy::for_loops_over_fallibles lint into rustc sym operands in inline assembly Update Nov 3, 2022 tracked by Updatify
as casts of enums with #[non_exhaustive] variants let else let_underscore_drop and let_underscore_lock from Clippy breaking from arbitrary labeled blocks (“label-break-value”) MaybeUninit is the correct way to work with uninitialized memory. Drop impl on foreign ADTs Update Sep 22, 2022 tracked by Updatify
&T if every byte in T is inside an UnsafeCell unused_tuple_struct_fields, similar to the existing warning for unused struct fields. This lint will become warn-by-default in the future. #[used] as llvm.compiler.used for ELF targets --diagnostic-width compiler flag to define the terminal width. rust-lld for iOS, tvOS and watchOS write! or writeln! into an OsString: Implement fmt::Write for OsString Update Aug 11, 2022 tracked by Updatify
impl Trait args. cenum_impl_drop_cast warnings deny-by-default. -C panic=abort is used regardless of declared ABI. bundle native library modifier, also removing the deprecated static-nobundle linking kind. * Refer to Rust’s platform support page for more information on Rust’s tiered platform support.
Update Jul 19, 2022 tracked by Updatify
Rust 1.62.1 addresses a few recent regressions in the compiler and standard library, and also mitigates a CPU vulnerability on Intel SGX.
impl Trait return types. async fn lifetimes. x86_64-fortanix-unknown-sgx target added a mitigation for the MMIO stale data vulnerability, advisory INTEL-SA-00615. Update Jun 30, 2022 tracked by Updatify
#[derive(Default)] on enums with a #[default] variant const functions may now specify extern "C" or extern "Rust" unaligned_references lint deny-by-default This lint is also a future compatibility lint, and is expected to eventually become a hard error. #[thread_local] attribute on non-static items aarch64-pc-windows-gnullvm and x86_64-pc-windows-gnullvm targets* Update May 19, 2022 tracked by Updatify
const fn signatures can now include generic trait bounds const fn signatures can now use impl Trait in argument and return position const fn impl Trait return type #[link] attributes and on the command line, as well as the whole-archive modifier specifically, are now supported char type is now described as UTF-32 in debuginfo #[target_feature] attribute can now be used with aarch64 features #[target_feature = "adx"] is now stable Update Apr 7, 2022 tracked by Updatify
#[cfg(panic = "...")] for either "unwind" or "abort". #[cfg(target_has_atomic = "...")] for each integer size and "ptr". +crt-static and relocation-model=pic on x86_64-unknown-linux-gnu unreachable_pub lints on nested and glob public reexport -Z instrument-coverage as -C instrument-coverage -Z print-link-args as --print link-args mips64-openwrt-linux-musl* armv7-unknown-linux-uclibceabi (softfloat)* RUST_BACKTRACE=full by default Update Feb 24, 2022 tracked by Updatify
-Cremark #[test]-like built-in attribute macro is present multiple times. -Z emit-future-incompat as --json future-incompat Update Jan 13, 2022 tracked by Updatify
{ident} in the string. This works in all macros accepting format strings. Support for this in panic! (panic!("{ident}")) requires the 2021 edition; panic invocations in previous editions that appear to be trying to use this will result in a warning lint about not having the intended effect. *const T pointers can now be dereferenced in const contexts. Unsize have been relaxed. strip option to remove these symbols to produce smaller release binaries. Note that this release only includes support in rustc, not directly in cargo. -Cremark Update Dec 2, 2021 tracked by Updatify
#[derive] and will see the original (pre-cfg) input. m!{ .. }.method() and m!{ .. }?. Clone and Debug implementations during dead code analysis. armv6k-nintendo-3ds at Tier 3*. armv7-unknown-linux-uclibceabihf at Tier 3*. m68k-unknown-linux-gnu at Tier 3*. aarch64-kmc-solid_asp3, armv7a-kmc-solid_asp3-eabi, armv7a-kmc-solid_asp3-eabihf * Refer to Rust’s platform support page for more information on Rust’s tiered platform support.
Update Nov 1, 2021 tracked by Updatify
Update Oct 21, 2021 tracked by Updatify
binding @ pattern can now also introduce new bindings. const fn. --force-warn. This feature is primarily intended for usage by cargo fix, rather than end users. aarch64-apple-ios-sim to Tier 2*. powerpc-unknown-freebsd at Tier 3*. riscv32imc-esp-espidf at Tier 3*. * Refer to Rust’s platform support page for more information on Rust’s tiered platform support.
Update Sep 9, 2021 tracked by Updatify
X..), which will start at X and will end at the maximum value of the integer. std::prelude (e.g. use std::prelude::rust_2021::*;). * Refer to Rust’s platform support page for more information on Rust’s tiered platform support.
string::Drain now implements AsRef<str> and AsRef<[u8]>. Update Jul 29, 2021 tracked by Updatify
You can now use macros for values in some built-in attributes. This primarily allows you to call macros within the #[doc] attribute. For example, to include external documentation in your crate, you can now write the following:
#![doc = include_str!("README.md")]
You can now cast between unsized slice types (and types which contain unsized slices) in const fn.
You can now use multiple generic lifetimes with impl Trait where the lifetimes don’t explicitly outlive another. In code this means that you can now have impl Trait<'a, 'b> where as before you could only have impl Trait<'a, 'b> where 'b: 'a.
/lib/rustlib/<target-triple>/target.json where / is the “sysroot” directory. You can find your sysroot directory by running rustc --print sysroot. wasm as a target_family for WebAssembly platforms. #[target_feature] on safe functions when targeting WebAssembly platforms. Update Jun 17, 2021 tracked by Updatify
◆ or 🦀. More specifically you can now use any identifier that matches the UAX #31 “Unicode Identifier and Pattern Syntax” standard. This is the same standard as languages like Python, however Rust uses NFC normalization which may be different from other languages. | (OR) on complete patterns. E.g. let x = Some(2u8);
// Before
matches!(x, Some(1) | Some(2));
// Now
matches!(x, Some(1 | 2));
:pat_param macro_rules! matcher. This matcher has the same semantics as the :pat matcher. This is to allow :pat to change semantics to being a pattern fragment in a future edition. Update May 18, 2021 tracked by Updatify
This release disables incremental compilation, unless the user has explicitly opted in via the newly added RUSTC_FORCE_INCREMENTAL=1 environment variable.
This is due to the widespread, and frequently occurring, breakage encountered by Rust users due to newly enabled incremental verification in 1.52.0. Notably, Rust users should upgrade to 1.52.0 or 1.52.1: the bugs that are detected by newly added incremental verification are still present in past stable versions, and are not yet fixed on any channel. These bugs can lead to miscompilation of Rust binaries.
These problems only affect incremental builds, so release builds with Cargo should not be affected unless the user has explicitly opted into incremental. Debug and check builds are affected.
See 84970 for more details.
Update May 6, 2021 tracked by Updatify
unsafe_op_in_unsafe_fn lint, which checks whether the unsafe code in an unsafe fn is wrapped in a unsafe block. This lint is allowed by default, and may become a warning or hard error in a future edition. Added tier 3* support for the following targets.
s390x-unknown-linux-musl riscv32gc-unknown-linux-musl & riscv64gc-unknown-linux-musl powerpc-unknown-openbsd * Refer to Rust’s platform support page for more information on Rust’s tiered platform support.
OsString now implements Extend and FromIterator. cmp::Reverse now has #[repr(transparent)] representation. Arc<impl Error> now implements error::Error. const. Update Mar 25, 2021 tracked by Updatify
structs by constant values in addition to by types and lifetimes. Also known as “const generics” E.g. you can now write the following. Note: Only values of primitive integers, bool, or char types are currently permitted. struct GenericArray<T, const LENGTH: usize> {
inner: [T; LENGTH]
}
impl<T, const LENGTH: usize> GenericArray<T, LENGTH> {
const fn last(&self) -> Option<&T> {
if LENGTH == 0 {
None
} else {
Some(&self.inner[LENGTH - 1])
}
}
}
-Csplit-debuginfo codegen option for macOS platforms. This option controls whether debug information is split across multiple files or packed into a single file. Note This option is unstable on other platforms. aarch64_be-unknown-linux-gnu, aarch64-unknown-linux-gnu_ilp32, and aarch64_be-unknown-linux-gnu_ilp32 targets. i386-unknown-linux-gnu and i486-unknown-linux-gnu targets. target-cpu=native option will now detect individual features of CPUs. Update Feb 11, 2021 tracked by Updatify
const values for x in [x; N] array expressions. This has been technically possible since 1.38.0, as it was unintentionally stabilized. ManuallyDrop<T> union fields are now considered safe. armv5te-unknown-linux-uclibceabi target. aarch64-apple-ios-macabi target. x86_64-unknown-freebsd is now built with the full toolset. * Refer to Rust’s platform support page for more information on Rust’s tiered platform support.
proc_macro::Punct now implements PartialEq<char>. ops::{Index, IndexMut} are now implemented for fixed sized arrays of any length. std::fs::File type now has a “niche” of -1. This value cannot be a valid file descriptor, and now means Option<File> takes up the same amount of space as File. Update Dec 31, 2020 tracked by Updatify
Drop, and you can now have a field in a union with ManuallyDrop<T>. #[derive(Debug)]
struct Person {
name: String,
age: u8,
}
let person = Person {
name: String::from("Alice"),
age: 20,
};
// `name` is moved out of person, but `age` is referenced.
let Person { name, ref age } = person;
println!("{} {}", name, age);
aarch64-unknown-linux-gnu. aarch64-apple-darwin. aarch64-pc-windows-msvc. mipsel-unknown-none. Update Nov 19, 2020 tracked by Updatify
unsafe keyword is now syntactically permitted on modules. This is still rejected semantically, but can now be parsed by procedural macros. -C link-self-contained=<yes|no> compiler flag. This tells rustc whether to link its own C runtime and libraries or to rely on a external linker to find them. (Supported only on windows-gnu, linux-musl, and wasi platforms.) -C target-feature=+crt-static on linux-gnu targets. Note: If you’re using cargo you must explicitly pass the --target flag. aarch64-unknown-linux-musl. * Refer to Rust’s platform support page for more information on Rust’s tiered platform support.
Update Oct 8, 2020 tracked by Updatify
-C control-flow-guard codegen option, which enables Control Flow Guard for Windows platforms, and is ignored on other platforms. thumbv4t-none-eabi target. RUST_BACKTRACE‘s output is now more compact. * Refer to Rust’s platform support page for more information on Rust’s tiered platform support.
CStr now implements Index<RangeFrom<usize>>. std/core are now implemented for arrays of any length, not just those of length less than 33. ops::RangeFull and ops::Range now implement Default. panic::Location now implements Copy, Clone, Eq, Hash, Ord, PartialEq, and PartialOrd. Update Sep 10, 2020 tracked by Updatify
impl<T> From<Foo> for Vec<T> {}. self position. E.g. you can now write fn foo(self: Box<Box<Self>>) {}. Previously only Self, &Self, &mut Self, Arc<Self>, Rc<Self>, and Box<Self> were allowed. format_args macro. Previously identifiers starting with an underscore were not allowed. pub) are now syntactically allowed on trait items and enum variants. These are still rejected semantically, but can be seen and parsed by procedural macros and conditional compilation. extern "C" function with Box<T> and use T* as the corresponding type on the C side. Please see the documentation for more information, including the important caveat about preferring to avoid Box<T> in Rust signatures for functions defined in C. Update Sep 10, 2020 tracked by Updatify
as has been defined as a saturating conversion. This was previously undefined behaviour, but you can use the {f64, f32}::to_int_unchecked methods to continue using the current behaviour, which may be desirable in rare performance sensitive situations. mem::Discriminant<T> now uses T‘s discriminant type instead of always using u64. macro_rules!) macro. target-feature flag. E.g. -C target-feature=+avx2 -C target-feature=+fma is now equivalent to -C target-feature=+avx2,+fma. force-unwind-tables flag. This option allows rustc to always generate unwind tables regardless of panic strategy. embed-bitcode flag. This codegen flag allows rustc to include LLVM bitcode into generated rlibs (this is on by default). tiny value to the code-model codegen flag. Update Sep 10, 2020 tracked by Updatify
Syntax-only changes
#[cfg(FALSE)]
mod foo {
mod bar {
mod baz; // `foo/bar/baz.rs` doesn't exist, but no error!
}
}
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.
-C codegen-units flag in incremental mode. Additionally when in incremental mode rustc defaults to 256 codegen units. catch_unwind to have zero-cost, unless unwinding is enabled and a panic is thrown. aarch64-unknown-none and aarch64-unknown-none-softfloat targets. arm64-apple-tvos and x86_64-apple-tvos targets. vec![] to map directly to Vec::new(). This allows vec![] to be able to be used in const contexts. Update Sep 10, 2020 tracked by Updatify
? operator in macro definitions. The ? operator allows you to specify zero or one repetitions similar to the * and + operators. super, self, or crate, will now always resolve to the item (enum, struct, etc.) available in the module if present, before resolving to a external crate or an item the prelude. E.g. enum Color { Red, Green, Blue }
use Color::*;
PhantomData<T> types. literal specifier. This will match against a literal of any type. E.g. 1, 'A', "Hello World" struct Point(i32, i32);
impl Point {
pub fn new(x: i32, y: i32) -> Self {
Self(x, y)
}
pub fn is_origin(&self) -> bool {
match self {
Self(0, 0) => true,
_ => false,
}
}
}
enum List<T>
where
Update Sep 10, 2020 tracked by Updatify
async functions and blocks with async fn, async move {}, and async {} respectively, and you can now call .await on async expressions. cfg, cfg_attr, allow, warn, deny, forbid as well as inert helper attributes used by procedural macro attributes applied to items. e.g. fn len(
#[cfg(windows)] slice: &[u16],
#[cfg(not(windows))] slice: &[u8],
) -> usize {
slice.len()
}
if guards of match arms. e.g. fn main() {
let array: Box<[u8; 4]> = Box::new([1, 2, 3, 4]);
match array {
nums
// ---- `nums` is bound by move.
if nums.iter().sum::<u8>() == 10
// ^------ `.iter()` implicitly takes a reference to `nums`.
=> {
drop(nums);
// ----------- Legal as `nums` was bound by move and so we have ownership.
}
_ => unreachable!(),
}
}
Update Sep 10, 2020 tracked by Updatify
&{number} (e.g. &1.0) not having the type inferred correctly. #[cfg()] can now be used on if expressions. Syntax only changes
type Foo: Ord syntactically. self in all fn contexts. fn syntax + cleanup item parsing. item macro fragments can be interpolated into traits, impls, and extern 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.
Update Sep 10, 2020 tracked by Updatify
cfg(target_vendor) attribute. E.g. #[cfg(target_vendor="apple")] fn main() { println!("Hello Apple!"); } u8 that covers 0..=255 and you would no longer be required to have a _ => unreachable!() case. if let and while let expressions. You can do this with the same syntax as a match expression. E.g. enum Creature {
Crab(String),
Lobster(String),
Person(String),
}
fn main() {
let state = Creature::Crab("Ferris");
if let Creature::Crab(name) | Creature::Person(name) = state {
println!("This creature's name is: {}", name);
}
}
if let and while let patterns. Using this feature will by default produce a warning as this behaviour can be unintuitive. E.g. if let _ = 5 {} let bindings, assignments, expression statements, and irrefutable pattern destructuring in const functions.
Update Sep 10, 2020 tracked by Updatify
#[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. pure, sizeof, alignof, and offsetof have been unreserved and can now be used as identifiers. GlobalAlloc trait and #[global_allocator] attribute are now stable. This will allow users to specify a global allocator for their program. #[test] attribute can now return Result<(), E: Debug> in addition to (). lifetime specifier for macro_rules! is now stable. This allows macros to easily target lifetimes. s and z optimisation levels are now stable. These optimisations prioritise making smaller binary sizes. z is the same as s with the exception that it does not vectorise loops, which typically results in an even smaller binary. --error-format=short this option will provide a more compressed output of rust error messages. Update Sep 10, 2020 tracked by Updatify
rls-preview component on the windows-gnu targets has been restored. Update Sep 10, 2020 tracked by Updatify
Copy impls Layout::repeat Update Sep 10, 2020 tracked by Updatify
#[must_use] will now warn if the type is contained in a tuple, Box, or an array and unused. cfg and cfg_attr attributes on generic parameters. type MyOption = Option<u8>;
fn increment_or_zero(x: MyOption) -> u8 {
match x {
MyOption::Some(y) => y + 1,
MyOption::None => 0,
}
}
_ as an identifier for consts. e.g. You can write const _: u32 = 5;. #[repr(align(X)] on enums. ? Kleene macro operator is now available in the 2015 edition. -C profile-generate and -C profile-use flags. For more information on how to use profile guided optimization, please refer to the rustc book. Update Sep 10, 2020 tracked by Updatify
The standard library’s str::repeat function contained an out of bounds write caused by an integer overflow. This has been fixed by deterministically panicking when an overflow happens.
Thank you to Scott McMurray for responsibly disclosing this vulnerability to us.
Update Sep 10, 2020 tracked by Updatify
#[global_allocator] attribute can now be used in submodules. #[deprecated] attribute can now be used on macros. rustc. This will improve compilation times in some cases. For further information please refer to the “Evaluating pipelined rustc compilation” thread. aarch64-uwp-windows-msvc, i686-uwp-windows-gnu, i686-uwp-windows-msvc, x86_64-uwp-windows-gnu, and x86_64-uwp-windows-msvc targets. armv7-unknown-linux-gnueabi and armv7-unknown-linux-musleabi targets. hexagon-unknown-linux-musl target. riscv32i-unknown-none-elf target. * Refer to Rust’s platform support page for more information on Rust’s tiered platform support.
Update Sep 10, 2020 tracked by Updatify
You can now use the slice pattern syntax with subslices. e.g.
fn foo(words: &[&str]) {
match words {
["Hello", "World", "!", ..] => println!("Hello World!"),
["Foo", "Bar", ..] => println!("Baz"),
rest => println!("{:?}", rest),
}
}
You can now use #[repr(transparent)] on univariant enums. Meaning that you can create an enum that has the exact layout and ABI of the type it contains.
You can now use outer attribute procedural macros on inline modules.
There are some syntax-only changes:
default is syntactically allowed before items in trait definitions. impls (i.e. consts, types, and fns) may syntactically leave out their bodies in favor of ;. impls are now syntactically allowed (e.g. type Foo: Ord;). ... (the C-variadic type) may occur syntactically directly as the type of any function parameter. These are still rejected semantically, so you will likely receive an error but these changes can be seen and parsed by procedural macros and conditional compilation.
Update Sep 10, 2020 tracked by Updatify
impl<'a> Reader for BufReader<'a> {} can now be impl Reader for BufReader<'_> {}. Lifetimes are still required to be defined in structs. const functions. These are currently a strict minimal subset of the const fn RFC. Refer to the language reference for what exactly is available. #[allow(clippy::filter_map)]. #[no_mangle] and #[export_name] attributes can now be located anywhere in a crate, not just in exported functions. Update Sep 10, 2020 tracked by Updatify
#[deprecated = "reason"] as a shorthand for #[deprecated(note = "reason")]. This was previously allowed by mistake but had no effect. #[attr()],#[attr[]], and #[attr{}] procedural macros. extern crate self as foo; to import your crate’s root into the extern prelude. riscv64imac-unknown-none-elf and riscv64gc-unknown-none-elf. -C linker-plugin-lto. This allows rustc to compile your Rust code into LLVM bitcode allowing LLVM to perform LTO optimisations across C/C++ FFI boundaries. powerpc64-unknown-freebsd. HashMap<K, V, S>‘s and HashSet<T, S>‘s basic methods. Most notably you no longer require the Hash trait to create an iterator. Ord trait bounds have been removed on some of BinaryHeap<T>‘s basic methods. Most notably you no longer require the Ord trait to create an iterator. Update Sep 10, 2020 tracked by Updatify
FnOnce, FnMut, and the Fn traits are now implemented for Box<FnOnce>, Box<FnMut>, and Box<Fn> respectively. unsafe fn call_unsafe(func: unsafe fn()) {
func()
}
pub fn main() {
unsafe { call_unsafe(|| {}); }
}
armv6-unknown-freebsd-gnueabihf and armv7-unknown-freebsd-gnueabihf targets. wasm32-unknown-wasi target. Thread will now show its ID in Debug output. StdinLock, StdoutLock, and StderrLock now implement AsRawFd. alloc::System now implements Default. Debug output ({:#?}) for structs now has a trailing comma on the last field. char::{ToLowercase, ToUppercase} now implement ExactSizeIterator. NonZero numeric types now implement FromStr. Update Sep 10, 2020 tracked by Updatify
r#), e.g. let r#for = true; crate in paths. This allows you to refer to the crate root in the path, e.g. use crate::foo; refers to foo in src/lib.rs. ::. Previously, using a external crate in a module without a use statement required let json = ::serde_json::from_str(foo); but can now be written as let json = serde_json::from_str(foo);. #[used] attribute to static items to prevent the compiler from optimising them away, even if they appear to be unused, e.g. #[used] static FOO: u32 = 1; Update Sep 10, 2020 tracked by Updatify
Update Sep 10, 2020 tracked by Updatify
dyn Send + fmt::Debug is now equivalent to dyn fmt::Debug + Send, where this was previously not the case. HashMap‘s implementation has been replaced with hashbrown::HashMap implementation. TryFromSliceError now implements From<Infallible>. mem::needs_drop is now available as a const fn. alloc::Layout::from_size_align_unchecked is now available as a const fn. String now implements BorrowMut<str>. io::Cursor now implements Default. NonNull::{dangling, cast} are now const fns. alloc crate is now stable. alloc allows you to use a subset of std (e.g. Vec, Box, Arc) in #![no_std] environments if the environment has access to heap memory allocation. String now implements From<&String>. Update Sep 10, 2020 tracked by Updatify