transpile: replace pref_align_of with align_of in edition 2024#1656
transpile: replace pref_align_of with align_of in edition 2024#1656
pref_align_of with align_of in edition 2024#1656Conversation
thedataking
left a comment
There was a problem hiding this comment.
The translation proposed here seems valid.
However, the translation of GNUs __alignof__ is no longer bit-for-bit faithful (e.g. __alignof__(double) == 8 but alignof(double) == 4 on i386) and the source code might rely on a particular layout via static asserts or allocation decisions. Would it make sense to emit a warning?
kkysen
left a comment
There was a problem hiding this comment.
The translation proposed here seems valid.
However, the translation of GNUs
__alignof__is no longer bit-for-bit faithful (e.g.__alignof__(double) == 8butalignof(double) == 4on i386) and the source code might rely on a particular layout via static asserts or allocation decisions. Would it make sense to emit a warning?
Yup, we could definitely emit a warning. I didn't want to make it a hard error, but I think a warning makes a lot of sense.
220a2dd to
79cae37
Compare
d717f6a to
20c2fed
Compare
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.
Since `core::intrinsics::pref_align_of` was removed, we can't fully support `__alignof`/`__alignof__` anymore, but using normal `core::mem::align_of` should still be a valid value. This also updates `tests/unit/misc` to edition 2024, as its usage of `__alignof__` was the only thing holding it back.
82b1b8f to
5793dbe
Compare
Since
core::intrinsics::pref_align_ofwas removed, we can't fully support__alignof/__alignof__anymore, but using normalcore::mem::align_ofshould still be a valid value.This also updates
tests/unit/miscto edition 2024, as its usage of__alignof__was the only thing holding it back.