makepad/libs/relax/compiler/tests/async_send.rs
Admin b22a714840 makepad run: the Rust JIT (libs/relax) and makepad-remote
The JIT that runs makepad apps from source: lexer, front end, type checker,
lazy borrow checker (Gandalf; `--check-first` opts in), codegen, session and
warm/cold caches keyed by compiler stamp, provided crates bound late,
startup images, live patching. User-facing name is `makepad run` (binary
`makepad`, MAKEPAD_RUN_* env, ~/.makepad-run); libs/relax stays the internal
library name. `makepad check` reports rustc-style diagnostics with rustc
error codes and checks a whole workspace (`--workspace`). Runs on macOS,
Linux, Windows and Android. makepad-remote: one tool schema for apps and the
WM (app/1): grabs, captures, traces, frame profiles and tweaks.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-13 12:26:21 +02:00

32 lines
874 B
Rust

use std::rc::Rc;
fn needs_send<T: Send>(value: T) -> T { value }
async fn work(x: u32) -> u32 { x + 1 }
async fn generic<T: Send>(value: T) -> T { value }
fn hidden() -> impl Sized { 42u32 }
fn explicit() -> impl Send { 42u32 }
#[test]
fn futures_and_opaque_values_are_send() {
drop(needs_send(work(2)));
drop(needs_send(async { work(1).await }));
drop(needs_send(generic(String::from("send"))));
drop(needs_send(hidden()));
drop(needs_send(explicit()));
}
#[test]
fn coroutine_upvars_are_published_before_retry() {
let text = String::from("owned");
drop(needs_send(async move { work(text.len() as u32).await }));
let x = 1u32;
drop(needs_send(async { work(x).await }));
}
#[test]
fn rc_scope_ends_before_await() {
drop(needs_send(async {
{ let rc = Rc::new(42u32); assert_eq!(*rc, 42); }
work(1).await
}));
}