Change8

1.98.0

Breaking Changes
📦 rust-languageView on GitHub →
6 breaking19 features🐛 17 fixes🔧 58 symbols

Summary

This release enhances Rust's language features with improved lifetime management and new lints, stabilizes numerous APIs including string and slice manipulation methods, and updates platform support. It also includes several compatibility adjustments and bug fixes.

⚠️ Breaking Changes

  • The `repr(transparent)` attribute is now stricter about which fields are considered trivial and can be ignored. Fields that are `repr(C)` types, have private fields, or are `#[non_exhaustive]` are no longer considered trivial. This may affect layout calculations and compatibility with existing code that relies on the previous, more lenient behavior.
  • Where-bounds of the form `Type = Type` and `Type == Type` are no longer syntactically allowed. Code using these forms must be updated to use the correct syntax.
  • The UNSAFE_CODE lint is now consistently emitted for all unsafe attributes. Previously, it was not always emitted for certain unsafe attributes, which could lead to overlooked unsafe code. Ensure all unsafe attributes are now correctly handled and linted.
  • On Emscripten, the WASM exception handling ABI is now unconditionally used. The `-Zemscripten-wasm-eh=false` flag to switch back to JS exceptions has been removed. This change may affect applications that relied on the previous behavior or the ability to switch ABIs.
  • Solaris: The `File::lock` implementation has been removed as it had incorrect semantics. It now returns 'unsupported' instead of attempting to lock. Code relying on `File::lock` on Solaris will need to be updated to handle this change.
  • The `derive(PartialOrd)` implementation now has a fast path when deriving `Ord`. This can break crates where a type's `PartialOrd` and `Ord` implementations were inconsistent with each other, as the new implementation enforces stricter consistency.

Migration Steps

  1. Update code that uses `Type = Type` or `Type == Type` where-bounds to the correct syntax.
  2. Review code that relies on the previous, more lenient behavior of `repr(transparent)` regarding trivial fields.
  3. Ensure all unsafe attributes are now correctly handled and linted due to the consistent emission of the `UNSAFE_CODE` lint.
  4. Update applications that relied on the ability to switch between WASM and JS exception handling ABIs on Emscripten.
  5. Update code that uses `File::lock` on Solaris to handle the 'unsupported' return value.
  6. Review code where `PartialOrd` and `Ord` implementations might have been inconsistent, as the new `derive(PartialOrd)` fast path enforces stricter consistency.

✨ New Features

  • Allow shortening lifetime of `&mut` when unsize-coercing, even in an invariant position, enabling coercion of `Cell<&'long mut i32>` to `Cell<&'short mut dyn Send>`.
  • Added `invalid_runtime_symbol_definitions` lint (deny-by-default) and `suspicious_runtime_symbol_definitions` lint (warn-by-default) to target core runtime symbols like `memcmp`, `memset`, `strlen`.
  • Added `c_void_returns` lint (warn-by-default) to check `core::ffi::c_void` as a return type.
  • Added `powerpc64-unknown-linux-gnuelfv2` as a Tier 3 platform support target.
  • Added `aarch64-unknown-linux-pauthtest` as a Tier 3 platform support target.
  • Promoted `thumbv7a-none-eabi`, `thumbv7a-none-eabihf`, `thumbv7r-none-eabi`, `thumbv7r-none-eabihf`, and `thumbv8r-none-eabihf` to Tier 2 platform support.
  • Stabilized LoongArch CRC Intrinsics.
  • The `derive` macro is now available at `{core,std}::derive`.
  • Stabilized `str::substr_range`.
  • Stabilized `[T]::subslice_range`.
  • Stabilized `core::fmt::NumBuffer`.
  • Stabilized `<{integer}>::format_into`.
  • Stabilized `Send/Sync` for `std::process::CommandArgs`.
  • Stabilized `{fN}::algebraic_add`, `{fN}::algebraic_sub`, `{fN}::algebraic_mul`, `{fN}::algebraic_div`, `{fN}::algebraic_rem`.
  • Stabilized `NonZero<{integer}>::from_str_radix`.
  • Stabilized `String::from_utf16le`, `String::from_utf16le_lossy`, `String::from_utf16be`, `String::from_utf16be_lossy`.
  • Stabilized `[T]::strip_circumfix` and `str::strip_circumfix`.
  • Stabilized `Atomic<T>::from_mut`, `Atomic<T>::get_mut_slice`, `Atomic<T>::from_mut_slice`.
  • Stabilized `std::range::legacy`.

🐛 Bug Fixes

  • Changed `Location<'_>` lifetime to `'static` in `Panic[Hook]Info`.
  • Documented panic in `RangeInclusive::from(legacy::RangeInclusive)`.
  • Documented that `ManuallyDrop`'s `Box` interaction has been fixed.
  • Fixed an issue where lifetime bounds of trait object types might resolve differently or be rejected in specific niche scenarios when fully elided.
  • Fixed an error in more cases of ambiguous imports.
  • Fixed the destructor implementation for thread locals on Windows to use Fiber Local Storage (FLS).
  • Converted some cases of the `ambiguous_glob_imports` lint into a hard error.
  • Ensured `Send`/`Sync` is not implemented for `std::env::Vars{,Os}`.
  • Fixed an issue where, in some attributes, arguments were not properly rejected.
  • Correctly checked whether types have equal size in `transmute()` when some `repr` attributes are involved.
  • More characters are now escaped when printing strings and chars.
  • Added a temporary scope to `assert_eq` and `assert_ne`.
  • Closed a hole in the pattern matching structural equality check, preventing cases where a match of a constant would be allowed despite disagreeing with a manually written `PartialEq` implementation, when a `derive(PartialEq)` implementation for that type also exists.
  • On Emscripten, the WASM exception handling ABI is now unconditionally used, removing the `-Zemscripten-wasm-eh=false` flag.
  • Removed `File::lock` implementation on Solaris due to incorrect semantics, now returns 'unsupported'.
  • Windows-gnu targets now specify baseline tools versions.
  • rustfmt now discovers module files defined in `cfg_select!`, potentially formatting more code.

Affected Symbols