Skip to content

Commit 3e47076

Browse files
committed
♻️ Fix basic clippy
1 parent f5d4110 commit 3e47076

File tree

8 files changed

+15
-24
lines changed

8 files changed

+15
-24
lines changed

src/main.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const BALLS_INSERT_END: &str = "\n// balls-insert-end";
4545

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

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

6666
Ok(())
6767
}
@@ -88,7 +88,7 @@ fn main() {
8888

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

91-
let errored = print_errors(&src, &file_path, errs, |tok_span| {
91+
let errored = print_errors(&src, file_path, errs, |tok_span| {
9292
resolve_span_span(tok_span, &spanned_tokens)
9393
});
9494

src/parser/ast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl MacroArg {
2020
pub fn balls_repr(&self) -> String {
2121
match self {
2222
Self::Num(num) => format!("0x{:x}", num),
23-
Self::ArgRef(ident) => format!("{}", ident),
23+
Self::ArgRef(ident) => ident.to_string(),
2424
}
2525
}
2626
}

src/parser/parser.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -161,20 +161,13 @@ fn statement() -> impl Parser<Token, Statement, Error = Simple<Token>> {
161161
if stated.ident.is_none() && !matches!(stated.expr.inner, Expr::Call { .. }) {
162162
emit(Simple::custom(
163163
span,
164-
format!("Top-level expression not allowed"),
164+
"Top-level expression not allowed".to_string(),
165165
))
166166
}
167167
stated
168168
})
169169
}
170170

171-
fn stack_parameters() -> impl Parser<Token, Vec<Spanned<String>>, Error = Simple<Token>> {
172-
ident()
173-
.map_with_span(Spanned::new)
174-
.list()
175-
.delimited_by(just(Token::OpenSquare), just(Token::CloseSquare))
176-
}
177-
178171
fn function_definition() -> impl Parser<Token, Ast, Error = Simple<Token>> {
179172
// fn TRANSFER
180173
let macro_def = just(Token::Fn).ignore_then(ident());

src/parser/tokens.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ pub enum Token {
2929
Assign,
3030
}
3131

32-
impl Into<String> for Token {
33-
fn into(self) -> String {
34-
format!("{}", self)
32+
impl From<Token> for String {
33+
fn from(val: Token) -> Self {
34+
format!("{}", val)
3535
}
3636
}
3737

src/scheduling/actions.rs

-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ pub fn get_actions<'a>(
2626
let deepest_idx = total_stack_el.saturating_sub(17);
2727

2828
(deepest_idx..total_stack_el)
29-
.into_iter()
3029
.filter_map(move |i| {
3130
(deepest_idx..total_stack_el).find_map(|j| {
3231
if i != j && machine.stack[i] == machine.stack[j] {
@@ -39,7 +38,6 @@ pub fn get_actions<'a>(
3938
.chain(unpoppable.clone().into_iter().map(Action::Unpop))
4039
.chain(
4140
(0..info.nodes.len())
42-
.into_iter()
4341
.filter_map(move |id| {
4442
if machine.blocked_by[id] != Some(0) || unpoppable.contains(&id) {
4543
return None;

src/scheduling/astar.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ impl FastHasher {
143143
unsafe { *buf = 0 };
144144

145145
value.hash(&mut self.0);
146-
let hash = self.0.finish();
147-
hash
146+
147+
self.0.finish()
148148
}
149149
}
150150

@@ -269,10 +269,10 @@ pub trait AStarScheduler: Sized + Sync + Send {
269269
fn estimate_explored_map_size(
270270
&mut self,
271271
_info: ScheduleInfo,
272-
start_state: &BackwardsMachine,
273-
max_stack_depth: usize,
272+
_start_state: &BackwardsMachine,
273+
_max_stack_depth: usize,
274274
) -> usize {
275-
let blocks = start_state.total_blocked() as usize;
275+
// let blocks = start_state.total_blocked() as usize;
276276
// blocks * max_stack_depth * max_stack_depth * 3
277277
19_000_000
278278
}

src/scheduling/machine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl BackwardsMachine {
8282
info: ScheduleInfo,
8383
steps: &mut Vec<Step>,
8484
) -> Result<(), String> {
85-
if self.stack.len() == 0 {
85+
if self.stack.is_empty() {
8686
debug_assert_eq!(
8787
info.target_input_stack.len(),
8888
0,

src/transformer/analysis.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ pub fn validate_and_get_symbols(nodes: Vec<Spanned<Ast>>) -> Result<Symbols, Vec
390390
..
391391
}) => {
392392
assert!(
393-
op.stack_in == other_op.stack_in && op.stack_out == op.stack_out,
393+
op.stack_in == other_op.stack_in && op.stack_out == other_op.stack_out,
394394
"Mismatching variant op in std_ops {:?} vs. {:?}",
395395
op,
396396
other_op

0 commit comments

Comments
 (0)