Latest in branch 1.75
1.75.0
Released 28 Dec 2023
(2 years ago)
SoftwareRust
Version1.75
Initial release1.75.0
28 Dec 2023
(2 years ago)
Latest release1.75.0
28 Dec 2023
(2 years ago)
Support status08 Feb 2024
(Ended 2 years, 3 months ago)
Release noteshttps://github.com/rust-lang/rust/releases/tag/1.75.0
Source codehttps://github.com/rust-lang/rust/tree/1.75.0
Downloadhttps://github.com/rust-lang/rust/releases/tag/1.75.0
Rust 1.75 ReleasesView full list

What Is New in Rust 1.75

Category Highlights
New Features async fn and return-position impl Trait in traits; pointer byte-offset APIs
Improvements BOLT layout optimization; rustc built with -Ccodegen-units=1 for faster compilation
Stabilized APIs Several APIs are now stable in const contexts

Can I use async functions and impl Trait in trait definitions in Rust 1.75?

Yes, Rust 1.75 now supports async fn and return-position impl Trait directly inside trait definitions, though some limitations remain.

This matters if you want to expose asynchronous behavior through a trait without resorting to boxed futures. The current restrictions include:

  • Only `async fn` without generic parameters is allowed.
  • The returned `impl Trait` must be a concrete future type that the compiler can infer.
  • These features are not yet usable in `const fn`.

Example:

trait Fetch {
    async fn get(&self) -> impl Future<Output = Result<String, Error>>;
}

In practice, most codebases can adopt this pattern with minimal changes, but keep an eye on the evolving limitation list for future releases.

How do I work with raw pointer byte offsets without casting in Rust 1.75?

Rust 1.75 introduces dedicated byte-offset methods on raw pointers, so you can add or subtract bytes without converting to *const u8.

This is handy for low-level FFI or manual memory layout work where byte granularity is required.

  • ptr::add_bytes(ptr, offset) - adds a byte offset.
  • ptr::sub_bytes(ptr, offset) - subtracts a byte offset.
  • Both methods are unsafe and preserve the original pointer type.

Example usage:

unsafe {
    let raw: *const u32 = data.as_ptr();
    let byte_ptr = ptr::add_bytes(raw, 8); // moves 8 bytes forward
    let value = *byte_ptr; // read as u32
}

Watch out for alignment requirements; the APIs do not perform automatic alignment checks.

What compiler performance improvements does Rust 1.75 bring?

Rust 1.75 ships with BOLT-optimized binary layout and builds rustc with a single codegen unit, delivering roughly 2 % and 1.5 % faster compile times on x86_64-linux.

These optimizations affect the `librustc_driver.so` library, improving instruction cache locality and allowing LLVM more aggressive inlining.

  • BOLT reorders functions based on profiling data, reducing branch mispredictions.
  • Setting -Ccodegen-units=1 forces a single LLVM codegen unit, enabling cross-function optimizations.

Most teams will notice a modest but consistent reduction in overall build time, especially for large crates with many dependencies.

Which const-context APIs became stable in Rust 1.75?

A handful of previously const-unstable functions are now stable, allowing them to be used inside const fn and const evaluations.

This matters if you perform compile-time calculations such as array length computation, const generic defaults, or static initialization.

  • Functions like ptr::addr_of_mut and certain iterator adapters are now const-stable.
  • Standard library types (e.g., Option::unwrap_or) have gained const implementations.

In practice, you can now write richer const fn bodies without resorting to nightly features, simplifying code that relies on compile-time guarantees.

Frequently Asked Questions

Does Rust 1.75 allow async functions in trait definitions?
Yes, you can now declare async fn inside traits, though some limitations still apply.

How can I add a byte offset to a raw pointer in Rust 1.75?
Use the new methods like ptr::add_bytes(ptr, offset) which work directly on *const T without casting.

What performance gain can I expect from the BOLT optimization in Rust 1.75?
Benchmarks show about a 2% reduction in mean wall-time for typical compile jobs on x86_64 Linux.

Are there any breaking changes in Rust 1.75 that require code modifications?
No breaking changes were introduced; existing code should compile unchanged.

Which const APIs became stable in Rust 1.75?
Several previously const-unstable functions are now usable in const contexts, enabling more compile-time calculations.

Releases In Branch 1.75

VersionRelease date
1.75.028 Dec 2023
(2 years ago)