diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-11-18 08:38:07 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-18 08:38:07 +0000 |
| commit | ea01a3aa9f45bc27a31a3d9c58f5dccb8dbd2bbf (patch) | |
| tree | e0d9b36eaca2229adca4a887990f20a335f4d36e | |
| parent | 64a73dcfba277587843bd2548b0d6990dc4a4b16 (diff) | |
| parent | 6196b928a44f469e37dc746a84a2175a560f09d4 (diff) | |
| download | rust-ea01a3aa9f45bc27a31a3d9c58f5dccb8dbd2bbf.tar.gz rust-ea01a3aa9f45bc27a31a3d9c58f5dccb8dbd2bbf.zip | |
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 <lnicola@dend.ro>
| -rw-r--r-- | crates/proc_macro_srv/src/abis/mod.rs | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/crates/proc_macro_srv/src/abis/mod.rs b/crates/proc_macro_srv/src/abis/mod.rs index 5d7c623b0a3..0de15b48329 100644 --- a/crates/proc_macro_srv/src/abis/mod.rs +++ b/crates/proc_macro_srv/src/abis/mod.rs @@ -69,22 +69,26 @@ impl Abi { symbol_name: String, info: RustCInfo, ) -> Result<Abi, LoadProcMacroDylibError> { - if info.version.0 != 1 { - Err(LoadProcMacroDylibError::UnsupportedABI) - } else if info.version.1 < 47 { - Err(LoadProcMacroDylibError::UnsupportedABI) - } else if info.version.1 < 54 { - let inner = unsafe { Abi_1_47::from_lib(lib, symbol_name) }?; - Ok(Abi::Abi1_47(inner)) - } else if info.version.1 < 56 { - let inner = unsafe { Abi_1_55::from_lib(lib, symbol_name) }?; - Ok(Abi::Abi1_55(inner)) - } else if info.version.1 < 57 { - let inner = unsafe { Abi_1_56::from_lib(lib, symbol_name) }?; - Ok(Abi::Abi1_56(inner)) - } else { - let inner = unsafe { Abi_1_58::from_lib(lib, symbol_name) }?; - Ok(Abi::Abi1_58(inner)) + // FIXME: this should use exclusive ranges when they're stable + // https://github.com/rust-lang/rust/issues/37854 + match (info.version.0, info.version.1) { + (1, 47..=54) => { + let inner = unsafe { Abi_1_47::from_lib(lib, symbol_name) }?; + Ok(Abi::Abi1_47(inner)) + } + (1, 55..=55) => { + let inner = unsafe { Abi_1_55::from_lib(lib, symbol_name) }?; + Ok(Abi::Abi1_55(inner)) + } + (1, 56..=57) => { + let inner = unsafe { Abi_1_56::from_lib(lib, symbol_name) }?; + Ok(Abi::Abi1_56(inner)) + } + (1, 58..) => { + let inner = unsafe { Abi_1_58::from_lib(lib, symbol_name) }?; + Ok(Abi::Abi1_58(inner)) + } + _ => Err(LoadProcMacroDylibError::UnsupportedABI), } } |
