Skip to content

Commit 6a21a29

Browse files
committed
Add an error for string literal expressions
1 parent 4f2048d commit 6a21a29

File tree

1 file changed

+11
-1
lines changed
  • crates/spirv-std/macros/src

1 file changed

+11
-1
lines changed

crates/spirv-std/macros/src/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,17 @@ impl syn::parse::Parse for PrintfInput {
376376
let mut expressions = Vec::new();
377377
while !input.is_empty() {
378378
input.parse::<syn::Token![,]>()?;
379-
expressions.push(input.parse()?);
379+
380+
let expr = input.parse()?;
381+
382+
if let syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Str(lit_str), ..}) = expr {
383+
return Err(syn::Error::new(
384+
lit_str.span(),
385+
"String literals should be part of the format string.",
386+
))
387+
}
388+
389+
expressions.push(expr);
380390
}
381391
expressions
382392
},

0 commit comments

Comments
 (0)