use naga::Module;
mod no_structs_in_fragment;
struct LintReport {
summary: &'static str,
explanation: &'static str,
violations: Vec<String>,
}
pub(crate) fn lint(shader_name: &str, module: &Module) {
let reports: Vec<LintReport> = [no_structs_in_fragment::check(module)]
.into_iter()
.flatten()
.collect();
if reports.is_empty() {
return;
}
let mut message = format!("`{shader_name}.wesl` failed shader lints:\n");
for report in &reports {
use std::fmt::Write as _;
write!(
message,
"\n{}\n\n{}\n\nViolations:\n",
report.summary, report.explanation,
)
.unwrap();
for violation in &report.violations {
message.push_str(" - ");
message.push_str(violation);
message.push('\n');
}
}
panic!("{message}");
}