aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor
diff options
context:
space:
mode:
authorBrezak <[email protected]>2025-07-22 20:56:46 +0200
committerBrezak <[email protected]>2025-07-23 19:19:02 +0200
commita52965dc5d3d0c706310998d3eda8bc15cd45b02 (patch)
tree64087a9a6391c6ded8c7ddfb06652152b1b0759e /embassy-executor
parenta5984a8298491ea748693783275d95286a481394 (diff)
embassy-executor: unsafe tasks as unsafe
Diffstat (limited to 'embassy-executor')
-rw-r--r--embassy-executor/CHANGELOG.md1
-rw-r--r--embassy-executor/tests/ui.rs1
-rw-r--r--embassy-executor/tests/ui/task_safety_attribute.rs25
3 files changed, 27 insertions, 0 deletions
diff --git a/embassy-executor/CHANGELOG.md b/embassy-executor/CHANGELOG.md
index 914863a83..7404961f3 100644
--- a/embassy-executor/CHANGELOG.md
+++ b/embassy-executor/CHANGELOG.md
@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
21- Added support for `-> impl Future<Output = ()>` in `#[task]` 21- Added support for `-> impl Future<Output = ()>` in `#[task]`
22- Fixed `Send` unsoundness with `-> impl Future` tasks 22- Fixed `Send` unsoundness with `-> impl Future` tasks
23- Marked `Spawner::for_current_executor` as `unsafe` 23- Marked `Spawner::for_current_executor` as `unsafe`
24- `#[task]` now properly marks the generated function as unsafe if the task is marked unsafe
24 25
25## 0.7.0 - 2025-01-02 26## 0.7.0 - 2025-01-02
26 27
diff --git a/embassy-executor/tests/ui.rs b/embassy-executor/tests/ui.rs
index 7757775ee..8b83cd368 100644
--- a/embassy-executor/tests/ui.rs
+++ b/embassy-executor/tests/ui.rs
@@ -32,4 +32,5 @@ fn ui() {
32 t.compile_fail("tests/ui/self.rs"); 32 t.compile_fail("tests/ui/self.rs");
33 t.compile_fail("tests/ui/type_error.rs"); 33 t.compile_fail("tests/ui/type_error.rs");
34 t.compile_fail("tests/ui/where_clause.rs"); 34 t.compile_fail("tests/ui/where_clause.rs");
35 t.pass("tests/ui/task_safety_attribute.rs");
35} 36}
diff --git a/embassy-executor/tests/ui/task_safety_attribute.rs b/embassy-executor/tests/ui/task_safety_attribute.rs
new file mode 100644
index 000000000..ab5a2f99f
--- /dev/null
+++ b/embassy-executor/tests/ui/task_safety_attribute.rs
@@ -0,0 +1,25 @@
1#![cfg_attr(feature = "nightly", feature(impl_trait_in_assoc_type))]
2#![deny(unused_unsafe)]
3
4use std::mem;
5
6#[embassy_executor::task]
7async fn safe() {}
8
9#[embassy_executor::task]
10async unsafe fn not_safe() {}
11
12#[export_name = "__pender"]
13fn pender(_: *mut ()) {
14 // The test doesn't link if we don't include this.
15 // We never call this anyway.
16}
17
18fn main() {
19 let _forget_me = safe();
20 // SAFETY: not_safe has not safety preconditions
21 let _forget_me2 = unsafe { not_safe() };
22
23 mem::forget(_forget_me);
24 mem::forget(_forget_me2);
25}