Skip to content

transpile: fix atomic intrinsics in edition 2024 #1658

Merged
kkysen merged 11 commits intomasterfrom
kkysen/transpile-edition-2024-atomics
Mar 18, 2026
Merged

transpile: fix atomic intrinsics in edition 2024 #1658
kkysen merged 11 commits intomasterfrom
kkysen/transpile-edition-2024-atomics

Conversation

@kkysen
Copy link
Contributor

@kkysen kkysen commented Mar 14, 2026

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.

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.
@kkysen kkysen force-pushed the kkysen/transpile-edition-2024-varargs branch from 5bb5fea to 6ede792 Compare March 14, 2026 06:06
@kkysen kkysen force-pushed the kkysen/transpile-edition-2024-atomics branch from 07c2635 to 7cc2ca4 Compare March 14, 2026 06:07
@kkysen kkysen changed the base branch from kkysen/transpile-edition-2024-varargs to master March 14, 2026 06:08
@kkysen kkysen changed the title transpile: add edition 2024 support for atomic intrinsics transpile: fix atomic intrinsics in edition 2024 Mar 14, 2026
@kkysen kkysen force-pushed the kkysen/transpile-edition-2024-atomics branch 4 times, most recently from 34cd744 to 0b19aae Compare March 17, 2026 02:57
@kkysen kkysen force-pushed the kkysen/transpile-edition-2024-atomics branch from 0b19aae to 3ec0612 Compare March 18, 2026 04:32
kkysen added 11 commits March 17, 2026 21:50
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.
…ying at call sites

This removes a bit of duplication, but also centralizes this logic,
which is much easier to follow when it's all together.
@kkysen kkysen force-pushed the kkysen/transpile-edition-2024-atomics branch from 174ad0c to e8192bb Compare March 18, 2026 04:51
@kkysen kkysen merged commit 669198c into master Mar 18, 2026
11 checks passed
@kkysen kkysen deleted the kkysen/transpile-edition-2024-atomics branch March 18, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants