Skip to content

Experimental feature gate proposal crabi #105586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,8 @@ declare_features! (
(active, const_trait_impl, "1.42.0", Some(67792), None),
/// Allows the `?` operator in const contexts.
(active, const_try, "1.56.0", Some(74935), None),
/// Allows using `extern "crabi"` and `repr(crabi)`
(incomplete, crabi, "CURRENT_RUSTC_VERSION", Some(111423), None),
/// Allows non-builtin attributes in inner attribute position.
(active, custom_inner_attributes, "1.30.0", Some(54726), None),
/// Allows custom test frameworks with `#![test_runner]` and `#[test_case]`.
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,7 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option<DefId>, abi: SpecAbi) ->
| Wasm
| RustIntrinsic
| PlatformIntrinsic
| Crabi
| Unadjusted => false,
Rust | RustCall | RustCold => tcx.sess.panic_strategy() == PanicStrategy::Unwind,
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_mir_transform/src/ffi_unwind_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ fn abi_can_unwind(abi: Abi) -> bool {
| Wasm
| RustIntrinsic
| PlatformIntrinsic
| Crabi
| Unadjusted => false,
Rust | RustCall | RustCold => true,
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ symbols! {
cosf64,
count,
cr,
crabi,
crate_id,
crate_in_paths,
crate_local,
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_target/src/spec/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub enum Abi {
PlatformIntrinsic,
Unadjusted,
RustCold,
Crabi,
}

impl Abi {
Expand Down Expand Up @@ -107,6 +108,7 @@ const AbiDatas: &[AbiData] = &[
AbiData { abi: Abi::PlatformIntrinsic, name: "platform-intrinsic" },
AbiData { abi: Abi::Unadjusted, name: "unadjusted" },
AbiData { abi: Abi::RustCold, name: "rust-cold" },
AbiData { abi: Abi::Crabi, name: "crabi" },
];

/// Returns the ABI with the given name (if any).
Expand Down Expand Up @@ -246,6 +248,10 @@ pub fn is_stable(name: &str) -> Result<(), AbiDisabled> {
feature: sym::wasm_abi,
explain: "wasm ABI is experimental and subject to change",
}),
"crabi" => Err(AbiDisabled::Unstable {
feature: sym::crabi,
explain: "crABI is experimental and subject to change",
}),
_ => Err(AbiDisabled::Unrecognized),
}
}
Expand Down Expand Up @@ -298,6 +304,7 @@ impl Abi {
PlatformIntrinsic => 32,
Unadjusted => 33,
RustCold => 34,
Crabi => 35,
};
debug_assert!(
AbiDatas
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2075,6 +2075,8 @@ impl Target {
Vectorcall { .. } if ["x86", "x86_64"].contains(&&self.arch[..]) => true,
// Return a `None` for other cases so that we know to emit a future compat lint.
Stdcall { .. } | Fastcall { .. } | Vectorcall { .. } => return None,
// Not yet implemented
Crabi => false,
})
}

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_ty_utils/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: SpecAbi) -> Conv {
AvrInterrupt => Conv::AvrInterrupt,
AvrNonBlockingInterrupt => Conv::AvrNonBlockingInterrupt,
Wasm => Conv::C,
Crabi => bug!("crABI is not yet implemented"),

// These API constants ought to be more specific...
Cdecl { .. } => Conv::C,
Expand Down
12 changes: 12 additions & 0 deletions tests/ui/feature-gates/feature-gate-crabi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Test that the `crabi` ABI is feature-gated, and cannot be used when the `crabi` feature gate is
// not used.

extern "crabi" {
//~^ ERROR crABI is experimental and subject to change [E0658]
//~| ERROR `"crabi"` is not a supported ABI for the current target [E0570]
fn f();
}

fn main() {
f();
}
23 changes: 23 additions & 0 deletions tests/ui/feature-gates/feature-gate-crabi.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
error[E0658]: crABI is experimental and subject to change
--> $DIR/feature-gate-crabi.rs:4:8
|
LL | extern "crabi" {
| ^^^^^^^
|
= note: see issue #111423 <https://github.com/rust-lang/rust/issues/111423> for more information
= help: add `#![feature(crabi)]` to the crate attributes to enable

error[E0570]: `"crabi"` is not a supported ABI for the current target
--> $DIR/feature-gate-crabi.rs:4:1
|
LL | / extern "crabi" {
LL | |
LL | |
LL | | fn f();
LL | | }
| |_^

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0570, E0658.
For more information about an error, try `rustc --explain E0570`.