-
- The generator needs to escape raw identifiers in macro names:
override!() → r#override!().
- The parser needs to reject illegal macro names:
self!().
-
- The parser needs to ensure that the inside a macro call only valid tokens are used.
Artifact:
data:application/octet-steam;base64,rf/LDGF3dHJhaXRhaXRBe3tvdmVycmlkZQwhICAMICgfICAMDCkMfX2FfWZqYI9mZmaaxGZmZmZmZgGAACxmZma//8tmZp40DA==
Formatted test case:
#[test]
fn test() -> Result<(), syn::Error> {
let input = quote! {
#[template(
ext = "",
source = "\u{c}awtraitaitA{{override\u{c}! \u{c} (\u{1f} \u{c}\u{c})\u{c}}}"
// ^^^^^^^^ ^^^^^^
// illegal identifier illegal token
)]
struct f {}
};
let output = derive_template(input, import_askama);
let _: syn::File = syn::parse2(output)?;
Ok(())
}
Generated code (extract):
override!(␟ ␌␌)
// ^^^^^^^^ ^- illegal token
// |
// illegal identifier
override!()→r#override!().self!().Artifact:
Formatted test case:
Generated code (extract):