what's new in the latest release of rust lang
- User
what's new in the latest release of rust lang
- Assistant
The latest stable release of Rust is version 1.83.0, which became available on November 28, 2024[1].
Language Enhancements:
-
Const Context Improvements: The release stabilizes the use of
&mut,*mut,&Cell, and*const Cellwithin constant contexts, allowing for more flexible and efficient code inconstfunctions. -
Static References in Const Initializers: It's now possible to create references to static items within
constinitializers, enhancing the expressiveness of constant definitions. -
Raw Lifetimes and Labels: The introduction of raw lifetimes and labels (
'r#ident) provides a more precise way to annotate lifetimes, improving code clarity and safety. -
Atomic and Non-Atomic Reads: The behavior when atomic and non-atomic reads race has been clearly defined, ensuring more predictable and reliable concurrent programming.
-
Non-Exhaustive Structs: Non-exhaustive structs can now be empty, offering greater flexibility in struct definitions.
-
Disallow Implicit Coercions from
!: Implicit coercions from the never type!are now disallowed, preventing potential logical errors in code. -
const externFunctions: It's now possible to defineconst externfunctions for other calling conventions, expanding the interoperability of constant functions. -
Stabilization of
expr_2021Macro Fragment Specifier: Theexpr_2021macro fragment specifier has been stabilized across all editions, standardizing macro usage. -
non_local_definitionsLint Update: Thenon_local_definitionslint now triggers on less code and issues warnings by default, promoting cleaner code practices.
Compiler Updates:
-
Deprecation of
-Csoft-floatFlag: The unsound-Csoft-floatflag has been deprecated, encouraging the use of more reliable floating-point operations. -
Addition of New Tier 3 Targets: Several new Tier 3 targets have been added, including:
-
aarch64_unknown_nto_qnx700 -
arm64e-apple-tvos -
armv7-rtems-eabihf -
loongarch64-unknown-linux-ohos -
riscv32-wrs-vxworksandriscv64-wrs-vxworks -
riscv32{e|em|emc}-unknown-none-elf -
x86_64-unknown-hurd-gnu -
x86_64-unknown-trusty
These additions enhance Rust's support across various platforms.
-
Library and Cargo Enhancements:
-
PartialEqforExitCode: TheExitCodetype now implements thePartialEqtrait, facilitating easier comparisons. -
catch_unwindDocumentation: It's documented thatcatch_unwindcan handle foreign exceptions without undefined behavior, though the exact behavior remains unspecified. -
DefaultImplementation for HashMap/HashSet Iterators: Iterators forHashMapandHashSetnow implement theDefaulttrait, simplifying their initialization. -
Unicode Version Bump: The Unicode version has been updated to 16.0.0, ensuring compatibility with the latest Unicode standards.
-
Documentation Update for
ptr::add/sub: The documentation forptr::addandptr::subhas been revised to clarify that they are not equivalent tooffset.
Cargo and Rustdoc Improvements:
-
New
CARGO_MANIFEST_PATHEnvironment Variable: A new environment variable,CARGO_MANIFEST_PATH, has been introduced. Similar toCARGO_MANIFEST_DIR, it points directly to the manifest file, providing more precise control over Cargo's behavior. -
package.autolibin Manifest: Thepackage.autolibfield has been added to the manifest, allowing users to disable[lib]auto-discovery when necessary. -
Support Level Declaration in Cargo: Crates can now declare their support level in Cargo's Charter or crate documentation, enhancing transparency and user trust.
-
Intentional Artifacts as 'Small' Changes: New Intentional Artifacts are now declared as 'small' changes, streamlining the release process.
-
Rustdoc Sidebar Enhancement: The sidebar (hamburger menu) table of contents in Rustdoc now includes the
# headersfrom the main item's documentation comment, improving navigation and usability.
Compatibility Notes:
-
Function Pointer ABI Warnings: Warnings have been introduced for function pointers using unsupported ABI strings, promoting safer and more compatible code.
-
Type Signature Checks in Function Pointer Casts: The compiler now checks the well-formedness of the source type's signature in function pointer casts, addressing a soundness issue related to casting function items to function pointers.
-
Equality in Type Dependent Paths: Equality is now used instead of subtyping when resolving type-dependent paths, enhancing type resolution accuracy.
-
macOS Linking Behavior: Linking on macOS now correctly includes Rust's default deployment target. Users may need to adjust the
MACOSX_DEPLOYMENT_TARGETor modify#[link]attributes to point to the correct frameworks. -
Error for
repr(Rust)on Non-Struct/Enum/Union Items: Rust now raises an error forrepr(Rust)applied to non-struct/enum/unionitems, as it previously had no effect. -
**Hard Error for `deprecated_cfg_attr_crate_type_name
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.