makepad/libs/relax/compiler/tests/live/struct_field/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

38 lines
1,005 B
Rust

// G3 / 4.4: struct layout edits (no live values of the type survive between runs).
// v1: a field is added between two others; make() and sum() are edited to use it. Every fn that
// uses P's layout (offsets are baked into code) must be recompiled, including outer(), whose
// text does not change but which embeds P in Outer.
// v2: only the struct's field order changes (no fn text changes): the derived Debug prints the
// new order, and every user of the layout is recompiled.
#[derive(Debug, Clone, Copy)]
struct P {
a: u32,
b: u64,
}
struct Outer {
tag: u8,
ps: [P; 3],
}
fn make(i: u32) -> P {
P { a: i, b: (i as u64) << 33 }
}
fn sum(p: &P) -> u64 {
p.a as u64 + p.b
}
fn outer() -> u64 {
let o = Outer { tag: 7, ps: [make(1), make(2), make(3)] };
let mut s = o.tag as u64;
for p in o.ps.iter() {
s = s.wrapping_mul(31).wrapping_add(sum(p));
}
s
}
#[test]
fn run() {
println!("out {:?} outer {}", make(5), outer());
}