transpile: fix atomic intrinsics in edition 2024 #1658
Open
transpile: fix atomic intrinsics in edition 2024 #1658
Conversation
kkysen
commented
Mar 14, 2026
| ) -> TranslationResult<WithStmts<Box<Expr>>> { | ||
| self.use_feature("core_intrinsics"); | ||
|
|
||
| // Emit `atomic_cxchg(a0, a1, a2).idx` |
Contributor
Author
There was a problem hiding this comment.
Some of these comments I left as is. I'm not sure how to phrase them with edition 2024, and also even with just edition 2021, this leaves out cxchgweak.
15 tasks
kkysen
added a commit
that referenced
this pull request
Mar 14, 2026
This fixes the following differences with edition 2024:
* [x] `#[unsafe(no_mangle)]`
* [x] `#[unsafe(export_name = "")]`
* [x] `#[unsafe(link_section = "")]`
* [x] `unsafe extern "C" {`
* [ ] `unsafe fn`s and `safe fn`s in `unsafe extern "C" {}`s
* not required, default to `unsafe fn`s
* [x] `#![feature(stdsimd)]` removed and split up
* [x] stabilized `#![feature(raw_ref_op)]` removed
* [x] stabilized `#![feature(label_break_value)]` removed
* [x] stabilized `#![feature(asm)]` removed
* [x] `[profile.release] strip = "debuginfo"` being the default
* [ ] (#1658) updated atomic intrinsics (`atomics.c`)
* [ ] `gen` reserved keyword (`keywords.c`)
* [ ] (#1657) updated `VaListImpl` (`varargs.c`)
* [ ] `#[warn(unsafe_op_in_unsafe_fn)]` enabled by default
* In `tests/unit/`, we add `#![allow(unsafe_op_in_unsafe_fn)]` for now.
* Proper fix of an outer `unsafe` block in `unsafe fn`s (or
finer-grained ones) we can do later.
* [ ] (#1656) `pref_align_of` removed
(rust-lang/rust#141803)
* used to translate `__alignof`
* no alternative, so may have to drop support
This also runs the correct `rustfmt`, as we were previously just picking
up whichever one `rustup` resolved.
* Fixes #1298.
This updates all of the transpiler snapshot tests and `tests/unit/`
tests that work on edition 2024 with the above fixes. The remaining
fixes I'll fix in separate PRs, as they might be trickier.
5bb5fea to
6ede792
Compare
07c2635 to
7cc2ca4
Compare
7cc2ca4 to
b535b6d
Compare
In edition 2024 (not sure exactly what nightly), atomic intrinsics became const generic over the `Ordering`. At the moment, this is re-parsed with `syn::parse_str` instead of building it with `mk()`/`Builder`. Codex suggested this because `Builder` doesn't support const generic expressions. We could add support in `c2rust-ast-builder`, although parsing with `syn` seems simpler to me.
b535b6d to
15bb618
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Most of these commits are refactoring things to be in a shape where adding edition 2024 support is simple. Then the last commit, 07c2635, actually adds edition 2024 support.