aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive
diff options
context:
space:
mode:
authorLibravatar msrd0 <msrd0@users.noreply.github.com>2020-11-02 17:11:53 +0100
committerLibravatar GitHub <noreply@github.com>2020-11-02 17:11:53 +0100
commitf23162a2080a3fb3fe2b8ba7eba4d61da5737dfe (patch)
tree691611a04b272594493862970c9aa327e6eb4df6 /askama_derive
parentac7d9e8031b4df489a0d58dc3459bc931f1ff870 (diff)
downloadaskama-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 'askama_derive')
-rw-r--r--askama_derive/Cargo.toml1
-rw-r--r--askama_derive/src/lib.rs9
2 files changed, 5 insertions, 5 deletions
diff --git a/askama_derive/Cargo.toml b/askama_derive/Cargo.toml
index 84970fb..63d08bd 100644
--- a/askama_derive/Cargo.toml
+++ b/askama_derive/Cargo.toml
@@ -25,5 +25,4 @@ warp = []
[dependencies]
askama_shared = { version = "0.10.4", path = "../askama_shared", default-features = false }
proc-macro2 = "1"
-quote = "1"
syn = "1"
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