aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor/tests/ui/task_safety_attribute.rs
blob: ab5a2f99f177e89eacdb044a9cc84f9dd7307a1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#![cfg_attr(feature = "nightly", feature(impl_trait_in_assoc_type))]
#![deny(unused_unsafe)]

use std::mem;

#[embassy_executor::task]
async fn safe() {}

#[embassy_executor::task]
async unsafe fn not_safe() {}

#[export_name = "__pender"]
fn pender(_: *mut ()) {
    // The test doesn't link if we don't include this.
    // We never call this anyway.
}

fn main() {
    let _forget_me = safe();
    // SAFETY: not_safe has not safety preconditions
    let _forget_me2 = unsafe { not_safe() };

    mem::forget(_forget_me);
    mem::forget(_forget_me2);
}