Skip to content

Commit

Permalink
Fix clippy warnings and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gahag committed May 11, 2024
1 parent 41adf74 commit 6c48794
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ where
type Context = T::Context;

fn fmt(&self, f: &mut std::fmt::Formatter<'_>, context: Self::Context) -> std::fmt::Result {
(&**self).fmt(f, context)
(**self).fmt(f, context)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/lib/typecheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Typecheck {
match context.args() {
[ value, Value::String(expected) ] => {
let expected_type = Type
::parse(&expected)
::parse(expected)
.ok_or_else(
|| Panic::value_error(
Value::String(expected.copy()),
Expand Down
3 changes: 1 addition & 2 deletions src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub mod value;
#[cfg(test)]
mod tests;

use std::{collections::HashMap, ops::Deref};
use std::collections::HashMap;

use crate::symbol::{self, Symbol};
use super::semantic::program;
Expand Down Expand Up @@ -454,7 +454,6 @@ impl Runtime {
),

(Value::Array(ref array), Value::Int(ix)) => array
.deref()
.set(ix, value)
.map_err(|_| Panic::index_out_of_bounds(Value::Int(ix), pos.into()))?,

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/value/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl Array {


// GcCell does not implement Eq because `borrow` might panic.
#[allow(clippy::derive_hash_xor_eq)]
#[allow(clippy::derived_hash_with_manual_eq)]
impl Hash for Array {
fn hash<H: Hasher>(&self, state: &mut H) {
self.borrow().hash(state)
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/value/dict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Ord for Dict {

/// We need Hash in order to be able to store dicts as keys in other dicts.
// GcCell does not implement Eq because `borrow` might panic.
#[allow(clippy::derive_hash_xor_eq)]
#[allow(clippy::derived_hash_with_manual_eq)]
impl Hash for Dict {
fn hash<H: Hasher>(&self, state: &mut H) {
// This is very expensive, but there is no better way to correctly compare.
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/value/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ impl Eq for RustFun { }

impl PartialOrd for RustFun {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.name().partial_cmp(other.name())
Some(self.cmp(other))
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/semantic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use program::{
RedirectionTarget,
Statement,
};
pub use error::{Error, ErrorKind, Errors, ErrorsDisplayContext};
pub use error::{Error, Errors, ErrorsDisplayContext};


/// Static semantic analyzer.
Expand Down Expand Up @@ -486,6 +486,7 @@ impl<'a> Analyzer<'a> {
ast::Literal::Function { params, body } => {
let mut analyzer = self.enter_frame();

#[allow(clippy::manual_try_fold)] // We don't want to short circuit here.
let params_result = params
.iter()
.fold(
Expand Down
2 changes: 1 addition & 1 deletion src/syntax/lexer/automata/argument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ where
if !c.is_word_start() {
self.error = true;
}
if self.braces == None {
if self.braces.is_none() {
self.braces = Some(false);
}

Expand Down
2 changes: 1 addition & 1 deletion src/syntax/lexer/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ macro_rules! assert_symbol {
/// Check that TokenKind is not too big, because it gets moved around a lot.
#[test]
fn test_token_kind_size() {
assert_eq!(std::mem::size_of::<TokenKind>(), 32);
assert!(std::mem::size_of::<TokenKind>() <= 32);
}


Expand Down
2 changes: 1 addition & 1 deletion src/syntax/parser/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ where
&self.token,
// The current token is a single unquoted number
Some(Token { kind: TokenKind::Argument(parts), .. })
if matches!(parts.as_ref(), &[ref part] if part.is_unquoted_number())
if matches!(parts.as_ref(), [part] if part.is_unquoted_number())
// And the next token is a redirection operator.
&& matches!(
self.cursor.peek(),
Expand Down
2 changes: 1 addition & 1 deletion src/syntax/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ where
.with_sync(sync::Strategy::keyword(Keyword::End))?;

Ok(ast::Expr::If {
condition: condition.into(),
condition,
then,
otherwise,
pos,
Expand Down
2 changes: 1 addition & 1 deletion src/term/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{
fmt::{self, Debug, Display},
};

pub use termion::color::{Black, Blue, Green, Red, Yellow};
pub use termion::color::{Blue, Green, Red, Yellow};


thread_local! {
Expand Down

0 comments on commit 6c48794

Please sign in to comment.