Skip to content

Commit 3b1424e

Browse files
committed
rust-tools: rename RustEdition::{Rust => Edition}{2021,2024}
`Edition2024` more closely matches what we normally call it.
1 parent 6043bee commit 3b1424e

6 files changed

Lines changed: 16 additions & 16 deletions

File tree

c2rust-rust-tools/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ pub enum RustEdition {
1212
/// The default is edition 2021 because `c2rust-refactor`,
1313
/// based on `nightly-2022-08-08`, only understands up to edition 2021.
1414
#[default]
15-
Rust2021,
16-
Rust2024,
15+
Edition2021,
16+
Edition2024,
1717
}
1818

1919
impl RustEdition {
20-
pub const ALL: &[Self] = &[Self::Rust2021, Self::Rust2024];
20+
pub const ALL: &[Self] = &[Self::Edition2021, Self::Edition2024];
2121

2222
pub const fn as_str(&self) -> &'static str {
2323
match self {
24-
Self::Rust2021 => "2021",
25-
Self::Rust2024 => "2024",
24+
Self::Edition2021 => "2021",
25+
Self::Edition2024 => "2024",
2626
}
2727
}
2828

@@ -32,9 +32,9 @@ impl RustEdition {
3232
pub const fn toolchain(&self) -> &'static str {
3333
match self {
3434
// 1.70 (1.68 for syn v2.0, 1.70 for sparse registry)
35-
Self::Rust2021 => "+nightly-2023-04-15",
35+
Self::Edition2021 => "+nightly-2023-04-15",
3636
// This doesn't really need to be pinned, but pin it for stability.
37-
Self::Rust2024 => "+nightly-2026-03-03",
37+
Self::Edition2024 => "+nightly-2026-03-03",
3838
}
3939
}
4040
}
@@ -49,7 +49,7 @@ impl FromStr for RustEdition {
4949
type Err = String;
5050

5151
fn from_str(s: &str) -> Result<Self, Self::Err> {
52-
let choices = [Self::Rust2021, Self::Rust2024];
52+
let choices = [Self::Edition2021, Self::Edition2024];
5353
choices
5454
.into_iter()
5555
.find(|choice| choice.as_str() == s)

c2rust-transpile/src/build_files/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ fn emit_cargo_toml<'lcmd>(
330330
"edition": tcfg.edition.as_str(),
331331
// This is already the default in Rust 1.77,
332332
// and edition 2024 was released in Rust 1.85.
333-
"strip_debuginfo_release": tcfg.edition < RustEdition::Rust2024,
333+
"strip_debuginfo_release": tcfg.edition < RustEdition::Edition2024,
334334
"crate_types": ccfg.link_cmd.r#type.as_cargo_types(),
335335
"is_library": ccfg.link_cmd.r#type.is_library(),
336336
"lib_rs_file": get_lib_rs_file_name(tcfg),

c2rust-transpile/src/translator/builtins.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ impl<'c> Translation<'c> {
414414

415415
"__builtin_arm_yield" => {
416416
let fn_name = "__yield";
417-
if self.tcfg.edition < RustEdition::Rust2024 {
417+
if self.tcfg.edition < RustEdition::Edition2024 {
418418
self.use_feature("stdsimd");
419419
} else {
420420
// Edition 2024 was release in Rust 1.85.

c2rust-transpile/src/translator/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ pub fn stmts_block(mut stmts: Vec<Stmt>) -> Block {
373373

374374
/// Whether `extern` blocks can be `unsafe` in this edition.
375375
fn extern_block_unsafety(edition: RustEdition) -> Unsafety {
376-
if edition >= RustEdition::Rust2024 {
376+
if edition >= RustEdition::Edition2024 {
377377
Unsafety::Unsafe
378378
} else {
379379
Unsafety::Normal
@@ -382,7 +382,7 @@ fn extern_block_unsafety(edition: RustEdition) -> Unsafety {
382382

383383
/// Whether attributes can be `unsafe` in this edition.
384384
fn attr_unsafety(edition: RustEdition) -> Unsafety {
385-
if edition >= RustEdition::Rust2024 {
385+
if edition >= RustEdition::Edition2024 {
386386
Unsafety::Unsafe
387387
} else {
388388
Unsafety::Normal
@@ -1595,7 +1595,7 @@ impl<'c> Translation<'c> {
15951595
/// Called when translation makes use of a language feature that will require a feature-gate.
15961596
pub fn use_feature(&self, feature: &'static str) {
15971597
if matches!(feature, "asm" | "label_break_value" | "raw_ref_op")
1598-
&& self.tcfg.edition >= RustEdition::Rust2024
1598+
&& self.tcfg.edition >= RustEdition::Edition2024
15991599
{
16001600
return;
16011601
}

c2rust-transpile/src/translator/simd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl<'c> Translation<'c> {
160160
.into());
161161
}
162162

163-
if self.tcfg.edition < RustEdition::Rust2024 {
163+
if self.tcfg.edition < RustEdition::Edition2024 {
164164
// Edition 2024 was release in Rust 1.85.
165165
// In Rust 1.78, `#![feature(stdsimd)]` was removed and split into individual features.
166166
// All of the x86_64 parts (that we use at least) were stabilized.

c2rust-transpile/tests/snapshots.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,13 @@ impl<'a> TranspileTest<'a> {
258258
transpile_snapshot(
259259
&platform,
260260
&c_path,
261-
RustEdition::Rust2021,
261+
RustEdition::Edition2021,
262262
expect_compile_error_edition_2021,
263263
);
264264
transpile_snapshot(
265265
&platform,
266266
&c_path,
267-
RustEdition::Rust2024,
267+
RustEdition::Edition2024,
268268
expect_compile_error_edition_2024,
269269
);
270270
}

0 commit comments

Comments
 (0)