transpile: upgrade most things for edition 2024#1643
Conversation
f86aec4 to
d1ae9eb
Compare
19c6138 to
db5a90e
Compare
d1ae9eb to
02b9ca2
Compare
73c45e4 to
1a4774e
Compare
|
In the 2024 edition, the |
9af29df to
43f7566
Compare
02b9ca2 to
b3ab33d
Compare
5ecf3f2 to
6d4cba2
Compare
kkysen
left a comment
There was a problem hiding this comment.
In the 2024 edition, the
unsafe-op-in-unsafe-fnlint now also warns by default. A simple fix could be to just add an extraunsafe { }block to each function, but ultimately marking only the actual unsafe operations as unsafe could be preferred.
It's still just a warning, and we have plenty of warnings already, so I don't think I'll fix it as part of this PR, but you're right, we should fix it. We can do an outer unsafe {} block first, and if possible, narrow it.
2273281 to
a70695c
Compare
…dition 2024 where it wasn't the default
This will help as I'm upgrading to edition 2024 and fix errors one by one.
…rustc` `nightly-2023-04-15` doesn't know about edition 2024 yet. Previously, `rustfmt` wasn't using a specific toolchain, so it would just default to whatever `rust-toolchain.toml` was there. Now it properly is overridden like `rustc` was being.
…m scratch with the right toolchain `generated-rust-toolchain.toml` is very simple, so embedding it should be fine. We previously didn't since `test_translator.py` just copied it, since it doesn't use `--emit-build-files`, for *reasons*. But now that the toolchain depends on the edition, we can't do that. So we just duplicate the simple logic in `fn emit_rust_toolchain`.
These are `incomplete_arrays.c` and `main_fn.c`.
…ion = "")]` in edition 2024 This reworks the previous basic support for `#[unsafe(no_mangle)]` to make it more robust. `fn Builder::meta` is added, which checks `self.unsafety`, and if it's `unsafe`, adds a wrapper `unsafe()` around the meta. This is then used in all of the `mk().meta_*` functions to ensure they use the `unsafe` wrapping. It has to be done at this level because sometimes these `unsafe`s aren't at the top-level, like `#[cfg_attr(target_os = "linux", unsafe(link_section = ".init_array"))]`.
* Fixes #1298. Luckily, I left comments saying how to do this in more recent Rust versions. We still haven't fixed the missing `cfg_attr` in `#![cfg_attr(target_arch = "arm", stdarch_arm_neon_intrinsics)]` when using `self.use_feature`, but we're not testing `target_arch = "arm"` at the moment.
…t tests are switched to it
…f `-` in `.rs` names
…e suffixes so that related files are next to each
…r `c-decls`, too
This easy to do, gives better test coverage, and allows us to see the failing snapshots on edition 2024 for tests that haven't been converted yet.
…e `fn use_feature`
… in edition 2024
…hind `edition < 2021`
…`test_*.rs` files This allows us to move individual test directories to edition 2024.
b4012b2 to
2810fc6
Compare
…package.edition`
…unsafe` blocks in each `unsafe fn`
`Edition2024` more closely matches what we normally call it.
2050f67 to
9bbfccc
Compare
This fixes the following differences with edition 2024:
#[unsafe(no_mangle)]#[unsafe(export_name = "")]#[unsafe(link_section = "")]unsafe extern "C" {unsafe fns andsafe fns inunsafe extern "C" {}sunsafe fns#![feature(stdsimd)]removed and split up#![feature(raw_ref_op)]removed#![feature(label_break_value)]removed#![feature(asm)]removed[profile.release] strip = "debuginfo"being the defaultatomics.c)genreserved keyword (keywords.c)VaListImpl(varargs.c)#[warn(unsafe_op_in_unsafe_fn)]enabled by defaulttests/unit/, we add#![allow(unsafe_op_in_unsafe_fn)]for now.unsafeblock inunsafe fns (or finer-grained ones) we can do later.pref_align_ofremoved (Remove rustc's notion of "preferred" alignment AKA__alignofrust-lang/rust#141803)__alignofThis also runs the correct
rustfmt, as we were previously just picking up whichever onerustupresolved.#![feature(stdsimd)]was split up and removed in 1.78, so stop emitting it when we upgrade past 1.65 #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.