$ the-wire · showcase
Rust fixes time-traveling UB, rolls back enum Debug change
By RepoJournal · Filed · About Rust
Rust's volatile-access semantics now allow traps, closing the last known case of time-traveling UB in the language.
Rust merged a semantics clarification: volatile accesses to non-AM memory may trap, per the unsafe-code-guidelines issue #610. RalfJung notes this fixes what he believes to be "the last case of 'time-traveling UB' we have in Rust," sequencing UB fully with observable events like I/O and volatile accesses [1]. This affects unsafe code that relies on volatile accesses never trapping, and any Miri or codegen behavior built on the old assumption.
A recent Debug implementation change for C-like enums has been reverted. rust-lang/rust#162164 reverts "Implement Debug for C-like enums with a concatenated string" [2], fixing issue #162124. C-like enums now produce the previous Debug output again, breaking any code that had started relying on the concatenated string format.
The miri rollup brought in several compiler fixes, including removing a wrong UnusedBraces lint for iterator loops in edition 2024, which had false positives [3], and making the box pattern removal diagnostic more actionable while removing box expression recovery [4]. Another change drops the `not(target_os = "vxworks")` guard in std's `set_perm_nofollow` after consolidation, fixing a build on VxWorks where `libc::O_NOFOLLOW` is not defined [5]. Cargo also landed a docs fix clarifying the vendor source config option, fixing an ambiguity in the description [6].
Two additions to the rust library landed: `Add` and `Sub` for `Complex` were implemented, and a new run-make test provides "a first line of defense against ABI mismatches" between C and Rust [7]. Custom allocator support was added to `(try_)map` on `UniqueArc` and `UniqueRc`, and Windows canonicalize got a fallback path [8].
On the internals side, the rustc next-gen region constraints work now always stores constraints in canonical form, using new `And`/`Or`/`LeafConstraint` types to avoid arbitrarily nested or/and structures [9].
Action items
- → If you rely on volatile accesses never trapping, review your unsafe code assumptions and update to match the new semantic guarantee. rust-lang/rust [plan]
- → If you adopted the Debug output for C-like enums in the recent nightly, update to the pre-revert format. rust-lang/rust [immediate]
- → Test your code on VxWorks if you use set_permissions, as the missing O_NOFOLLOW guard is now fixed. rust-lang/rust [monitor]
References
- [1] volatile: allow accesses to non-AM memory to trap ↗ rust-lang/rust
- [2] Revert "Implement Debug for C-like enums with a concatenated string" ↗ rust-lang/rust
- [3] Rollup merge of #162181 - chenyukang:yukang-fix-160741-unused-braces-for-iterator, r=jieyouxu ↗ rust-lang/miri
- [4] Rollup merge of #162008 - fmease:actionable-box-pat-diag, r=fee1-dead ↗ rust-lang/miri
- [5] Rollup merge of #162065 - physwkim:vxworks-set-perm-nofollow, r=ChrisDenton ↗ rust-lang/miri
- [6] docs: clarify cargo vendor source config option (#17435) ↗ rust-lang/cargo
- [7] add `Complex` ABI run-make test ↗ rust-lang/rust
- [8] Auto merge of #162254 - JonathanBrouwer:rollup-Q3zP05f, r=JonathanBrouwer ↗ rust-lang/rust
- [9] abby: always store nextgen region constraints in canonical form ↗ rust-lang/rust