Skip to content

Commit c45c427

Browse files
Rollup merge of #148536 - folkertdev:cmse-async-const-fn, r=davidtwco
cmse: add test for `async` and `const` functions tracking issue: #81391 tracking issue: #75835 Some additional tests that seemed useful while working on the RFC text. `async` functions are disallowed (because `-> impl Trait` is not supported). `const` entry functions are allowed, `nonsecure-call` does not make sense, because this abi can only be used on function pointers, which cannot be evaluated during constant evaluation. The async test is in the `c-variadic.rs` file because it has the minicore-compatible machinery for defining an async function. Splitting that logic out (like `minisimd.rs`) turns out to be complicated because the async stuff relies on types defined by minicore. r? `@davidtwco`
2 parents 9a7e080 + 4e9dfb5 commit c45c427

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ async unsafe extern "cmse-nonsecure-entry" fn async_and_c_variadic(_: ...) {
2121
//~| ERROR functions cannot be both `async` and C-variadic
2222
}
2323

24+
// Async on its own is also not allowed.
25+
async unsafe extern "cmse-nonsecure-entry" fn async_is_not_allowed() {
26+
//~^ ERROR `impl Trait` is not allowed in `extern "cmse-nonsecure-entry"` signatures
27+
}
28+
2429
// Below are the lang items that are required for a program that defines an `async` function.
2530
// Without them, the ICE that is tested for here is not reached for this target. For now they are in
2631
// this file, but they may be moved into `minicore` if/when other `#[no_core]` tests want to use

tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.stderr

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,12 @@ LL | async unsafe extern "cmse-nonsecure-entry" fn async_and_c_variadic(_: ...)
2424
|
2525
= help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list
2626

27-
error: aborting due to 3 previous errors
27+
error[E0798]: `impl Trait` is not allowed in `extern "cmse-nonsecure-entry"` signatures
28+
--> $DIR/c-variadic.rs:25:1
29+
|
30+
LL | async unsafe extern "cmse-nonsecure-entry" fn async_is_not_allowed() {
31+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32+
33+
error: aborting due to 4 previous errors
2834

35+
For more information about this error, try `rustc --explain E0798`.

tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,13 @@ extern "cmse-nonsecure-entry" fn identity_impl_trait_nested(
8989
//~^ ERROR `impl Trait` is not allowed in `extern "cmse-nonsecure-entry"` signatures
9090
v
9191
}
92+
93+
const extern "cmse-nonsecure-entry" fn const_fn_works(x: u8) -> u8 {
94+
x
95+
}
96+
97+
const CONST: u8 = const_fn_works(0);
98+
99+
fn fn_ptr_works(f: extern "cmse-nonsecure-entry" fn(_: u8) -> u8) -> u8 {
100+
f(0)
101+
}

0 commit comments

Comments
 (0)