makepad/libs/relax/compiler/tests/n01_round33_rigid.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

31 lines
994 B
Rust

// D7 / front-bck audit 1.5: rigid aliases in borrowck (nll.rs params_in: type tests for rigid
// projections; rty.rs skel_into: region skeleton for rigid opaques), compared with rustc.
trait Tr { type Item; }
impl Tr for u8 { type Item = u16; }
fn need_static<U: 'static>(_: U) {}
// T::Item is rigid here; T: 'static proves it by the projection-outlives rule.
fn by_args<T: Tr + 'static>(x: T::Item) { need_static(x); }
// ... and a where-clause on the projection itself.
fn by_bound<T: Tr>(x: T::Item) where T::Item: 'static { need_static(x); }
fn mk<'a>(x: &'a u8) -> impl Sized + 'a { x }
// A rigid opaque carries its captured region: the returned value borrows `x` only.
fn pass_through<'a, 'b>(x: &'a u8, _y: &'b u8) -> impl Sized + 'a { mk(x) }
#[test]
fn rigid_projection_outlives() {
by_args::<u8>(1);
by_bound::<u8>(2);
}
#[test]
fn rigid_opaque_regions() {
let a = 1u8;
let r;
{
let b = 2u8;
r = pass_through(&a, &b);
}
let _ = r;
}