makepad/libs/relax/compiler/tests/live/m10_nested/v0.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

41 lines
940 B
Rust

// M10: Inner gains a field inside [Inner; 2] inside Outer inside a Vec.
// Unchanged Outer methods must still read and mutate both array elements;
// two Outer values also exercise the Vec stride.
use std::sync::Mutex;
struct Inner {
n: u32,
}
struct Outer {
tag: u8,
inner: [Inner; 2],
}
impl Outer {
fn total(&self) -> u32 {
self.tag as u32 + self.inner[0].n + self.inner[1].n
}
fn bump(&mut self) {
self.inner[0].n += 1;
self.inner[1].n += 2;
}
}
static ITEMS: Mutex<Vec<Outer>> = Mutex::new(Vec::new());
#[test]
fn run() {
let mut items = ITEMS.lock().unwrap();
if items.is_empty() {
for tag in 1..=2 {
items.push(Outer { tag, inner: [Inner { n: 10 }, Inner { n: 20 }] });
}
}
for item in items.iter_mut() {
println!("out {} {} {} {}", item.tag, item.inner[0].n, item.inner[1].n, item.total());
item.bump();
}
}