Skip to content

Commit e1cbe59

Browse files
committed
Clippy fixes
Update .gitignore
1 parent a044c18 commit e1cbe59

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.vscode
12
/target
23
Cargo.lock
34
book/book

calculator/src/compiler/interpreter.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ impl Eval {
2929
match node {
3030
Node::Int(n) => *n,
3131
Node::UnaryExpr { op, child } => {
32-
let child = self.eval(&child);
32+
let child = self.eval(child);
3333
match op {
3434
Operator::Plus => child,
3535
Operator::Minus => -child,
3636
}
3737
}
3838
Node::BinaryExpr { op, lhs, rhs } => {
39-
let lhs_ret = self.eval(&lhs);
40-
let rhs_ret = self.eval(&rhs);
39+
let lhs_ret = self.eval(lhs);
40+
let rhs_ret = self.eval(rhs);
4141

4242
match op {
4343
Operator::Plus => lhs_ret + rhs_ret,

calculator/src/compiler/jit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ impl<'a> RecursiveBuilder<'a> {
6464
match ast {
6565
Node::Int(n) => self.i32_type.const_int(*n as u64, true),
6666
Node::UnaryExpr { op, child } => {
67-
let child = self.build(&child);
67+
let child = self.build(child);
6868
match op {
6969
Operator::Minus => child.const_neg(),
7070
Operator::Plus => child,
7171
}
7272
}
7373
Node::BinaryExpr { op, lhs, rhs } => {
74-
let left = self.build(&lhs);
75-
let right = self.build(&rhs);
74+
let left = self.build(lhs);
75+
let right = self.build(rhs);
7676

7777
match op {
7878
Operator::Plus => self.builder.build_int_add(left, right, "plus_temp"),

calculator/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cfg_if! {
1313
fn main() {
1414
let args: Vec<String> = std::env::args().collect();
1515
if args.len() < 2 {
16-
eprintln!("Not input file was provided");
16+
eprintln!("No input file was provided");
1717
std::process::exit(-1);
1818
}
1919
println!(

calculator/src/parser.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::upper_case_acronyms)]
2+
13
use pest::{self, Parser};
24

35
use crate::ast::{Node, Operator};
@@ -50,7 +52,7 @@ fn build_ast_from_term(pair: pest::iterators::Pair<Rule>) -> Node {
5052
let istr = pair.as_str();
5153
let (sign, istr) = match &istr[..1] {
5254
"-" => (-1, &istr[1..]),
53-
_ => (1, &istr[..]),
55+
_ => (1, istr),
5456
};
5557
let int: i32 = istr.parse().unwrap();
5658
Node::Int(sign * int)

0 commit comments

Comments
 (0)