fix clippy warnings or disable unneeded lints

This commit is contained in:
Schrottkatze 2023-11-20 11:05:55 +01:00
parent 6af2c7c02c
commit daa551caa3
10 changed files with 88 additions and 79 deletions

View file

@ -113,7 +113,7 @@ fn check_missing_sink(syntax: &[PipelineElement]) -> Result<(), logos::Span> {
fn check_literal_as_sink(syntax: &[PipelineElement]) -> Result<(), logos::Span> {
let last_block: Option<&[PipelineElement]> = syntax
.split(|PipelineElement { kind, span: _ }| kind == &PipelineElementKind::Pipe)
.split(|PipelineElement { kind, .. }| kind == &PipelineElementKind::Pipe)
.last();
// there HAS to be a better way to do this... this is HORRIBLE
@ -124,16 +124,16 @@ fn check_literal_as_sink(syntax: &[PipelineElement]) -> Result<(), logos::Span>
}) = last_block.first()
{
if let Some(first_part) = parts.first() {
if !matches!(
if matches!(
first_part,
CommandPart {
kind: CommandPartKind::Word(_),
span: _
..
}
) {
Err(span.clone())
} else {
Ok(())
} else {
Err(span.clone())
}
} else {
Ok(())
@ -156,7 +156,7 @@ fn check_literal_as_filter(syntax: &[PipelineElement]) -> Result<(), Vec<logos::
element,
PipelineElement {
kind: PipelineElementKind::Pipe,
span: _
..
}
)
})
@ -169,14 +169,14 @@ fn check_literal_as_filter(syntax: &[PipelineElement]) -> Result<(), Vec<logos::
return None;
};
let Some(CommandPart { kind, span: _ }) = c.first() else {
let Some(CommandPart { kind, .. }) = c.first() else {
return None;
};
if !matches!(kind, CommandPartKind::Word(_)) {
Some(span)
} else {
if matches!(kind, CommandPartKind::Word(_)) {
None
} else {
Some(span)
}
})
.filter_map(|err| err.map(Clone::clone))
@ -200,7 +200,7 @@ fn check_literal_with_args(syntax: &[PipelineElement]) -> Result<(), logos::Span
c.first(),
Some(CommandPart {
kind: CommandPartKind::Word(_),
span: _
..
})
)
{

View file

@ -1,5 +1,3 @@
use logos::Logos;
use logos::Span;
@ -52,7 +50,9 @@ pub fn parse_syntax(input: &str) -> Result<Vec<PipelineElement>, Vec<logos::Span
let span = partial_command.first().unwrap().span.start
..partial_command.last().unwrap().span.end;
r.push(PipelineElement {
kind: PipelineElementKind::Command(std::mem::take(&mut partial_command)),
kind: PipelineElementKind::Command(std::mem::take(
&mut partial_command,
)),
span,
});
}
@ -77,7 +77,6 @@ pub fn parse_syntax(input: &str) -> Result<Vec<PipelineElement>, Vec<logos::Span
kind: CommandPartKind::String(string),
span,
}),
_ => {}
}
} else {
errs.push(span);