From e43a0dba18468506271b5945686d7612b76b4290 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Mon, 2 Feb 2026 17:36:28 -0800 Subject: [PATCH 1/5] Deny unreachable-pub --- Cargo.toml | 1 + src/count.rs | 2 +- src/enclosure.rs | 4 ++-- src/list.rs | 10 +++++----- src/positional.rs | 6 ++++-- src/shebang.rs | 2 +- src/show_whitespace.rs | 2 +- src/verbosity.rs | 2 +- 8 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 98bf598fb7..8e9f9fa543 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,6 +66,7 @@ which = "8.0.0" [lints.rust] mismatched_lifetime_syntaxes = "allow" unexpected_cfgs = { level = "warn", check-cfg = ['cfg(fuzzing)'] } +unreachable_pub = "deny" [lints.clippy] all = { level = "deny", priority = -1 } diff --git a/src/count.rs b/src/count.rs index b6504c99c5..ae451d4153 100644 --- a/src/count.rs +++ b/src/count.rs @@ -1,6 +1,6 @@ use super::*; -pub struct Count(pub T, pub usize); +pub(crate) struct Count(pub T, pub usize); impl Display for Count { fn fmt(&self, f: &mut Formatter) -> fmt::Result { diff --git a/src/enclosure.rs b/src/enclosure.rs index d1cf3eada1..0a6f94bed6 100644 --- a/src/enclosure.rs +++ b/src/enclosure.rs @@ -1,12 +1,12 @@ use super::*; -pub struct Enclosure { +pub(crate) struct Enclosure { enclosure: &'static str, value: T, } impl Enclosure { - pub fn tick(value: T) -> Enclosure { + pub(crate) fn tick(value: T) -> Enclosure { Self { enclosure: "`", value, diff --git a/src/list.rs b/src/list.rs index 00eb81aa86..9580ddc859 100644 --- a/src/list.rs +++ b/src/list.rs @@ -1,32 +1,32 @@ use super::*; -pub struct List + Clone> { +pub(crate) struct List + Clone> { conjunction: &'static str, values: I, } impl + Clone> List { - pub fn or>(values: II) -> Self { + pub(crate) fn or>(values: II) -> Self { Self { conjunction: "or", values: values.into_iter(), } } - pub fn and>(values: II) -> Self { + pub(crate) fn and>(values: II) -> Self { Self { conjunction: "and", values: values.into_iter(), } } - pub fn or_ticked>( + pub(crate) fn or_ticked>( values: II, ) -> List, impl Iterator> + Clone> { List::or(values.into_iter().map(Enclosure::tick)) } - pub fn and_ticked>( + pub(crate) fn and_ticked>( values: II, ) -> List, impl Iterator> + Clone> { List::and(values.into_iter().map(Enclosure::tick)) diff --git a/src/positional.rs b/src/positional.rs index 2db8ffee01..5c8c05c77c 100644 --- a/src/positional.rs +++ b/src/positional.rs @@ -27,7 +27,7 @@ use super::*; /// For modes that do take other arguments, the search argument is simply /// prepended to rest. #[cfg_attr(test, derive(PartialEq, Eq, Debug))] -pub struct Positional { +pub(crate) struct Positional { /// Everything else pub arguments: Vec, /// Overrides from values of the form `[a-zA-Z_][a-zA-Z0-9_-]*=.*` @@ -37,7 +37,9 @@ pub struct Positional { } impl Positional { - pub fn from_values<'values>(values: Option>) -> Self { + pub(crate) fn from_values<'values>( + values: Option>, + ) -> Self { let mut overrides = Vec::new(); let mut search_directory = None; let mut arguments = Vec::new(); diff --git a/src/shebang.rs b/src/shebang.rs index eae43a88ea..d629674483 100644 --- a/src/shebang.rs +++ b/src/shebang.rs @@ -30,7 +30,7 @@ impl<'line> Shebang<'line> { }) } - pub fn interpreter_filename(&self) -> &str { + pub(crate) fn interpreter_filename(&self) -> &str { self .interpreter .split(['/', '\\']) diff --git a/src/show_whitespace.rs b/src/show_whitespace.rs index a98c0247bd..ad48ac8679 100644 --- a/src/show_whitespace.rs +++ b/src/show_whitespace.rs @@ -1,7 +1,7 @@ use super::*; /// String wrapper that uses nonblank characters to display spaces and tabs -pub struct ShowWhitespace<'str>(pub &'str str); +pub(crate) struct ShowWhitespace<'str>(pub &'str str); impl Display for ShowWhitespace<'_> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { diff --git a/src/verbosity.rs b/src/verbosity.rs index 65db6952e2..14a6988c7f 100644 --- a/src/verbosity.rs +++ b/src/verbosity.rs @@ -32,7 +32,7 @@ impl Verbosity { self >= Self::Grandiloquent } - pub const fn default() -> Self { + pub(crate) const fn default() -> Self { Self::Taciturn } } From f854571be44950ccc4bb97750af1f9ef713c0dcd Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Mon, 2 Feb 2026 17:42:59 -0800 Subject: [PATCH 2/5] Use Self --- Cargo.toml | 27 +++++++++++++++------------ src/compile_error.rs | 2 +- src/enclosure.rs | 2 +- src/error.rs | 2 +- src/expression.rs | 29 ++++++++++------------------- src/justfile.rs | 8 ++++---- src/keyword.rs | 2 +- src/output_error.rs | 2 +- src/signal.rs | 34 +++++++++++++++++----------------- src/summary.rs | 44 ++++++++++++++++++++++---------------------- src/thunk.rs | 2 +- 11 files changed, 74 insertions(+), 80 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8e9f9fa543..e7d201d9d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,19 +71,22 @@ unreachable_pub = "deny" [lints.clippy] all = { level = "deny", priority = -1 } arbitrary-source-item-ordering = "deny" -enum_glob_use = "allow" -ignore_without_reason = "allow" -needless_pass_by_value = "allow" +enum-glob-use = "allow" +ignore-without-reason = "allow" +missing-const-for-fn = "allow" +needless-pass-by-value = "allow" +nursery = { level = "deny", priority = -1 } pedantic = { level = "deny", priority = -1 } -similar_names = "allow" -struct_excessive_bools = "allow" -struct_field_names = "allow" -too_many_arguments = "allow" -too_many_lines = "allow" -type_complexity = "allow" -undocumented_unsafe_blocks = "deny" -unnecessary_wraps = "allow" -wildcard_imports = "allow" +redundant-pub-crate = "allow" +similar-names = "allow" +struct-excessive-bools = "allow" +struct-field-names = "allow" +too-many-arguments = "allow" +too-many-lines = "allow" +type-complexity = "allow" +undocumented-unsafe-blocks = "deny" +unnecessary-wraps = "allow" +wildcard-imports = "allow" [lib] doctest = false diff --git a/src/compile_error.rs b/src/compile_error.rs index 6064099bab..50a7d06bea 100644 --- a/src/compile_error.rs +++ b/src/compile_error.rs @@ -11,7 +11,7 @@ impl<'src> CompileError<'src> { self.token } - pub(crate) fn new(token: Token<'src>, kind: CompileErrorKind<'src>) -> CompileError<'src> { + pub(crate) fn new(token: Token<'src>, kind: CompileErrorKind<'src>) -> Self { Self { token, kind: kind.into(), diff --git a/src/enclosure.rs b/src/enclosure.rs index 0a6f94bed6..30363a213a 100644 --- a/src/enclosure.rs +++ b/src/enclosure.rs @@ -6,7 +6,7 @@ pub(crate) struct Enclosure { } impl Enclosure { - pub(crate) fn tick(value: T) -> Enclosure { + pub(crate) fn tick(value: T) -> Self { Self { enclosure: "`", value, diff --git a/src/error.rs b/src/error.rs index ba4eeb1753..a776178624 100644 --- a/src/error.rs +++ b/src/error.rs @@ -330,7 +330,7 @@ impl<'src> From> for Error<'src> { } impl<'src> From for Error<'src> { - fn from(dotenv_error: dotenvy::Error) -> Error<'src> { + fn from(dotenv_error: dotenvy::Error) -> Self { Self::Dotenv { dotenv_error } } } diff --git a/src/expression.rs b/src/expression.rs index ab4d21f275..d736f07f1f 100644 --- a/src/expression.rs +++ b/src/expression.rs @@ -9,15 +9,12 @@ use super::*; #[derive(PartialEq, Debug, Clone)] pub(crate) enum Expression<'src> { /// `lhs && rhs` - And { - lhs: Box>, - rhs: Box>, - }, + And { lhs: Box, rhs: Box }, /// `assert(condition, error)` Assert { name: Name<'src>, condition: Condition<'src>, - error: Box>, + error: Box, }, /// `contents` Backtick { @@ -27,33 +24,27 @@ pub(crate) enum Expression<'src> { /// `name(arguments)` Call { thunk: Thunk<'src> }, /// `lhs + rhs` - Concatenation { - lhs: Box>, - rhs: Box>, - }, + Concatenation { lhs: Box, rhs: Box }, /// `if condition { then } else { otherwise }` Conditional { condition: Condition<'src>, - then: Box>, - otherwise: Box>, + then: Box, + otherwise: Box, }, // `f"format string"` FormatString { start: StringLiteral<'src>, - expressions: Vec<(Expression<'src>, StringLiteral<'src>)>, + expressions: Vec<(Self, StringLiteral<'src>)>, }, /// `(contents)` - Group { contents: Box> }, + Group { contents: Box }, /// `lhs / rhs` Join { - lhs: Option>>, - rhs: Box>, + lhs: Option>, + rhs: Box, }, /// `lhs || rhs` - Or { - lhs: Box>, - rhs: Box>, - }, + Or { lhs: Box, rhs: Box }, /// `"string_literal"` or `'string_literal'` StringLiteral { string_literal: StringLiteral<'src> }, /// `variable` diff --git a/src/justfile.rs b/src/justfile.rs index b6e06395fc..b8ec6b615e 100644 --- a/src/justfile.rs +++ b/src/justfile.rs @@ -12,7 +12,7 @@ pub(crate) struct Justfile<'src> { pub(crate) loaded: Vec, #[serde(skip)] pub(crate) module_path: String, - pub(crate) modules: Table<'src, Justfile<'src>>, + pub(crate) modules: Table<'src, Self>, #[serde(skip)] pub(crate) name: Option>, #[serde(skip)] @@ -80,7 +80,7 @@ impl<'src> Justfile<'src> { config: &'run Config, dotenv: &'run BTreeMap, root: &'run Scope<'src, 'run>, - scopes: &mut BTreeMap, &'run Scope<'src, 'run>)>, + scopes: &mut BTreeMap)>, search: &'run Search, ) -> RunResult<'src> { let scope = Evaluator::evaluate_assignments(config, dotenv, self, root, search)?; @@ -265,7 +265,7 @@ impl<'src> Justfile<'src> { is_dependency: bool, ran: &Ran, recipe: &Recipe<'src>, - scopes: &BTreeMap, &Scope<'src, '_>)>, + scopes: &BTreeMap)>, search: &Search, ) -> RunResult<'src> { let mutex = ran.mutex(recipe, arguments); @@ -345,7 +345,7 @@ impl<'src> Justfile<'src> { evaluator: &mut Evaluator<'src, 'run>, ran: &Ran, recipe: &Recipe<'src>, - scopes: &BTreeMap, &Scope<'src, 'run>)>, + scopes: &BTreeMap)>, search: &Search, ) -> RunResult<'src> { if context.config.no_dependencies { diff --git a/src/keyword.rs b/src/keyword.rs index 1f0d9186b0..bae639ebaa 100644 --- a/src/keyword.rs +++ b/src/keyword.rs @@ -38,7 +38,7 @@ pub(crate) enum Keyword { } impl Keyword { - pub(crate) fn from_lexeme(lexeme: &str) -> Option { + pub(crate) fn from_lexeme(lexeme: &str) -> Option { lexeme.parse().ok() } diff --git a/src/output_error.rs b/src/output_error.rs index 9f8f3e1ba2..4533284345 100644 --- a/src/output_error.rs +++ b/src/output_error.rs @@ -17,7 +17,7 @@ pub(crate) enum OutputError { } impl OutputError { - pub(crate) fn result_from_exit_status(exit_status: ExitStatus) -> Result<(), OutputError> { + pub(crate) fn result_from_exit_status(exit_status: ExitStatus) -> Result<(), Self> { match exit_status.code() { Some(0) => Ok(()), Some(code) => Err(Self::Code(code)), diff --git a/src/signal.rs b/src/signal.rs index ed78a60795..67cb167edf 100644 --- a/src/signal.rs +++ b/src/signal.rs @@ -20,8 +20,8 @@ pub(crate) enum Signal { impl Signal { #[cfg(not(windows))] - pub(crate) const ALL: &'static [Signal] = &[ - Signal::Hangup, + pub(crate) const ALL: &'static [Self] = &[ + Self::Hangup, #[cfg(any( target_os = "dragonfly", target_os = "freebsd", @@ -30,10 +30,10 @@ impl Signal { target_os = "netbsd", target_os = "openbsd", ))] - Signal::Info, - Signal::Interrupt, - Signal::Quit, - Signal::Terminate, + Self::Info, + Self::Interrupt, + Self::Quit, + Self::Terminate, ]; pub(crate) fn code(self) -> i32 { @@ -66,7 +66,7 @@ impl Display for Signal { f, "{}", match self { - Signal::Hangup => "SIGHUP", + Self::Hangup => "SIGHUP", #[cfg(any( target_os = "dragonfly", target_os = "freebsd", @@ -75,10 +75,10 @@ impl Display for Signal { target_os = "netbsd", target_os = "openbsd", ))] - Signal::Info => "SIGINFO", - Signal::Interrupt => "SIGINT", - Signal::Quit => "SIGQUIT", - Signal::Terminate => "SIGTERM", + Self::Info => "SIGINFO", + Self::Interrupt => "SIGINT", + Self::Quit => "SIGQUIT", + Self::Terminate => "SIGTERM", } ) } @@ -108,9 +108,9 @@ impl From for nix::sys::signal::Signal { impl TryFrom for Signal { type Error = io::Error; - fn try_from(n: u8) -> Result { + fn try_from(n: u8) -> Result { match n { - 1 => Ok(Signal::Hangup), + 1 => Ok(Self::Hangup), #[cfg(any( target_os = "dragonfly", target_os = "freebsd", @@ -119,10 +119,10 @@ impl TryFrom for Signal { target_os = "netbsd", target_os = "openbsd", ))] - 29 => Ok(Signal::Info), - 2 => Ok(Signal::Interrupt), - 3 => Ok(Signal::Quit), - 15 => Ok(Signal::Terminate), + 29 => Ok(Self::Info), + 2 => Ok(Self::Interrupt), + 3 => Ok(Self::Quit), + 15 => Ok(Self::Terminate), _ => Err(io::Error::other(format!("unexpected signal: {n}"))), } } diff --git a/src/summary.rs b/src/summary.rs index 6fa77421ef..0066b2622e 100644 --- a/src/summary.rs +++ b/src/summary.rs @@ -184,42 +184,42 @@ impl Assignment { #[derive(Eq, PartialEq, Hash, Ord, PartialOrd, Debug, Clone)] pub enum Expression { And { - lhs: Box, - rhs: Box, + lhs: Box, + rhs: Box, }, Assert { condition: Condition, - error: Box, + error: Box, }, Backtick { command: String, }, Call { name: String, - arguments: Vec, + arguments: Vec, }, Concatenation { - lhs: Box, - rhs: Box, + lhs: Box, + rhs: Box, }, Conditional { - lhs: Box, - rhs: Box, - then: Box, - otherwise: Box, + lhs: Box, + rhs: Box, + then: Box, + otherwise: Box, operator: ConditionalOperator, }, FormatString { start: String, - expressions: Vec<(Expression, String)>, + expressions: Vec<(Self, String)>, }, Join { - lhs: Option>, - rhs: Box, + lhs: Option>, + rhs: Box, }, Or { - lhs: Box, - rhs: Box, + lhs: Box, + rhs: Box, }, String { text: String, @@ -241,13 +241,13 @@ impl Expression { condition: full::Condition { lhs, rhs, operator }, error, .. - } => Expression::Assert { + } => Self::Assert { condition: Condition { - lhs: Box::new(Expression::new(lhs)), - rhs: Box::new(Expression::new(rhs)), + lhs: Box::new(Self::new(lhs)), + rhs: Box::new(Self::new(rhs)), operator: ConditionalOperator::new(*operator), }, - error: Box::new(Expression::new(error)), + error: Box::new(Self::new(error)), }, Backtick { contents, .. } => Self::Backtick { command: (*contents).clone(), @@ -281,11 +281,11 @@ impl Expression { args: (a, rest), .. } => { - let mut arguments = vec![Expression::new(a)]; + let mut arguments = vec![Self::new(a)]; for arg in rest { - arguments.push(Expression::new(arg)); + arguments.push(Self::new(arg)); } - Expression::Call { + Self::Call { name: name.lexeme().to_owned(), arguments, } diff --git a/src/thunk.rs b/src/thunk.rs index df17dec0f0..f72e8e383e 100644 --- a/src/thunk.rs +++ b/src/thunk.rs @@ -63,7 +63,7 @@ impl<'src> Thunk<'src> { pub(crate) fn resolve( name: Name<'src>, mut arguments: Vec>, - ) -> CompileResult<'src, Thunk<'src>> { + ) -> CompileResult<'src, Self> { function::get(name.lexeme()).map_or( Err(name.error(CompileErrorKind::UnknownFunction { function: name.lexeme(), From c0c3581883078622d48cbc1b39e9d3e49a699231 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Mon, 2 Feb 2026 17:46:59 -0800 Subject: [PATCH 3/5] More lints --- src/error.rs | 2 +- src/subcommand.rs | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/error.rs b/src/error.rs index a776178624..81a6ef5f9e 100644 --- a/src/error.rs +++ b/src/error.rs @@ -329,7 +329,7 @@ impl<'src> From> for Error<'src> { } } -impl<'src> From for Error<'src> { +impl From for Error<'_> { fn from(dotenv_error: dotenvy::Error) -> Self { Self::Dotenv { dotenv_error } } diff --git a/src/subcommand.rs b/src/subcommand.rs index 55a0ce8601..1fb8deab31 100644 --- a/src/subcommand.rs +++ b/src/subcommand.rs @@ -83,7 +83,7 @@ impl Subcommand { &config.search_config, )?; - if let Edit = self { + if matches!(self, Edit) { return Self::edit(&search); } @@ -617,10 +617,8 @@ impl Subcommand { } let no_groups = ordered_groups.len() == 1 && ordered_groups.first() == Some(&None); - let mut groups_count = 0; - if !no_groups { - groups_count = ordered_groups.len(); - } + + let groups_count = if no_groups { 0 } else { ordered_groups.len() }; for (i, group) in ordered_groups.into_iter().enumerate() { if i > 0 { From e4fcf451d16f7223baee506c223eac8732b97c2f Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Mon, 2 Feb 2026 18:16:31 -0800 Subject: [PATCH 4/5] Revise --- Cargo.toml | 34 ++++++++++++++++++---------------- src/justfile.rs | 14 ++++++++------ tests/test.rs | 2 +- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e7d201d9d6..b88540fede 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,23 +70,25 @@ unreachable_pub = "deny" [lints.clippy] all = { level = "deny", priority = -1 } -arbitrary-source-item-ordering = "deny" -enum-glob-use = "allow" -ignore-without-reason = "allow" -missing-const-for-fn = "allow" -needless-pass-by-value = "allow" -nursery = { level = "deny", priority = -1 } +arbitrary_source_item_ordering = "deny" +derive_partial_eq_without_eq = "allow" +enum_glob_use = "allow" +ignore_without_reason = "allow" +missing_const_for_fn = "allow" +needless_pass_by_value = "allow" +option_if_let_else = "allow" pedantic = { level = "deny", priority = -1 } -redundant-pub-crate = "allow" -similar-names = "allow" -struct-excessive-bools = "allow" -struct-field-names = "allow" -too-many-arguments = "allow" -too-many-lines = "allow" -type-complexity = "allow" -undocumented-unsafe-blocks = "deny" -unnecessary-wraps = "allow" -wildcard-imports = "allow" +redundant_pub_crate = "allow" +similar_names = "allow" +struct_excessive_bools = "allow" +struct_field_names = "allow" +too_many_arguments = "allow" +too_many_lines = "allow" +type_complexity = "allow" +undocumented_unsafe_blocks = "deny" +unnecessary_wraps = "allow" +useless_let_if_seq = "allow" +wildcard_imports = "allow" [lib] doctest = false diff --git a/src/justfile.rs b/src/justfile.rs index b8ec6b615e..0bfcfb4c95 100644 --- a/src/justfile.rs +++ b/src/justfile.rs @@ -268,12 +268,16 @@ impl<'src> Justfile<'src> { scopes: &BTreeMap)>, search: &Search, ) -> RunResult<'src> { - let mutex = ran.mutex(recipe, arguments); + { + let mutex = ran.mutex(recipe, arguments); - let mut guard = mutex.lock().unwrap(); + let mut guard = mutex.lock().unwrap(); - if *guard { - return Ok(()); + if *guard { + return Ok(()); + } + + *guard = true; } if !config.yes && !recipe.confirm()? { @@ -332,8 +336,6 @@ impl<'src> Justfile<'src> { search, )?; - *guard = true; - Ok(()) } diff --git a/tests/test.rs b/tests/test.rs index d7c60d5c99..37161d30d6 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -358,7 +358,7 @@ impl Test { } } -pub fn assert_eval_eq(expression: &str, result: &str) { +pub(crate) fn assert_eval_eq(expression: &str, result: &str) { Test::new() .justfile(format!("x := {expression}")) .args(["--evaluate", "x"]) From 272779abda8c9571d674ef5775940df14b4c8dd2 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Mon, 2 Feb 2026 18:20:13 -0800 Subject: [PATCH 5/5] Reform --- Cargo.toml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b88540fede..545011120d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,14 +71,10 @@ unreachable_pub = "deny" [lints.clippy] all = { level = "deny", priority = -1 } arbitrary_source_item_ordering = "deny" -derive_partial_eq_without_eq = "allow" enum_glob_use = "allow" ignore_without_reason = "allow" -missing_const_for_fn = "allow" needless_pass_by_value = "allow" -option_if_let_else = "allow" pedantic = { level = "deny", priority = -1 } -redundant_pub_crate = "allow" similar_names = "allow" struct_excessive_bools = "allow" struct_field_names = "allow" @@ -87,7 +83,6 @@ too_many_lines = "allow" type_complexity = "allow" undocumented_unsafe_blocks = "deny" unnecessary_wraps = "allow" -useless_let_if_seq = "allow" wildcard_imports = "allow" [lib]