diff options
author | msrd0 <msrd0@users.noreply.github.com> | 2020-11-02 17:11:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-02 17:11:53 +0100 |
commit | f23162a2080a3fb3fe2b8ba7eba4d61da5737dfe (patch) | |
tree | 691611a04b272594493862970c9aa327e6eb4df6 /askama_derive/src | |
parent | ac7d9e8031b4df489a0d58dc3459bc931f1ff870 (diff) | |
download | askama-f23162a2080a3fb3fe2b8ba7eba4d61da5737dfe.tar.gz askama-f23162a2080a3fb3fe2b8ba7eba4d61da5737dfe.tar.bz2 askama-f23162a2080a3fb3fe2b8ba7eba4d61da5737dfe.zip |
Use `syn::Error::to_compile_error` and add trybuild ui test (#374)
Diffstat (limited to '')
-rw-r--r-- | askama_derive/src/lib.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/askama_derive/src/lib.rs b/askama_derive/src/lib.rs index 8844e99..101b861 100644 --- a/askama_derive/src/lib.rs +++ b/askama_derive/src/lib.rs @@ -7,6 +7,7 @@ use askama_shared::{ generator, get_template_source, read_config_file, CompileError, Config, Integrations, }; use proc_macro::TokenStream; +use proc_macro2::Span; use std::collections::HashMap; use std::path::PathBuf; @@ -15,11 +16,11 @@ use std::path::PathBuf; pub fn derive_template(input: TokenStream) -> TokenStream { let ast: syn::DeriveInput = syn::parse(input).unwrap(); match build_template(&ast) { - Ok(source) => source, - Err(e) => format!("compile_error!({:?})", e), + Ok(source) => source.parse().unwrap(), + Err(e) => syn::Error::new(Span::call_site(), e) + .to_compile_error() + .into(), } - .parse() - .unwrap() } /// Takes a `syn::DeriveInput` and generates source code for it |