Skip to content

Commit 95bd163

Browse files
pvdrznyurik
andcommitted
Add support for edition 2024
Co-authored-by: Yuri Astrakhan <[email protected]>
1 parent 19f5f82 commit 95bd163

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

bindgen/features.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ impl std::error::Error for InvalidRustEdition {}
137137
define_rust_editions! {
138138
Edition2018(2018) => 31,
139139
Edition2021(2021) => 56,
140+
Edition2024(2024) => 85,
140141
}
141142

142143
impl RustTarget {
@@ -160,9 +161,9 @@ impl Default for RustEdition {
160161
/// This macro defines the [`RustTarget`] and [`RustFeatures`] types.
161162
macro_rules! define_rust_targets {
162163
(
163-
Nightly => {$($nightly_feature:ident $(($nightly_edition:literal))* $(: #$issue:literal)?),* $(,)?} $(,)?
164+
Nightly => {$($nightly_feature:ident $(($nightly_edition:literal))|* $(: #$issue:literal)?),* $(,)?} $(,)?
164165
$(
165-
$variant:ident($minor:literal) => {$($feature:ident $(($edition:literal))* $(: #$pull:literal)?),* $(,)?},
166+
$variant:ident($minor:literal) => {$($feature:ident $(($edition:literal))|* $(: #$pull:literal)?),* $(,)?},
166167
)*
167168
$(,)?
168169
) => {
@@ -253,7 +254,7 @@ define_rust_targets! {
253254
},
254255
Stable_1_77(77) => {
255256
offset_of: #106655,
256-
literal_cstr(2021): #117472,
257+
literal_cstr(2021)|(2024): #117472,
257258
},
258259
Stable_1_73(73) => { thiscall_abi: #42202 },
259260
Stable_1_71(71) => { c_unwind_abi: #106075 },
@@ -404,6 +405,26 @@ impl Default for RustFeatures {
404405
mod test {
405406
use super::*;
406407

408+
#[test]
409+
fn release_versions_for_editions() {
410+
assert_eq!(
411+
"1.33".parse::<RustTarget>().unwrap().latest_edition(),
412+
RustEdition::Edition2018
413+
);
414+
assert_eq!(
415+
"1.56".parse::<RustTarget>().unwrap().latest_edition(),
416+
RustEdition::Edition2021
417+
);
418+
assert_eq!(
419+
"1.85".parse::<RustTarget>().unwrap().latest_edition(),
420+
RustEdition::Edition2024
421+
);
422+
assert_eq!(
423+
"nightly".parse::<RustTarget>().unwrap().latest_edition(),
424+
RustEdition::Edition2024
425+
);
426+
}
427+
407428
#[test]
408429
fn target_features() {
409430
let features =

0 commit comments

Comments
 (0)