aboutsummaryrefslogtreecommitdiffstats
path: root/src/parse/mod.rs
diff options
context:
space:
mode:
authorJonas Maier <>2026-03-10 18:03:39 +0100
committerJonas Maier <>2026-03-10 18:03:39 +0100
commit1361e3088224860b143755e9fe1f1d7ce033e476 (patch)
tree2aaa89f1e20001b2cedd4055f24a30fcdff127d5 /src/parse/mod.rs
parentff3ac68d159869d57e2cc190236d08c64e00b867 (diff)
downloadpish-1361e3088224860b143755e9fe1f1d7ce033e476.tar.gz
clippy
Diffstat (limited to 'src/parse/mod.rs')
-rw-r--r--src/parse/mod.rs26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/parse/mod.rs b/src/parse/mod.rs
index 4250caf..0df624f 100644
--- a/src/parse/mod.rs
+++ b/src/parse/mod.rs
@@ -41,7 +41,7 @@ pub enum Ast<T: Stage> {
pub fn decl(name: ExpString, body: Ast<PreExpansion>) -> Ast<PreExpansion> {
Ast::FunDecl(FunDecl {
- name: name,
+ name,
body: FunBody {
body: Box::new(body),
},
@@ -411,10 +411,10 @@ impl ExpString {
}
fn is_symbol(x: u8) -> bool {
- match x {
- b';' | b'|' | b'{' | b'}' | b'$' | b'(' | b')' | b'\'' | b'"' => true,
- _ => false,
- }
+ matches!(
+ x,
+ b';' | b'|' | b'{' | b'}' | b'$' | b'(' | b')' | b'\'' | b'"'
+ )
}
fn is_var_begin(x: u8) -> bool {
@@ -618,10 +618,8 @@ impl Parse for ExpString {
let cmd = Ast::parse(b)?;
b.spaces();
- if b.is_empty() {
- if !b.is_completion() {
- return Err(ParseError::Expected(')'));
- }
+ if b.is_empty() && !b.is_completion() {
+ return Err(ParseError::Expected(')'));
}
if b.has() && b.peek() == b')' {
@@ -799,7 +797,7 @@ impl Pipes<PreExpansion> {
}
}
-pub fn completion_context<'a, E: Expander>(x: &'a [u8], e: &mut E) -> CompletionContext {
+pub fn completion_context<E: Expander>(x: &[u8], e: &mut E) -> CompletionContext {
let mut cursor = Cursor::new(x, ParseMode::Completion);
let ast = Ast::parse(&mut cursor);
@@ -900,10 +898,7 @@ impl<'a> Cursor<'a> {
}
fn is_completion(&self) -> bool {
- match self.mode {
- ParseMode::Completion => true,
- _ => false,
- }
+ matches!(self.mode, ParseMode::Completion)
}
fn parse<T: Parse>(&mut self) -> Result<T> {
@@ -946,8 +941,7 @@ impl Parse for Command<PreExpansion> {
Err(e) => Err(e)?,
}
}
- let x = Ok(Self { cmd: path, args });
- x
+ Ok(Self { cmd: path, args })
}
}