Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
elkowar committed Dec 8, 2024
1 parent 2ba6f39 commit 2760eb7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ fn run_command(args: Args) -> Result<()> {
println!("Git state:");
yolk.paths()
.start_git_command_builder()?
.args(&["status", "--short"])
.args(["status", "--short"])
.status()
.into_diagnostic()?;
}
Expand Down
2 changes: 1 addition & 1 deletion src/templating/comment_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl CommentStyle {
tagged_line: line, ..
},
..
} => &line,
} => line,
Element::Conditional { blocks, .. } => &blocks.first()?.tagged_line,
Element::Plain(_) => return None,
};
Expand Down
16 changes: 7 additions & 9 deletions src/templating/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<'a> Sp<&'a str> {
}
}

impl<'a, T> Sp<T> {
impl<T> Sp<T> {
fn new(range: Range<usize>, content: T) -> Self {
Self { range, content }
}
Expand All @@ -68,13 +68,13 @@ pub struct TaggedLine<'a> {
pub full_line: Sp<&'a str>,
}

pub fn parse_document<'a>(s: &'a str) -> Result<Vec<Element<'a>>, YolkParseFailure> {
pub fn parse_document(s: &str) -> Result<Vec<Element<'_>>, YolkParseFailure> {
let p = repeat(0.., p_element);
try_parse(p, s)
}

#[allow(unused)]
pub fn parse_element<'a>(s: &'a str) -> Result<Element<'a>, YolkParseFailure> {
pub fn parse_element(s: &str) -> Result<Element<'_>, YolkParseFailure> {
let p = terminated(p_element, repeat(0.., line_ending).map(|_: ()| ()));
try_parse(p, s)
}
Expand All @@ -93,20 +93,20 @@ pub fn try_parse<'a, P: Parser<Input<'a>, T, YolkParseError>, T>(

fn p_element<'a>(input: &mut Input<'a>) -> PResult<Element<'a>> {
trace("peek any", peek(any)).parse_next(input)?;
Ok(alt((
alt((
p_inline_element.context(lbl("inline element")),
p_nextline_element.context(lbl("nextline element")),
p_conditional_element.context(lbl("conditional element")),
p_multiline_element.context(lbl("multiline element")),
p_plain_line_element.context(lbl("plain line")),
fail.context(lbl("valid element")),
))
.parse_next(input)
// .resume_after(
// repeat_till(1.., (not(line_ending), any), line_ending)
// .map(|((), _)| ())
// .void(),
// )
.parse_next(input)?)
// .unwrap_or_else(|| Element::Plain(Sp::new(0..0, ""))))
}

Expand Down Expand Up @@ -141,9 +141,7 @@ fn test_p_text_segment() -> TestResult {
Ok(())
}

fn p_regular_tag_inner<'a>(
end: &'a str,
) -> impl winnow::Parser<Input<'a>, &'a str, YolkParseError> {
fn p_regular_tag_inner(end: &str) -> impl winnow::Parser<Input<'_>, &'_ str, YolkParseError> {
trace("p_regular_tag_inner", move |i: &mut _| {
repeat_till(1.., (not(line_ending), not(end), any), peek(end))
.map(|(_, _): ((), _)| ())
Expand Down Expand Up @@ -340,7 +338,7 @@ fn p_conditional_element<'a>(input: &mut Input<'a>) -> PResult<Element<'a>> {

let mut blocks = Vec::new();
blocks.push(if_body);
blocks.extend(elif_bodies.into_iter());
blocks.extend(elif_bodies);
Ok(Element::Conditional {
blocks,
else_block: else_block.map(|x| x.map_expr(|_| ())),
Expand Down
2 changes: 1 addition & 1 deletion src/yolk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl Yolk {
.prepare_eval_ctx_for_templates(mode)
.context("Failed to prepare eval_ctx")?;
eval_ctx
.eval_lua::<Value>("expr", &expr)?
.eval_lua::<Value>("expr", expr)?
.to_string()
.into_diagnostic()
}
Expand Down
12 changes: 6 additions & 6 deletions src/yolk_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl YolkPaths {
/// Start an invocation of the `git` command with the `--git-dir` and `--work-tree` set to the yolk git and root path.
pub fn start_git_command_builder(&self) -> Result<std::process::Command> {
let mut cmd = std::process::Command::new("git");
cmd.current_dir(self.root_path()).args(&[
cmd.current_dir(self.root_path()).args([
"--git-dir",
&self.active_yolk_git_dir()?.to_string_lossy(),
"--work-tree",
Expand Down Expand Up @@ -296,21 +296,21 @@ fn check_is_deployed_recursive(
let target_root = target_root.as_ref();
let egg_root = egg_root.as_ref();
let current = current.as_ref();
let target_file = target_root.join(current.strip_prefix(&egg_root).into_diagnostic()?);
let target_file = target_root.join(current.strip_prefix(egg_root).into_diagnostic()?);
if target_file.is_symlink() && target_file.canonical()? == current {
return Ok(true);
Ok(true)
} else if target_file.is_file() {
return Ok(false);
Ok(false)
} else if target_file.is_dir() {
for entry in fs_err::read_dir(current).into_diagnostic()? {
let entry = entry.into_diagnostic()?;
if !check_is_deployed_recursive(target_root, egg_root, entry.path())? {
return Ok(false);
}
}
return Ok(true);
Ok(true)
} else {
return Ok(false);
Ok(false)
}
}

Expand Down

0 comments on commit 2760eb7

Please sign in to comment.