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

26 lines
653 B
Rust

// `extern crate self as name;` at the crate root names the crate itself (rustc: an item binding
// at the root plus an extern-prelude entry, so `name::..` works in every module) -- makepad-draw
// uses it so derive output written as `makepad_draw::..` compiles inside makepad-draw.
extern crate self as me;
pub mod a {
pub fn f() -> u32 {
7
}
pub struct S(pub u32);
}
mod b {
pub fn g() -> u32 {
me::a::f() + me::a::S(1).0
}
}
#[test]
fn extern_crate_self() {
assert_eq!(me::a::f(), 7);
assert_eq!(b::g(), 8);
let s: me::a::S = a::S(3);
assert_eq!(s.0, 3);
println!("extern_crate_self ok");
}