fix(derive): fail missing surface generation
Make #[slhx::surface] report a compile-time error when slhx.generated.rs is absent instead of silently expanding to an empty module. Add compile-fail coverage for the missing generated include path. req: build/004 req: test/003
This commit is contained in:
+11
-2
@@ -66,13 +66,22 @@ fn inject_surface_include(item: TokenStream) -> TokenStream {
|
||||
|
||||
fn surface_include() -> String {
|
||||
let Some(path) = generated_path("slhx.generated.rs") else {
|
||||
return String::new();
|
||||
return format!(
|
||||
" compile_error!({:?}); ",
|
||||
"#[slhx::surface] requires OUT_DIR; run inside a Cargo crate with slhx_build::app() in build.rs"
|
||||
);
|
||||
};
|
||||
|
||||
if path.exists() {
|
||||
format!(" include!({:?}); ", path.display().to_string())
|
||||
} else {
|
||||
String::new()
|
||||
format!(
|
||||
" compile_error!({:?}); ",
|
||||
format!(
|
||||
"#[slhx::surface] could not find {}; add slhx_build::app().run()? to build.rs or check template generation",
|
||||
path.display()
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user