Skip to content

Commit

Permalink
♻️ Fix basic clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Philogy committed Mar 20, 2024
1 parent f5d4110 commit 14add0d
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 36 deletions.
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ chumsky = "0.9.3"
clap = { version = "4.5.1", features = ["derive"] }
num-bigint = "0.4.4"


[dependencies.xxhash-rust]
version = "0.8.8"
features = ["xxh3", "const_xxh3"]

[lib]
path = "src/lib.rs"

Expand Down
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
too-many-arguments-threshold = 10
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const BALLS_INSERT_END: &str = "\n// balls-insert-end";

fn splice_into_huff(path: &str, content_to_inject: String) -> Result<(), String> {
let content =
std::fs::read_to_string(&path).map_err(|_| format!("Failed to read file {}", path))?;
std::fs::read_to_string(path).map_err(|_| format!("Failed to read file {}", path))?;
let start_index = content
.find(BALLS_INSERT_START)
.ok_or(format!("Could not find \"{}\"", BALLS_INSERT_START))?
Expand All @@ -61,7 +61,7 @@ fn splice_into_huff(path: &str, content_to_inject: String) -> Result<(), String>
&content[end_index..]
);

std::fs::write(&path, new_content).map_err(|_| format!("Failed to write file {}", path))?;
std::fs::write(path, new_content).map_err(|_| format!("Failed to write file {}", path))?;

Ok(())
}
Expand All @@ -88,7 +88,7 @@ fn main() {

let (maybe_ast_nodes, errs) = parser::parse_tokens(tokens.clone());

let errored = print_errors(&src, &file_path, errs, |tok_span| {
let errored = print_errors(&src, file_path, errs, |tok_span| {
resolve_span_span(tok_span, &spanned_tokens)
});

Expand Down
2 changes: 1 addition & 1 deletion src/parser/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl MacroArg {
pub fn balls_repr(&self) -> String {
match self {
Self::Num(num) => format!("0x{:x}", num),
Self::ArgRef(ident) => format!("{}", ident),
Self::ArgRef(ident) => ident.to_string(),
}
}
}
Expand Down
9 changes: 1 addition & 8 deletions src/parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,13 @@ fn statement() -> impl Parser<Token, Statement, Error = Simple<Token>> {
if stated.ident.is_none() && !matches!(stated.expr.inner, Expr::Call { .. }) {
emit(Simple::custom(
span,
format!("Top-level expression not allowed"),
"Top-level expression not allowed".to_string(),
))
}
stated
})
}

fn stack_parameters() -> impl Parser<Token, Vec<Spanned<String>>, Error = Simple<Token>> {
ident()
.map_with_span(Spanned::new)
.list()
.delimited_by(just(Token::OpenSquare), just(Token::CloseSquare))
}

fn function_definition() -> impl Parser<Token, Ast, Error = Simple<Token>> {
// fn TRANSFER
let macro_def = just(Token::Fn).ignore_then(ident());
Expand Down
6 changes: 3 additions & 3 deletions src/parser/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ pub enum Token {
Assign,
}

impl Into<String> for Token {
fn into(self) -> String {
format!("{}", self)
impl From<Token> for String {
fn from(val: Token) -> Self {
format!("{}", val)
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/scheduling/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ pub fn get_actions<'a>(
let deepest_idx = total_stack_el.saturating_sub(17);

(deepest_idx..total_stack_el)
.into_iter()
.filter_map(move |i| {
(deepest_idx..total_stack_el).find_map(|j| {
if i != j && machine.stack[i] == machine.stack[j] {
Expand All @@ -39,7 +38,6 @@ pub fn get_actions<'a>(
.chain(unpoppable.clone().into_iter().map(Action::Unpop))
.chain(
(0..info.nodes.len())
.into_iter()
.filter_map(move |id| {
if machine.blocked_by[id] != Some(0) || unpoppable.contains(&id) {
return None;
Expand Down
10 changes: 5 additions & 5 deletions src/scheduling/astar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ impl FastHasher {
unsafe { *buf = 0 };

value.hash(&mut self.0);
let hash = self.0.finish();
hash

self.0.finish()
}
}

Expand Down Expand Up @@ -269,10 +269,10 @@ pub trait AStarScheduler: Sized + Sync + Send {
fn estimate_explored_map_size(
&mut self,
_info: ScheduleInfo,
start_state: &BackwardsMachine,
max_stack_depth: usize,
_start_state: &BackwardsMachine,
_max_stack_depth: usize,
) -> usize {
let blocks = start_state.total_blocked() as usize;
// let blocks = start_state.total_blocked() as usize;
// blocks * max_stack_depth * max_stack_depth * 3
19_000_000
}
Expand Down
2 changes: 1 addition & 1 deletion src/scheduling/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl BackwardsMachine {
info: ScheduleInfo,
steps: &mut Vec<Step>,
) -> Result<(), String> {
if self.stack.len() == 0 {
if self.stack.is_empty() {
debug_assert_eq!(
info.target_input_stack.len(),
0,
Expand Down
2 changes: 1 addition & 1 deletion src/transformer/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ pub fn validate_and_get_symbols(nodes: Vec<Spanned<Ast>>) -> Result<Symbols, Vec
..
}) => {
assert!(
op.stack_in == other_op.stack_in && op.stack_out == op.stack_out,
op.stack_in == other_op.stack_in && op.stack_out == other_op.stack_out,
"Mismatching variant op in std_ops {:?} vs. {:?}",
op,
other_op
Expand Down

0 comments on commit 14add0d

Please sign in to comment.