diff options
| author | bors <bors@rust-lang.org> | 2024-09-14 23:47:59 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-09-14 23:47:59 +0000 |
| commit | 4f1be92153167dfc2a54215bfd49f398c04ce647 (patch) | |
| tree | 0954467ad959275983f16c169aec34b73793396d /compiler/rustc_parse/src/parser | |
| parent | 9b72238eb813e9d06e9e9d270168512fbffd7ee7 (diff) | |
| parent | a528f4ecd99cd5e1fb4454fc383688eccd4e34e1 (diff) | |
| download | rust-4f1be92153167dfc2a54215bfd49f398c04ce647.tar.gz rust-4f1be92153167dfc2a54215bfd49f398c04ce647.zip | |
Auto merge of #129753 - folkertdev:stabilize-const-extern-fn, r=RalfJung
stabilize `const_extern_fn`
closes https://github.com/rust-lang/rust/issues/64926
tracking issue: https://github.com/rust-lang/rust/issues/64926
reference PR: https://github.com/rust-lang/reference/pull/1596
## Stabilizaton Report
### Summary
Using `const extern "Rust"` and `const extern "C"` was already stabilized (since version 1.62.0, see https://github.com/rust-lang/rust/pull/95346). This PR stabilizes the other calling conventions: it is now possible to write `const unsafe extern "calling-convention" fn` and `const extern "calling-convention" fn` for any supported calling convention:
```rust
const extern "C-unwind" fn foo1(val: u8) -> u8 { val + 1}
const extern "stdcall" fn foo2(val: u8) -> u8 { val + 1}
const unsafe extern "C-unwind" fn bar1(val: bool) -> bool { !val }
const unsafe extern "stdcall" fn bar2(val: bool) -> bool { !val }
```
This can be used to const-ify an `extern fn`, or conversely, to make a `const fn` callable from external code.
r? T-lang
cc `@RalfJung`
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/ty.rs | 3 |
1 files changed, 0 insertions, 3 deletions
diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index dd1cc75c7ff..66019ffbc0a 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -607,9 +607,6 @@ impl<'a> Parser<'a> { let decl = self.parse_fn_decl(|_| false, AllowPlus::No, recover_return_sign)?; let whole_span = lo.to(self.prev_token.span); if let ast::Const::Yes(span) = constness { - // If we ever start to allow `const fn()`, then update - // feature gating for `#![feature(const_extern_fn)]` to - // cover it. self.dcx().emit_err(FnPointerCannotBeConst { span: whole_span, qualifier: span }); } if let Some(ast::CoroutineKind::Async { span, .. }) = coroutine_kind { |
