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

47 lines
1.4 KiB
Rust

// arch-n01 slice A: method probe extension candidates on the native solver
// (rustc_hir_typeck/src/method/probe.rs:1092-1175,2087-2161), Pin dispatch for
// dyn compatibility (library/core/src/pin.rs:1827), overloaded calls of a rigid
// opaque (callee.rs try_overloaded_call_traits), written value-path lifetimes
// (fn_ctxt/_impl.rs instantiate_value_path). rustc: all pass.
use std::future::Future;
fn integer_range_map() -> u64 { (1..=4).map(|x| x * 10).sum() }
fn needs_future<T: ?Sized + Future>() {}
fn adder(n: i32) -> impl Fn(i32) -> i32 { move |x| x + n }
fn pick<'a, 'b>(x: &'a str, _y: &'b str) -> &'a str where 'a: 'a, 'b: 'b { x }
struct Buf<T = u8, const N: usize = 4> { v: [T; N] }
impl<T: Copy + Default, const N: usize> Buf<T, N> {
fn new() -> Self { Buf { v: [T::default(); N] } }
fn len(&self) -> usize { self.v.len() }
}
#[test]
fn probe_int_var_receiver() { assert_eq!(integer_range_map(), 100); }
#[test]
fn dyn_future_is_future() { needs_future::<dyn Future<Output = u32>>(); }
#[test]
fn opaque_overloaded_call() {
let f = adder(5);
assert_eq!(f(1), 6);
assert_eq!(adder(2)(3), 5);
}
#[test]
fn written_value_lifetimes() {
let a = String::from("a");
assert_eq!(pick::<'_, 'static>(&a, "b"), "a");
}
#[test]
fn defaults_in_type_position() {
let b: Buf = Buf::new();
assert_eq!(b.len(), 4);
let d: Buf<u32, 7> = Buf::new();
assert_eq!(d.len(), 7);
}