Skip to content

Commit ac0c52b

Browse files
pvdrznyurik
andcommitted
Add support for edition 2024
Co-authored-by: Yuri Astrakhan <YuriAstrakhan@gmail.com>
1 parent 744cf2b commit ac0c52b

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

bindgen/features.rs

+24-3
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ impl std::error::Error for InvalidRustEdition {}
139139
define_rust_editions! {
140140
Edition2018(2018) => 31,
141141
Edition2021(2021) => 56,
142+
Edition2024(2024) => 85,
142143
}
143144

144145
impl RustTarget {
@@ -162,9 +163,9 @@ impl Default for RustEdition {
162163
/// This macro defines the [`RustTarget`] and [`RustFeatures`] types.
163164
macro_rules! define_rust_targets {
164165
(
165-
Nightly => {$($nightly_feature:ident $(($nightly_edition:literal))* $(: #$issue:literal)?),* $(,)?} $(,)?
166+
Nightly => {$($nightly_feature:ident $(($nightly_edition:literal))|* $(: #$issue:literal)?),* $(,)?} $(,)?
166167
$(
167-
$variant:ident($minor:literal) => {$($feature:ident $(($edition:literal))* $(: #$pull:literal)?),* $(,)?},
168+
$variant:ident($minor:literal) => {$($feature:ident $(($edition:literal))|* $(: #$pull:literal)?),* $(,)?},
168169
)*
169170
$(,)?
170171
) => {
@@ -255,7 +256,7 @@ define_rust_targets! {
255256
},
256257
Stable_1_77(77) => {
257258
offset_of: #106655,
258-
literal_cstr(2021): #117472,
259+
literal_cstr(2021)|(2024): #117472,
259260
},
260261
Stable_1_73(73) => { thiscall_abi: #42202 },
261262
Stable_1_71(71) => { c_unwind_abi: #106075 },
@@ -406,6 +407,26 @@ impl Default for RustFeatures {
406407
mod test {
407408
use super::*;
408409

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

0 commit comments

Comments
 (0)