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>
44 lines
1.2 KiB
Rust
44 lines
1.2 KiB
Rust
// thread_local! (boot B25): `static`/`const { }` initialisers, attributes and visibility, several
|
|
// declarations per call, item and statement position. rustc: all pass. (RefCell writes are left out
|
|
// here: guard temporaries are coord.md B26, frontend.)
|
|
use std::cell::{Cell, RefCell};
|
|
|
|
thread_local! {
|
|
static A: Cell<Option<u32>> = const { Cell::new(None) };
|
|
static R: RefCell<Vec<u32>> = RefCell::new(Vec::new());
|
|
#[allow(dead_code)]
|
|
pub static B: Cell<u32> = Cell::new(5);
|
|
}
|
|
|
|
mod m {
|
|
thread_local!(pub(crate) static C: std::cell::Cell<Vec<u8>> = std::cell::Cell::new(Vec::new()));
|
|
}
|
|
|
|
#[test]
|
|
fn thread_local_items() {
|
|
A.with(|a| {
|
|
a.set(Some(3));
|
|
});
|
|
assert!(R.with(|r| r.borrow().len()) == 0);
|
|
let v = A.with(|a| a.take().unwrap());
|
|
B.with(|b| b.set(b.get() + v));
|
|
assert!(B.with(|b| b.get()) == 8);
|
|
m::C.with(|c| {
|
|
let mut t = c.take();
|
|
t.push(1);
|
|
c.set(t);
|
|
});
|
|
assert!(m::C.with(|c| {
|
|
let t = c.take();
|
|
t.len()
|
|
}) == 1);
|
|
}
|
|
|
|
#[test]
|
|
fn thread_local_in_a_block() {
|
|
thread_local! {
|
|
static D: Cell<u64> = const { Cell::new(10) };
|
|
}
|
|
D.with(|d| d.set(d.get() * 2));
|
|
assert!(D.with(|d| d.get()) == 20);
|
|
}
|