Commit e01ec7ca authored by Raphaël Gomès's avatar Raphaël Gomès
Browse files

Make error messages point to the wrapped function instead of `#[timed]`

parent 6065ff5cba75
......@@ -26,9 +26,11 @@ pub fn timed(_attr_ts: TokenStream, fn_ts: TokenStream) -> TokenStream {
outer.sig.ident = func.sig.ident.to_owned();
let original_func_name = func.sig.ident.to_string();
let inner_block = func.block;
let inner_block = &func.block;
let span = outer.sig.ident.span();
let block = quote! {
let block = quote_spanned! {
span=>
{
let timer = ::std::time::Instant::now();
let mut inner = || { #inner_block };
......@@ -54,7 +56,7 @@ fn parse_function(item: syn::Item) -> Result<syn::ItemFn, TokenStream> {
match item {
syn::Item::Fn(func) => Ok(func),
i => Err(quote_spanned! {
i.span() =>
i.span()=>
compile_error!("`#[timed]` can only be used on functions");
#i
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment