From 32504cb3a7ad7e9efc18e6981f7e89d19905ddea Mon Sep 17 00:00:00 2001 From: Weronika Tarnawska Date: Fri, 4 Sep 2026 09:41:01 +0200 Subject: [PATCH 1/6] Upgrade edition to 2024 --- Cargo.toml | 2 +- examples/git.rs | 2 +- shellfn-attribute/Cargo.toml | 2 +- shellfn-core/Cargo.toml | 2 +- tests/tests.rs | 14 +++++++------- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8ddb8e4..85205f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ readme = "README.md" license = "MIT" repository = "https://github.com/synek317/shellfn" documentation = "https://docs.rs/shellfn" -edition = "2018" +edition = "2024" [workspace] members = ["shellfn-attribute", "shellfn-core"] diff --git a/examples/git.rs b/examples/git.rs index dbab71f..eeba5e6 100644 --- a/examples/git.rs +++ b/examples/git.rs @@ -2,7 +2,7 @@ use shellfn::shell; use std::error::Error; #[shell] -fn list_modified(dir: &str) -> Result, Box> { +fn list_modified(dir: &str) -> Result + use<>, Box> { r#" cd $DIR git status | grep '^\s*modified:' | awk '{print $2}' diff --git a/shellfn-attribute/Cargo.toml b/shellfn-attribute/Cargo.toml index 1ade695..ce243b6 100644 --- a/shellfn-attribute/Cargo.toml +++ b/shellfn-attribute/Cargo.toml @@ -4,7 +4,7 @@ version = "0.2.0" authors = ["Marcin Sas-Szymanski "] description = "Attribute macro for `shellfn` crate" license = "MIT" -edition = "2018" +edition = "2024" [lib] doctest = false diff --git a/shellfn-core/Cargo.toml b/shellfn-core/Cargo.toml index 62308c1..b3da182 100644 --- a/shellfn-core/Cargo.toml +++ b/shellfn-core/Cargo.toml @@ -4,7 +4,7 @@ version = "0.2.0" authors = ["Marcin Sas-Szymanski "] description = "Core functions for `shellfn` crate" license = "MIT" -edition = "2018" +edition = "2024" [lib] doctest = false diff --git a/tests/tests.rs b/tests/tests.rs index 98ea76d..4f865bd 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -342,7 +342,7 @@ mod analyzes_return_type { use super::*; #[shell] - fn script(data: &str, exit_code: u32) -> impl Iterator { + fn script(data: &str, exit_code: u32) -> impl Iterator + use<> { r#" for V in $DATA; do echo $V; @@ -389,7 +389,7 @@ mod analyzes_return_type { use super::*; #[shell(no_panic)] - fn script(data: &str, exit_code: u32) -> impl Iterator { + fn script(data: &str, exit_code: u32) -> impl Iterator + use<> { r#" for V in $DATA; do echo $V; @@ -436,7 +436,7 @@ mod analyzes_return_type { fn script( data: &str, exit_code: u32, - ) -> impl Iterator> { + ) -> impl Iterator> + use<> { r#" for V in $DATA; do echo $V; @@ -483,7 +483,7 @@ mod analyzes_return_type { fn script( data: &str, exit_code: u32, - ) -> impl Iterator> { + ) -> impl Iterator> + use<> { r#" for V in $DATA; do echo $V; @@ -542,7 +542,7 @@ mod analyzes_return_type { fn script( data: &str, exit_code: u32, - ) -> Result, BoxedError> { + ) -> Result + use<>, BoxedError> { r#" for V in $DATA; do echo $V; @@ -594,7 +594,7 @@ mod analyzes_return_type { fn script( data: &str, exit_code: u32, - ) -> Result, BoxedError> { + ) -> Result + use<>, BoxedError> { r#" for V in $DATA; do echo $V; @@ -639,7 +639,7 @@ mod analyzes_return_type { fn script( data: &str, exit_code: u32, - ) -> Result>, BoxedError> + ) -> Result> + use<>, BoxedError> { r#" for V in $DATA; do From 1203e985476dd09ea677cd4bf134e6ee93056b3c Mon Sep 17 00:00:00 2001 From: Weronika Tarnawska Date: Fri, 4 Sep 2026 09:41:34 +0200 Subject: [PATCH 2/6] Fixes needed after edition upgrade --- shellfn-attribute/src/block_builder.rs | 32 +++++++++++++------------- shellfn-attribute/src/lib.rs | 2 +- shellfn-attribute/src/utils.rs | 12 +++++----- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/shellfn-attribute/src/block_builder.rs b/shellfn-attribute/src/block_builder.rs index 5a1b3e5..d36110a 100644 --- a/shellfn-attribute/src/block_builder.rs +++ b/shellfn-attribute/src/block_builder.rs @@ -56,7 +56,7 @@ impl BlockBuilder { match arg { Receiver(_) => "self".to_string(), Typed(pat_type) => match pat_type.pat.as_ref() { - Ident(ref pat_ident) => pat_ident.ident.to_string(), + Ident(pat_ident) => pat_ident.ident.to_string(), Wild(_) => continue, _ => panic!("captured arguments with pattern other than simple Ident are not yet supported"), }, @@ -71,8 +71,8 @@ impl BlockBuilder { ReturnType::Default => { self.with_unit_return_type(); } - ReturnType::Type(_, ref t) => match **t { - Type::Path(ref type_path) if is_result_type_path(type_path) => { + ReturnType::Type(_, t) => match *t { + Type::Path(type_path) if is_result_type_path(&type_path) => { self.outer_result = true; let args = &type_path.path.segments.last().unwrap().arguments; @@ -80,13 +80,13 @@ impl BlockBuilder { if let PathArguments::AngleBracketed(path_args) = args { if let Some(arg) = path_args.args.first() { match arg { - GenericArgument::Type(Type::ImplTrait(ref imp)) => { + GenericArgument::Type(Type::ImplTrait(imp)) => { self.with_impl_trait(imp) } - GenericArgument::Type(ref t) if is_unit_type(t) => { + GenericArgument::Type(t) if is_unit_type(t) => { self.with_unit_return_type(); } - GenericArgument::Type(ref t) if is_vec_type(t) => { + GenericArgument::Type(t) if is_vec_type(t) => { self.with_vec_return_type(t); } _ => {} @@ -94,14 +94,14 @@ impl BlockBuilder { } } } - Type::ImplTrait(ref imp) => { + Type::ImplTrait(imp) => { self.outer_result = false; - self.with_impl_trait(imp); + self.with_impl_trait(&imp); } - ref t if is_vec_type(t) => self.with_vec_return_type(t), - ref t if is_unit_type(t) => self.with_unit_return_type(), + t if is_vec_type(&t) => self.with_vec_return_type(&t), + t if is_unit_type(&t) => self.with_unit_return_type(), Type::Path(_) => {} - ref t => panic!("Unsupported return type {:#?}", t), + t => panic!("Unsupported return type {:#?}", t), }, } self @@ -114,11 +114,11 @@ impl BlockBuilder { fn with_vec_return_type(&mut self, typ: &Type) { self.output_type = OutputType::Vec; - if let Type::Path(ref type_path) = typ { + if let Type::Path(type_path) = typ { let args = &type_path.path.segments.last().unwrap().arguments; if let PathArguments::AngleBracketed(path_args) = args { - if let Some(GenericArgument::Type(ref t)) = path_args.args.first() { + if let Some(GenericArgument::Type(t)) = path_args.args.first() { self.inner_result = is_result_type(t); } } @@ -126,13 +126,13 @@ impl BlockBuilder { } fn with_impl_trait(&mut self, imp: &TypeImplTrait) { - if let Some(TypeParamBound::Trait(ref bound)) = imp.bounds.first() { + if let Some(TypeParamBound::Trait(bound)) = imp.bounds.first() { if let Some(segment) = bound.path.segments.first() { if segment.ident == "Iterator" { self.output_type = OutputType::Iter; - if let PathArguments::AngleBracketed(ref path_args) = segment.arguments { - if let Some(GenericArgument::AssocType(ref binding)) = + if let PathArguments::AngleBracketed(path_args) = &segment.arguments { + if let Some(GenericArgument::AssocType(binding)) = path_args.args.first() { if binding.ident == "Item" && is_result_type(&binding.ty) { diff --git a/shellfn-attribute/src/lib.rs b/shellfn-attribute/src/lib.rs index 14789ba..ed946a8 100644 --- a/shellfn-attribute/src/lib.rs +++ b/shellfn-attribute/src/lib.rs @@ -32,7 +32,7 @@ pub fn shell(attr: TokenStream, input: TokenStream) -> TokenStream { if let Some(Stmt::Expr( Expr::Lit(ExprLit { - lit: Lit::Str(ref program), + lit: Lit::Str(program), .. }), _, diff --git a/shellfn-attribute/src/utils.rs b/shellfn-attribute/src/utils.rs index c973d56..7d962ef 100644 --- a/shellfn-attribute/src/utils.rs +++ b/shellfn-attribute/src/utils.rs @@ -1,15 +1,15 @@ use syn::{Type, TypePath}; pub fn is_result_type(typ: &Type) -> bool { - if let Type::Path(ref type_path) = *typ { - is_path_to("Result", type_path) + if let Type::Path(type_path) = typ { + is_path_to("Result", &type_path) } else { false } } pub fn is_unit_type(typ: &Type) -> bool { - if let Type::Tuple(ref tuple) = typ { + if let Type::Tuple(tuple) = typ { return tuple.elems.is_empty(); } @@ -17,15 +17,15 @@ pub fn is_unit_type(typ: &Type) -> bool { } pub fn is_vec_type(typ: &Type) -> bool { - if let Type::Path(ref type_path) = *typ { - is_vec_type_path(type_path) + if let Type::Path(type_path) = typ { + is_vec_type_path(&type_path) } else { false } } pub fn is_result_type_path(type_path: &TypePath) -> bool { - is_path_to("Result", type_path) + is_path_to("Result", &type_path) } pub fn is_vec_type_path(type_path: &TypePath) -> bool { From 8077ae5ba7d35c20c985f6ad94b26c01653f0444 Mon Sep 17 00:00:00 2001 From: Weronika Tarnawska Date: Fri, 4 Sep 2026 09:42:04 +0200 Subject: [PATCH 3/6] Update syn and darling --- shellfn-attribute/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shellfn-attribute/Cargo.toml b/shellfn-attribute/Cargo.toml index ce243b6..c3c0ddd 100644 --- a/shellfn-attribute/Cargo.toml +++ b/shellfn-attribute/Cargo.toml @@ -12,9 +12,9 @@ proc-macro = true path = "src/lib.rs" [dependencies] -syn = { version = "2", features = ["full", "extra-traits"] } +syn = { version = "3", features = ["full", "extra-traits"] } quote = "1" proc-macro2 = "1" -darling = "0.20" +darling = "0.24" shellwords = "1" shellfn-core = { path = "../shellfn-core", version = "0.2.0" } From 67e2e827995a6307948f7b4dabc3bee1d645796a Mon Sep 17 00:00:00 2001 From: Weronika Tarnawska Date: Fri, 4 Sep 2026 11:48:25 +0200 Subject: [PATCH 4/6] Update CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3682b14..7b45a1d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ permissions: contents: read env: - clippy_rust_version: '1.84' + clippy_rust_version: '1.85' jobs: test: From f7635e6fafe1665451df2db9133e47d00a75312a Mon Sep 17 00:00:00 2001 From: synek317 Date: Fri, 4 Sep 2026 12:24:05 +0200 Subject: [PATCH 5/6] Update ci.yml to use rust 1.88 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7b45a1d..d555d9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ permissions: contents: read env: - clippy_rust_version: '1.85' + clippy_rust_version: '1.88' jobs: test: From 2abf7c30a0b2342705f3bb22fcaa2f19a440158a Mon Sep 17 00:00:00 2001 From: synek317 Date: Fri, 4 Sep 2026 12:28:56 +0200 Subject: [PATCH 6/6] fmt + clippy --- examples/calendar.rs | 2 +- examples/git.rs | 2 +- examples/python.rs | 2 +- rustfmt.toml | 1 - shellfn-attribute/src/attributes.rs | 2 +- shellfn-attribute/src/block_builder.rs | 22 ++++++++++------------ shellfn-attribute/src/utils.rs | 6 +++--- shellfn-core/src/execute/item.rs | 2 +- shellfn-core/src/execute/iter.rs | 2 +- shellfn-core/src/execute/void.rs | 2 +- tests/tests.rs | 4 ++-- 11 files changed, 22 insertions(+), 25 deletions(-) delete mode 100644 rustfmt.toml diff --git a/examples/calendar.rs b/examples/calendar.rs index 9225f7f..058aed4 100644 --- a/examples/calendar.rs +++ b/examples/calendar.rs @@ -7,5 +7,5 @@ fn run(module: &str) -> Result> { } fn main() -> Result<(), Box> { - run("calendar").map(|output| println!("{}", output)) + run("calendar").map(|output| println!("{output}")) } diff --git a/examples/git.rs b/examples/git.rs index eeba5e6..369cbcb 100644 --- a/examples/git.rs +++ b/examples/git.rs @@ -11,7 +11,7 @@ fn list_modified(dir: &str) -> Result + use<>, Box< fn main() -> Result<(), Box> { for modified in list_modified(".")? { - println!("You have modified the file: {}", modified); + println!("You have modified the file: {modified}"); } Ok(()) } diff --git a/examples/python.rs b/examples/python.rs index bd2a255..1c34b44 100644 --- a/examples/python.rs +++ b/examples/python.rs @@ -18,6 +18,6 @@ print(json.dumps(obj, indent=indent, sort_keys=sort_keys)) fn main() -> Result<(), Box> { let json = r#"{"foo": 42, "bar": { "baz": 10, "qux": [1, 2, 3]}}"#; let pretty_json = pretty_json(json, 2, false)?; - println!("{}", pretty_json); + println!("{pretty_json}"); Ok(()) } diff --git a/rustfmt.toml b/rustfmt.toml deleted file mode 100644 index 1acc2f2..0000000 --- a/rustfmt.toml +++ /dev/null @@ -1 +0,0 @@ -struct_field_align_threshold = 50 diff --git a/shellfn-attribute/src/attributes.rs b/shellfn-attribute/src/attributes.rs index 9aff730..4d93ddf 100644 --- a/shellfn-attribute/src/attributes.rs +++ b/shellfn-attribute/src/attributes.rs @@ -3,7 +3,7 @@ use darling::FromMeta; #[derive(Debug, Default, FromMeta)] pub struct Attributes { #[darling(default = "default_cmd")] - pub cmd: String, + pub cmd: String, #[darling(default)] pub no_panic: bool, } diff --git a/shellfn-attribute/src/block_builder.rs b/shellfn-attribute/src/block_builder.rs index d36110a..94803ba 100644 --- a/shellfn-attribute/src/block_builder.rs +++ b/shellfn-attribute/src/block_builder.rs @@ -9,14 +9,14 @@ const PROGRAM: &str = "PROGRAM"; #[derive(Default)] pub struct BlockBuilder { - program: String, - cmd: String, - args: Vec, - envs: Vec, - output_type: OutputType, + program: String, + cmd: String, + args: Vec, + envs: Vec, + output_type: OutputType, outer_result: bool, inner_result: bool, - no_panic: bool, + no_panic: bool, } impl BlockBuilder { @@ -48,8 +48,8 @@ impl BlockBuilder { } pub fn with_args<'a>(mut self, args: impl Iterator) -> Self { - use syn::Pat::*; use FnArg::*; + use syn::Pat::*; for arg in args { self.envs.push( @@ -101,7 +101,7 @@ impl BlockBuilder { t if is_vec_type(&t) => self.with_vec_return_type(&t), t if is_unit_type(&t) => self.with_unit_return_type(), Type::Path(_) => {} - t => panic!("Unsupported return type {:#?}", t), + t => panic!("Unsupported return type {t:#?}"), }, } self @@ -132,9 +132,7 @@ impl BlockBuilder { self.output_type = OutputType::Iter; if let PathArguments::AngleBracketed(path_args) = &segment.arguments { - if let Some(GenericArgument::AssocType(binding)) = - path_args.args.first() - { + if let Some(GenericArgument::AssocType(binding)) = path_args.args.first() { if binding.ident == "Item" && is_result_type(&binding.ty) { self.inner_result = true; } @@ -182,7 +180,7 @@ impl BlockBuilder { return arg_tokens; } - let pattern = format!("${}", var_name); + let pattern = format!("${var_name}"); if arg.contains(&pattern) { quote! { #arg_tokens.replace(#pattern, &envs[#i].1) } diff --git a/shellfn-attribute/src/utils.rs b/shellfn-attribute/src/utils.rs index 7d962ef..94f61d9 100644 --- a/shellfn-attribute/src/utils.rs +++ b/shellfn-attribute/src/utils.rs @@ -2,7 +2,7 @@ use syn::{Type, TypePath}; pub fn is_result_type(typ: &Type) -> bool { if let Type::Path(type_path) = typ { - is_path_to("Result", &type_path) + is_path_to("Result", type_path) } else { false } @@ -18,14 +18,14 @@ pub fn is_unit_type(typ: &Type) -> bool { pub fn is_vec_type(typ: &Type) -> bool { if let Type::Path(type_path) = typ { - is_vec_type_path(&type_path) + is_vec_type_path(type_path) } else { false } } pub fn is_result_type_path(type_path: &TypePath) -> bool { - is_path_to("Result", &type_path) + is_path_to("Result", type_path) } pub fn is_vec_type_path(type_path: &TypePath) -> bool { diff --git a/shellfn-core/src/execute/item.rs b/shellfn-core/src/execute/item.rs index cf9e33a..67f288f 100644 --- a/shellfn-core/src/execute/item.rs +++ b/shellfn-core/src/execute/item.rs @@ -1,5 +1,5 @@ use crate::error::Error; -use crate::utils::{spawn, PANIC_MSG}; +use crate::utils::{PANIC_MSG, spawn}; use std::error::Error as StdError; use std::ffi::OsStr; use std::str::FromStr; diff --git a/shellfn-core/src/execute/iter.rs b/shellfn-core/src/execute/iter.rs index a20d227..10e0477 100644 --- a/shellfn-core/src/execute/iter.rs +++ b/shellfn-core/src/execute/iter.rs @@ -1,5 +1,5 @@ use crate::error::Error; -use crate::utils::{spawn, PANIC_MSG}; +use crate::utils::{PANIC_MSG, spawn}; use itertools::Either; use std::error::Error as StdError; use std::ffi::OsStr; diff --git a/shellfn-core/src/execute/void.rs b/shellfn-core/src/execute/void.rs index b777660..5ca9c5c 100644 --- a/shellfn-core/src/execute/void.rs +++ b/shellfn-core/src/execute/void.rs @@ -1,5 +1,5 @@ use crate::error::{Error, NeverError}; -use crate::utils::{spawn, PANIC_MSG}; +use crate::utils::{PANIC_MSG, spawn}; use std::ffi::OsStr; use std::process::{Child, Output}; diff --git a/tests/tests.rs b/tests/tests.rs index 4f865bd..636ef3f 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -651,8 +651,8 @@ mod analyzes_return_type { } #[shell(cmd = "dummy_invalid_command_123")] - fn invalid_script( - ) -> Result>, BoxedError> + fn invalid_script() + -> Result>, BoxedError> { r#" invalid script iter