Split is_stable from rustc_target::spec::abi::is_enabled.
This commit is contained in:
parent
84365fff0a
commit
e60016eb55
1 changed files with 110 additions and 160 deletions
|
@ -109,175 +109,125 @@ pub enum AbiDisabled {
|
||||||
Unrecognized,
|
Unrecognized,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gate_feature_post(
|
|
||||||
features: &rustc_feature::Features,
|
|
||||||
feature: Symbol,
|
|
||||||
span: Span,
|
|
||||||
explain: &'static str,
|
|
||||||
) -> Result<(), AbiDisabled> {
|
|
||||||
if !features.enabled(feature) && !span.allows_unstable(feature) {
|
|
||||||
Err(AbiDisabled::Unstable { feature, explain })
|
|
||||||
} else {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn is_enabled(
|
pub fn is_enabled(
|
||||||
features: &rustc_feature::Features,
|
features: &rustc_feature::Features,
|
||||||
span: Span,
|
span: Span,
|
||||||
name: &str,
|
name: &str,
|
||||||
) -> Result<(), AbiDisabled> {
|
) -> Result<(), AbiDisabled> {
|
||||||
|
let s = is_stable(name);
|
||||||
|
if let Err(AbiDisabled::Unstable { feature, .. }) = s {
|
||||||
|
if features.enabled(feature) || span.allows_unstable(feature) {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_stable(name: &str) -> Result<(), AbiDisabled> {
|
||||||
match name {
|
match name {
|
||||||
// Stable
|
// Stable
|
||||||
"Rust" | "C" | "cdecl" | "stdcall" | "fastcall" | "aapcs" | "win64" | "sysv64"
|
"Rust" | "C" | "cdecl" | "stdcall" | "fastcall" | "aapcs" | "win64" | "sysv64"
|
||||||
| "system" => Ok(()),
|
| "system" => Ok(()),
|
||||||
"rust-intrinsic" => {
|
"rust-intrinsic" => Err(AbiDisabled::Unstable {
|
||||||
gate_feature_post(features, sym::intrinsics, span, "intrinsics are subject to change")
|
feature: sym::intrinsics,
|
||||||
}
|
explain: "intrinsics are subject to change",
|
||||||
"platform-intrinsic" => gate_feature_post(
|
}),
|
||||||
features,
|
"platform-intrinsic" => Err(AbiDisabled::Unstable {
|
||||||
sym::platform_intrinsics,
|
feature: sym::platform_intrinsics,
|
||||||
span,
|
explain: "platform intrinsics are experimental and possibly buggy",
|
||||||
"platform intrinsics are experimental and possibly buggy",
|
}),
|
||||||
),
|
"vectorcall" => Err(AbiDisabled::Unstable {
|
||||||
"vectorcall" => gate_feature_post(
|
feature: sym::abi_vectorcall,
|
||||||
features,
|
explain: "vectorcall is experimental and subject to change",
|
||||||
sym::abi_vectorcall,
|
}),
|
||||||
span,
|
"thiscall" => Err(AbiDisabled::Unstable {
|
||||||
"vectorcall is experimental and subject to change",
|
feature: sym::abi_thiscall,
|
||||||
),
|
explain: "thiscall is experimental and subject to change",
|
||||||
"thiscall" => gate_feature_post(
|
}),
|
||||||
features,
|
"rust-call" => Err(AbiDisabled::Unstable {
|
||||||
sym::abi_thiscall,
|
feature: sym::unboxed_closures,
|
||||||
span,
|
explain: "rust-call ABI is subject to change",
|
||||||
"thiscall is experimental and subject to change",
|
}),
|
||||||
),
|
"rust-cold" => Err(AbiDisabled::Unstable {
|
||||||
"rust-call" => gate_feature_post(
|
feature: sym::rust_cold_cc,
|
||||||
features,
|
explain: "rust-cold is experimental and subject to change",
|
||||||
sym::unboxed_closures,
|
}),
|
||||||
span,
|
"ptx-kernel" => Err(AbiDisabled::Unstable {
|
||||||
"rust-call ABI is subject to change",
|
feature: sym::abi_ptx,
|
||||||
),
|
explain: "PTX ABIs are experimental and subject to change",
|
||||||
"rust-cold" => gate_feature_post(
|
}),
|
||||||
features,
|
"unadjusted" => Err(AbiDisabled::Unstable {
|
||||||
sym::rust_cold_cc,
|
feature: sym::abi_unadjusted,
|
||||||
span,
|
explain: "unadjusted ABI is an implementation detail and perma-unstable",
|
||||||
"rust-cold is experimental and subject to change",
|
}),
|
||||||
),
|
"msp430-interrupt" => Err(AbiDisabled::Unstable {
|
||||||
"ptx-kernel" => gate_feature_post(
|
feature: sym::abi_msp430_interrupt,
|
||||||
features,
|
explain: "msp430-interrupt ABI is experimental and subject to change",
|
||||||
sym::abi_ptx,
|
}),
|
||||||
span,
|
"x86-interrupt" => Err(AbiDisabled::Unstable {
|
||||||
"PTX ABIs are experimental and subject to change",
|
feature: sym::abi_x86_interrupt,
|
||||||
),
|
explain: "x86-interrupt ABI is experimental and subject to change",
|
||||||
"unadjusted" => gate_feature_post(
|
}),
|
||||||
features,
|
"amdgpu-kernel" => Err(AbiDisabled::Unstable {
|
||||||
sym::abi_unadjusted,
|
feature: sym::abi_amdgpu_kernel,
|
||||||
span,
|
explain: "amdgpu-kernel ABI is experimental and subject to change",
|
||||||
"unadjusted ABI is an implementation detail and perma-unstable",
|
}),
|
||||||
),
|
"avr-interrupt" | "avr-non-blocking-interrupt" => Err(AbiDisabled::Unstable {
|
||||||
"msp430-interrupt" => gate_feature_post(
|
feature: sym::abi_avr_interrupt,
|
||||||
features,
|
explain: "avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change",
|
||||||
sym::abi_msp430_interrupt,
|
}),
|
||||||
span,
|
"efiapi" => Err(AbiDisabled::Unstable {
|
||||||
"msp430-interrupt ABI is experimental and subject to change",
|
feature: sym::abi_efiapi,
|
||||||
),
|
explain: "efiapi ABI is experimental and subject to change",
|
||||||
"x86-interrupt" => gate_feature_post(
|
}),
|
||||||
features,
|
"C-cmse-nonsecure-call" => Err(AbiDisabled::Unstable {
|
||||||
sym::abi_x86_interrupt,
|
feature: sym::abi_c_cmse_nonsecure_call,
|
||||||
span,
|
explain: "C-cmse-nonsecure-call ABI is experimental and subject to change",
|
||||||
"x86-interrupt ABI is experimental and subject to change",
|
}),
|
||||||
),
|
"C-unwind" => Err(AbiDisabled::Unstable {
|
||||||
"amdgpu-kernel" => gate_feature_post(
|
feature: sym::c_unwind,
|
||||||
features,
|
explain: "C-unwind ABI is experimental and subject to change",
|
||||||
sym::abi_amdgpu_kernel,
|
}),
|
||||||
span,
|
"stdcall-unwind" => Err(AbiDisabled::Unstable {
|
||||||
"amdgpu-kernel ABI is experimental and subject to change",
|
feature: sym::c_unwind,
|
||||||
),
|
explain: "stdcall-unwind ABI is experimental and subject to change",
|
||||||
"avr-interrupt" | "avr-non-blocking-interrupt" => gate_feature_post(
|
}),
|
||||||
features,
|
"system-unwind" => Err(AbiDisabled::Unstable {
|
||||||
sym::abi_avr_interrupt,
|
feature: sym::c_unwind,
|
||||||
span,
|
explain: "system-unwind ABI is experimental and subject to change",
|
||||||
"avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change",
|
}),
|
||||||
),
|
"thiscall-unwind" => Err(AbiDisabled::Unstable {
|
||||||
"efiapi" => gate_feature_post(
|
feature: sym::c_unwind,
|
||||||
features,
|
explain: "thiscall-unwind ABI is experimental and subject to change",
|
||||||
sym::abi_efiapi,
|
}),
|
||||||
span,
|
"cdecl-unwind" => Err(AbiDisabled::Unstable {
|
||||||
"efiapi ABI is experimental and subject to change",
|
feature: sym::c_unwind,
|
||||||
),
|
explain: "cdecl-unwind ABI is experimental and subject to change",
|
||||||
"C-cmse-nonsecure-call" => gate_feature_post(
|
}),
|
||||||
features,
|
"fastcall-unwind" => Err(AbiDisabled::Unstable {
|
||||||
sym::abi_c_cmse_nonsecure_call,
|
feature: sym::c_unwind,
|
||||||
span,
|
explain: "fastcall-unwind ABI is experimental and subject to change",
|
||||||
"C-cmse-nonsecure-call ABI is experimental and subject to change",
|
}),
|
||||||
),
|
"vectorcall-unwind" => Err(AbiDisabled::Unstable {
|
||||||
"C-unwind" => gate_feature_post(
|
feature: sym::c_unwind,
|
||||||
features,
|
explain: "vectorcall-unwind ABI is experimental and subject to change",
|
||||||
sym::c_unwind,
|
}),
|
||||||
span,
|
"aapcs-unwind" => Err(AbiDisabled::Unstable {
|
||||||
"C-unwind ABI is experimental and subject to change",
|
feature: sym::c_unwind,
|
||||||
),
|
explain: "aapcs-unwind ABI is experimental and subject to change",
|
||||||
"stdcall-unwind" => gate_feature_post(
|
}),
|
||||||
features,
|
"win64-unwind" => Err(AbiDisabled::Unstable {
|
||||||
sym::c_unwind,
|
feature: sym::c_unwind,
|
||||||
span,
|
explain: "win64-unwind ABI is experimental and subject to change",
|
||||||
"stdcall-unwind ABI is experimental and subject to change",
|
}),
|
||||||
),
|
"sysv64-unwind" => Err(AbiDisabled::Unstable {
|
||||||
"system-unwind" => gate_feature_post(
|
feature: sym::c_unwind,
|
||||||
features,
|
explain: "sysv64-unwind ABI is experimental and subject to change",
|
||||||
sym::c_unwind,
|
}),
|
||||||
span,
|
"wasm" => Err(AbiDisabled::Unstable {
|
||||||
"system-unwind ABI is experimental and subject to change",
|
feature: sym::wasm_abi,
|
||||||
),
|
explain: "wasm ABI is experimental and subject to change",
|
||||||
"thiscall-unwind" => gate_feature_post(
|
}),
|
||||||
features,
|
|
||||||
sym::c_unwind,
|
|
||||||
span,
|
|
||||||
"thiscall-unwind ABI is experimental and subject to change",
|
|
||||||
),
|
|
||||||
"cdecl-unwind" => gate_feature_post(
|
|
||||||
features,
|
|
||||||
sym::c_unwind,
|
|
||||||
span,
|
|
||||||
"cdecl-unwind ABI is experimental and subject to change",
|
|
||||||
),
|
|
||||||
"fastcall-unwind" => gate_feature_post(
|
|
||||||
features,
|
|
||||||
sym::c_unwind,
|
|
||||||
span,
|
|
||||||
"fastcall-unwind ABI is experimental and subject to change",
|
|
||||||
),
|
|
||||||
"vectorcall-unwind" => gate_feature_post(
|
|
||||||
features,
|
|
||||||
sym::c_unwind,
|
|
||||||
span,
|
|
||||||
"vectorcall-unwind ABI is experimental and subject to change",
|
|
||||||
),
|
|
||||||
"aapcs-unwind" => gate_feature_post(
|
|
||||||
features,
|
|
||||||
sym::c_unwind,
|
|
||||||
span,
|
|
||||||
"aapcs-unwind ABI is experimental and subject to change",
|
|
||||||
),
|
|
||||||
"win64-unwind" => gate_feature_post(
|
|
||||||
features,
|
|
||||||
sym::c_unwind,
|
|
||||||
span,
|
|
||||||
"win64-unwind ABI is experimental and subject to change",
|
|
||||||
),
|
|
||||||
"sysv64-unwind" => gate_feature_post(
|
|
||||||
features,
|
|
||||||
sym::c_unwind,
|
|
||||||
span,
|
|
||||||
"sysv64-unwind ABI is experimental and subject to change",
|
|
||||||
),
|
|
||||||
"wasm" => gate_feature_post(
|
|
||||||
features,
|
|
||||||
sym::wasm_abi,
|
|
||||||
span,
|
|
||||||
"wasm ABI is experimental and subject to change",
|
|
||||||
),
|
|
||||||
_ => Err(AbiDisabled::Unrecognized),
|
_ => Err(AbiDisabled::Unrecognized),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue