Skip to content

Commit c8c1d5d

Browse files
pvdrznyurik
andcommitted
Add support for edition 2024
Co-authored-by: Yuri Astrakhan <[email protected]>
1 parent 22f2653 commit c8c1d5d

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
) => {
@@ -252,7 +253,7 @@ define_rust_targets! {
252253
},
253254
Stable_1_77(77) => {
254255
offset_of: #106655,
255-
literal_cstr(2021): #117472,
256+
literal_cstr(2021)|(2024): #117472,
256257
},
257258
Stable_1_73(73) => { thiscall_abi: #42202 },
258259
Stable_1_71(71) => { c_unwind_abi: #106075 },
@@ -401,6 +402,26 @@ impl Default for RustFeatures {
401402
mod test {
402403
use super::*;
403404

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

0 commit comments

Comments
 (0)