Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ 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 }
arbitrary-source-item-ordering = "deny"
arbitrary_source_item_ordering = "deny"
enum_glob_use = "allow"
ignore_without_reason = "allow"
needless_pass_by_value = "allow"
Expand Down
2 changes: 1 addition & 1 deletion src/compile_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/count.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;

pub struct Count<T: Display>(pub T, pub usize);
pub(crate) struct Count<T: Display>(pub T, pub usize);

impl<T: Display> Display for Count<T> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
Expand Down
4 changes: 2 additions & 2 deletions src/enclosure.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use super::*;

pub struct Enclosure<T: Display> {
pub(crate) struct Enclosure<T: Display> {
enclosure: &'static str,
value: T,
}

impl<T: Display> Enclosure<T> {
pub fn tick(value: T) -> Enclosure<T> {
pub(crate) fn tick(value: T) -> Self {
Self {
enclosure: "`",
value,
Expand Down
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ impl<'src> From<ConstError<'src>> for Error<'src> {
}
}

impl<'src> From<dotenvy::Error> for Error<'src> {
fn from(dotenv_error: dotenvy::Error) -> Error<'src> {
impl From<dotenvy::Error> for Error<'_> {
fn from(dotenv_error: dotenvy::Error) -> Self {
Self::Dotenv { dotenv_error }
}
}
Expand Down
29 changes: 10 additions & 19 deletions src/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ use super::*;
#[derive(PartialEq, Debug, Clone)]
pub(crate) enum Expression<'src> {
/// `lhs && rhs`
And {
lhs: Box<Expression<'src>>,
rhs: Box<Expression<'src>>,
},
And { lhs: Box<Self>, rhs: Box<Self> },
/// `assert(condition, error)`
Assert {
name: Name<'src>,
condition: Condition<'src>,
error: Box<Expression<'src>>,
error: Box<Self>,
},
/// `contents`
Backtick {
Expand All @@ -27,33 +24,27 @@ pub(crate) enum Expression<'src> {
/// `name(arguments)`
Call { thunk: Thunk<'src> },
/// `lhs + rhs`
Concatenation {
lhs: Box<Expression<'src>>,
rhs: Box<Expression<'src>>,
},
Concatenation { lhs: Box<Self>, rhs: Box<Self> },
/// `if condition { then } else { otherwise }`
Conditional {
condition: Condition<'src>,
then: Box<Expression<'src>>,
otherwise: Box<Expression<'src>>,
then: Box<Self>,
otherwise: Box<Self>,
},
// `f"format string"`
FormatString {
start: StringLiteral<'src>,
expressions: Vec<(Expression<'src>, StringLiteral<'src>)>,
expressions: Vec<(Self, StringLiteral<'src>)>,
},
/// `(contents)`
Group { contents: Box<Expression<'src>> },
Group { contents: Box<Self> },
/// `lhs / rhs`
Join {
lhs: Option<Box<Expression<'src>>>,
rhs: Box<Expression<'src>>,
lhs: Option<Box<Self>>,
rhs: Box<Self>,
},
/// `lhs || rhs`
Or {
lhs: Box<Expression<'src>>,
rhs: Box<Expression<'src>>,
},
Or { lhs: Box<Self>, rhs: Box<Self> },
/// `"string_literal"` or `'string_literal'`
StringLiteral { string_literal: StringLiteral<'src> },
/// `variable`
Expand Down
22 changes: 12 additions & 10 deletions src/justfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub(crate) struct Justfile<'src> {
pub(crate) loaded: Vec<PathBuf>,
#[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<Name<'src>>,
#[serde(skip)]
Expand Down Expand Up @@ -80,7 +80,7 @@ impl<'src> Justfile<'src> {
config: &'run Config,
dotenv: &'run BTreeMap<String, String>,
root: &'run Scope<'src, 'run>,
scopes: &mut BTreeMap<String, (&'run Justfile<'src>, &'run Scope<'src, 'run>)>,
scopes: &mut BTreeMap<String, (&'run Self, &'run Scope<'src, 'run>)>,
search: &'run Search,
) -> RunResult<'src> {
let scope = Evaluator::evaluate_assignments(config, dotenv, self, root, search)?;
Expand Down Expand Up @@ -265,15 +265,19 @@ impl<'src> Justfile<'src> {
is_dependency: bool,
ran: &Ran,
recipe: &Recipe<'src>,
scopes: &BTreeMap<String, (&Justfile<'src>, &Scope<'src, '_>)>,
scopes: &BTreeMap<String, (&Self, &Scope<'src, '_>)>,
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()? {
Expand Down Expand Up @@ -332,8 +336,6 @@ impl<'src> Justfile<'src> {
search,
)?;

*guard = true;

Ok(())
}

Expand All @@ -345,7 +347,7 @@ impl<'src> Justfile<'src> {
evaluator: &mut Evaluator<'src, 'run>,
ran: &Ran,
recipe: &Recipe<'src>,
scopes: &BTreeMap<String, (&Justfile<'src>, &Scope<'src, 'run>)>,
scopes: &BTreeMap<String, (&Self, &Scope<'src, 'run>)>,
search: &Search,
) -> RunResult<'src> {
if context.config.no_dependencies {
Expand Down
2 changes: 1 addition & 1 deletion src/keyword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub(crate) enum Keyword {
}

impl Keyword {
pub(crate) fn from_lexeme(lexeme: &str) -> Option<Keyword> {
pub(crate) fn from_lexeme(lexeme: &str) -> Option<Self> {
lexeme.parse().ok()
}

Expand Down
10 changes: 5 additions & 5 deletions src/list.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
use super::*;

pub struct List<T: Display, I: Iterator<Item = T> + Clone> {
pub(crate) struct List<T: Display, I: Iterator<Item = T> + Clone> {
conjunction: &'static str,
values: I,
}

impl<T: Display, I: Iterator<Item = T> + Clone> List<T, I> {
pub fn or<II: IntoIterator<Item = T, IntoIter = I>>(values: II) -> Self {
pub(crate) fn or<II: IntoIterator<Item = T, IntoIter = I>>(values: II) -> Self {
Self {
conjunction: "or",
values: values.into_iter(),
}
}

pub fn and<II: IntoIterator<Item = T, IntoIter = I>>(values: II) -> Self {
pub(crate) fn and<II: IntoIterator<Item = T, IntoIter = I>>(values: II) -> Self {
Self {
conjunction: "and",
values: values.into_iter(),
}
}

pub fn or_ticked<II: IntoIterator<Item = T, IntoIter = I>>(
pub(crate) fn or_ticked<II: IntoIterator<Item = T, IntoIter = I>>(
values: II,
) -> List<Enclosure<T>, impl Iterator<Item = Enclosure<T>> + Clone> {
List::or(values.into_iter().map(Enclosure::tick))
}

pub fn and_ticked<II: IntoIterator<Item = T, IntoIter = I>>(
pub(crate) fn and_ticked<II: IntoIterator<Item = T, IntoIter = I>>(
values: II,
) -> List<Enclosure<T>, impl Iterator<Item = Enclosure<T>> + Clone> {
List::and(values.into_iter().map(Enclosure::tick))
Expand Down
2 changes: 1 addition & 1 deletion src/output_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
6 changes: 4 additions & 2 deletions src/positional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
/// Overrides from values of the form `[a-zA-Z_][a-zA-Z0-9_-]*=.*`
Expand All @@ -37,7 +37,9 @@ pub struct Positional {
}

impl Positional {
pub fn from_values<'values>(values: Option<impl IntoIterator<Item = &'values str>>) -> Self {
pub(crate) fn from_values<'values>(
values: Option<impl IntoIterator<Item = &'values str>>,
) -> Self {
let mut overrides = Vec::new();
let mut search_directory = None;
let mut arguments = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion src/shebang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl<'line> Shebang<'line> {
})
}

pub fn interpreter_filename(&self) -> &str {
pub(crate) fn interpreter_filename(&self) -> &str {
self
.interpreter
.split(['/', '\\'])
Expand Down
2 changes: 1 addition & 1 deletion src/show_whitespace.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
34 changes: 17 additions & 17 deletions src/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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 {
Expand Down Expand Up @@ -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",
Expand All @@ -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",
}
)
}
Expand Down Expand Up @@ -108,9 +108,9 @@ impl From<Signal> for nix::sys::signal::Signal {
impl TryFrom<u8> for Signal {
type Error = io::Error;

fn try_from(n: u8) -> Result<Signal, Self::Error> {
fn try_from(n: u8) -> Result<Self, Self::Error> {
match n {
1 => Ok(Signal::Hangup),
1 => Ok(Self::Hangup),
#[cfg(any(
target_os = "dragonfly",
target_os = "freebsd",
Expand All @@ -119,10 +119,10 @@ impl TryFrom<u8> 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}"))),
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/subcommand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl Subcommand {
&config.search_config,
)?;

if let Edit = self {
if matches!(self, Edit) {
return Self::edit(&search);
}

Expand Down Expand Up @@ -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 {
Expand Down
Loading