diff options
Diffstat (limited to 'subplotlib-derive')
-rw-r--r-- | subplotlib-derive/Cargo.toml | 9 | ||||
-rw-r--r-- | subplotlib-derive/src/lib.rs | 21 |
2 files changed, 13 insertions, 17 deletions
diff --git a/subplotlib-derive/Cargo.toml b/subplotlib-derive/Cargo.toml index 36337d4..7d5b0c4 100644 --- a/subplotlib-derive/Cargo.toml +++ b/subplotlib-derive/Cargo.toml @@ -1,23 +1,24 @@ [package] name = "subplotlib-derive" -version = "0.6.0" +version = "0.9.0" authors = [ "Lars Wirzenius <liw@liw.fi>", "Daniel Silverstone <dsilvers@digital-scurf.org>", ] -edition = "2018" +edition = "2021" license = "MIT-0" description = ''' macros for constructing subplotlib based test suites, typically generated by `subplot codegen`.''' homepage = "https://subplot.tech/" repository = "https://gitlab.com/subplot/subplot" +rust-version = "1.70" [lib] proc-macro = true [dependencies] -syn = { version = "1", features = ["full"] } +syn = { version = "2", features = ["full"] } quote = "1" proc-macro2 = "1" -fehler = "1" +culpa = "1.0.1" diff --git a/subplotlib-derive/src/lib.rs b/subplotlib-derive/src/lib.rs index 7aef0dc..8e18c98 100644 --- a/subplotlib-derive/src/lib.rs +++ b/subplotlib-derive/src/lib.rs @@ -8,7 +8,7 @@ use syn::{ use quote::quote; -use fehler::{throw, throws}; +use culpa::{throw, throws}; fn ty_is_borrow_str(ty: &Type) -> bool { if let Type::Reference(ty) = ty { @@ -209,19 +209,19 @@ fn process_step(mut input: ItemFn) -> proc_macro2::TokenStream { let contexts: Vec<Type> = input .attrs .iter() - .filter(|attr| attr.path.is_ident("context")) + .filter(|attr| attr.path().is_ident("context")) .map(|attr| { let ty: Type = attr.parse_args()?; Ok(ty) }) .collect::<Result<_, Error>>()?; - input.attrs.retain(|f| !f.path.is_ident("context")); + input.attrs.retain(|f| !f.path().is_ident("context")); let docs: Vec<_> = input .attrs .iter() - .filter(|attr| attr.path.is_ident("doc")) + .filter(|attr| attr.path().is_ident("doc")) .collect(); let fields = input @@ -350,10 +350,11 @@ fn process_step(mut input: ItemFn) -> proc_macro2::TokenStream { impl Builder { #(#fieldfns)* - pub fn build(self, step_text: String) -> ScenarioStep { + pub fn build(self, step_text: String, location: &'static str) -> ScenarioStep { ScenarioStep::new(step_text, move |ctx, _defuse_poison| #builder_body, - |scenario| register_contexts(scenario) + |scenario| register_contexts(scenario), + location, ) } } @@ -403,10 +404,7 @@ fn process_step(mut input: ItemFn) -> proc_macro2::TokenStream { for context in outer_ctx.into_iter().chain(contexts.iter()) { write!(contextattrs, "\n #[context({:?})]", ty_as_path(context)?).unwrap(); } - let func_args: Vec<_> = fields - .iter() - .map(|(ident, _)| format!("{}", ident)) - .collect(); + let func_args: Vec<_> = fields.iter().map(|(ident, _)| format!("{ident}")).collect(); let func_args = func_args.join(", "); format!( r#" @@ -424,9 +422,6 @@ fn process_step(mut input: ItemFn) -> proc_macro2::TokenStream { }} ``` "#, - stepname = stepname, - contextattrs = contextattrs, - func_args = func_args, ) }; let ret = quote! { |