Skip to content

Commit ea01a3a

Browse files
bors[bot]lnicola
andauthored
Merge #10799
10799: fix: Fix proc macro ABI version checks r=lnicola a=lnicola If I'm reading this right, we used to pick `Abi1_55` for `1.54` and `Abi_1_58` for `1.57`. CC `@alexjg` (just in case I'm misinterpreting the code), CC #10772. bors r+ Co-authored-by: Laurențiu Nicola <[email protected]>
2 parents 64a73dc + 6196b92 commit ea01a3a

File tree

1 file changed

+20
-16
lines changed
  • crates/proc_macro_srv/src/abis

1 file changed

+20
-16
lines changed

crates/proc_macro_srv/src/abis/mod.rs

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,26 @@ impl Abi {
6969
symbol_name: String,
7070
info: RustCInfo,
7171
) -> Result<Abi, LoadProcMacroDylibError> {
72-
if info.version.0 != 1 {
73-
Err(LoadProcMacroDylibError::UnsupportedABI)
74-
} else if info.version.1 < 47 {
75-
Err(LoadProcMacroDylibError::UnsupportedABI)
76-
} else if info.version.1 < 54 {
77-
let inner = unsafe { Abi_1_47::from_lib(lib, symbol_name) }?;
78-
Ok(Abi::Abi1_47(inner))
79-
} else if info.version.1 < 56 {
80-
let inner = unsafe { Abi_1_55::from_lib(lib, symbol_name) }?;
81-
Ok(Abi::Abi1_55(inner))
82-
} else if info.version.1 < 57 {
83-
let inner = unsafe { Abi_1_56::from_lib(lib, symbol_name) }?;
84-
Ok(Abi::Abi1_56(inner))
85-
} else {
86-
let inner = unsafe { Abi_1_58::from_lib(lib, symbol_name) }?;
87-
Ok(Abi::Abi1_58(inner))
72+
// FIXME: this should use exclusive ranges when they're stable
73+
// https://github.com/rust-lang/rust/issues/37854
74+
match (info.version.0, info.version.1) {
75+
(1, 47..=54) => {
76+
let inner = unsafe { Abi_1_47::from_lib(lib, symbol_name) }?;
77+
Ok(Abi::Abi1_47(inner))
78+
}
79+
(1, 55..=55) => {
80+
let inner = unsafe { Abi_1_55::from_lib(lib, symbol_name) }?;
81+
Ok(Abi::Abi1_55(inner))
82+
}
83+
(1, 56..=57) => {
84+
let inner = unsafe { Abi_1_56::from_lib(lib, symbol_name) }?;
85+
Ok(Abi::Abi1_56(inner))
86+
}
87+
(1, 58..) => {
88+
let inner = unsafe { Abi_1_58::from_lib(lib, symbol_name) }?;
89+
Ok(Abi::Abi1_58(inner))
90+
}
91+
_ => Err(LoadProcMacroDylibError::UnsupportedABI),
8892
}
8993
}
9094

0 commit comments

Comments
 (0)