Skip to content

Commit 0682b35

Browse files
authored
Merge pull request #27 from scileo/remove-clippy-warnings
Remove clippy warnings
2 parents f44962a + f1a74ff commit 0682b35

13 files changed

+78
-107
lines changed

src/environment.rs

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::namespace::{Namespace, Namespaces};
2+
use crate::repl;
23
use crate::rust_core;
4+
use crate::symbol::Symbol;
35
use crate::value::{ToValue, Value};
4-
use crate::Symbol;
5-
use crate::repl;
66

77
use std::cell::RefCell;
88
use std::collections::HashMap;
@@ -68,21 +68,21 @@ impl Environment {
6868
}
6969
pub fn clojure_core_environment() -> Rc<Environment> {
7070
// Register our macros / functions ahead of time
71-
let add_fn = rust_core::AddFn {};
72-
let str_fn = rust_core::StrFn {};
73-
let do_fn = rust_core::DoFn {};
74-
let nth_fn = rust_core::NthFn {};
75-
let do_macro = rust_core::DoMacro {};
76-
let concat_fn = rust_core::ConcatFn {};
77-
let print_string_fn = rust_core::PrintStringFn {};
78-
// Hardcoded fns
79-
let lexical_eval_fn = Value::LexicalEvalFn {};
80-
// Hardcoded macros
81-
let let_macro = Value::LetMacro {};
82-
let quote_macro = Value::QuoteMacro {};
83-
let def_macro = Value::DefMacro {};
84-
let fn_macro = Value::FnMacro {};
85-
let defmacro_macro = Value::DefmacroMacro {};
71+
let add_fn = rust_core::AddFn {};
72+
let str_fn = rust_core::StrFn {};
73+
let do_fn = rust_core::DoFn {};
74+
let nth_fn = rust_core::NthFn {};
75+
let do_macro = rust_core::DoMacro {};
76+
let concat_fn = rust_core::ConcatFn {};
77+
let print_string_fn = rust_core::PrintStringFn {};
78+
// Hardcoded fns
79+
let lexical_eval_fn = Value::LexicalEvalFn {};
80+
// Hardcoded macros
81+
let let_macro = Value::LetMacro {};
82+
let quote_macro = Value::QuoteMacro {};
83+
let def_macro = Value::DefMacro {};
84+
let fn_macro = Value::FnMacro {};
85+
let defmacro_macro = Value::DefmacroMacro {};
8686
let environment = Rc::new(Environment::new_main_environment());
8787

8888
let eval_fn = rust_core::EvalFn::new(Rc::clone(&environment));
@@ -96,33 +96,33 @@ impl Environment {
9696
environment.insert(Symbol::intern("defmacro"), defmacro_macro.to_rc_value());
9797
environment.insert(Symbol::intern("eval"), eval_fn.to_rc_value());
9898

99-
environment.insert(Symbol::intern("+"), add_fn.to_rc_value());
100-
environment.insert(Symbol::intern("let"), let_macro.to_rc_value());
101-
environment.insert(Symbol::intern("str"), str_fn.to_rc_value());
102-
environment.insert(Symbol::intern("quote"), quote_macro.to_rc_value());
103-
environment.insert(Symbol::intern("do-fn*"), do_fn.to_rc_value());
104-
environment.insert(Symbol::intern("do"), do_macro.to_rc_value());
105-
environment.insert(Symbol::intern("def"), def_macro.to_rc_value());
106-
environment.insert(Symbol::intern("fn"), fn_macro.to_rc_value());
107-
environment.insert(Symbol::intern("defmacro"), defmacro_macro.to_rc_value());
108-
environment.insert(Symbol::intern("eval"), eval_fn.to_rc_value());
109-
environment.insert(
99+
environment.insert(Symbol::intern("+"), add_fn.to_rc_value());
100+
environment.insert(Symbol::intern("let"), let_macro.to_rc_value());
101+
environment.insert(Symbol::intern("str"), str_fn.to_rc_value());
102+
environment.insert(Symbol::intern("quote"), quote_macro.to_rc_value());
103+
environment.insert(Symbol::intern("do-fn*"), do_fn.to_rc_value());
104+
environment.insert(Symbol::intern("do"), do_macro.to_rc_value());
105+
environment.insert(Symbol::intern("def"), def_macro.to_rc_value());
106+
environment.insert(Symbol::intern("fn"), fn_macro.to_rc_value());
107+
environment.insert(Symbol::intern("defmacro"), defmacro_macro.to_rc_value());
108+
environment.insert(Symbol::intern("eval"), eval_fn.to_rc_value());
109+
environment.insert(
110110
Symbol::intern("lexical-eval"),
111111
lexical_eval_fn.to_rc_value(),
112-
);
112+
);
113113

114-
environment.insert(Symbol::intern("nth"), nth_fn.to_rc_value());
115-
environment.insert(Symbol::intern("concat"), concat_fn.to_rc_value());
116-
environment.insert(
114+
environment.insert(Symbol::intern("nth"), nth_fn.to_rc_value());
115+
environment.insert(Symbol::intern("concat"), concat_fn.to_rc_value());
116+
environment.insert(
117117
Symbol::intern("print-string"),
118118
print_string_fn.to_rc_value(),
119-
);
119+
);
120+
121+
//
122+
// Read in clojure.core
123+
//
124+
let _ = repl::try_eval_file(&environment, "./src/clojure/core.clj");
120125

121-
//
122-
// Read in clojure.core
123-
//
124-
let _ = repl::try_eval_file(&environment, "./src/clojure/core.clj");
125-
126-
environment
126+
environment
127127
}
128128
}

src/ifn.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use crate::value::Value;
1515
use dyn_clone::DynClone;
1616

1717
use std::fmt::Debug;
18-
use std::hash::Hash;
1918

2019
//
2120
// Based on: clojure.lang.IFn

src/lambda.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl IFn for Fn {
2626
let argc = self.arg_syms.len();
2727

2828
let mut var_args = false;
29-
if (argc >= 2) {
29+
if argc >= 2 {
3030
if let Some(sym) = self.arg_syms.get(argc - 2) {
3131
if sym.to_string() == "&" {
3232
var_args = true;
@@ -48,7 +48,7 @@ impl IFn for Fn {
4848
let curr_sym = self.arg_syms.get(i).unwrap();
4949
// We can bind the rest of the arguments, then, to the next variable and blow this popsicle stand
5050
if curr_sym.to_string() == "&" {
51-
if (!var_args) {
51+
if !var_args {
5252
return Value::Condition(String::from("Invalid function argument '&' in non-variable-argument function definition"));
5353
}
5454
let last_sym = self.arg_syms.get(i + 1).unwrap();

src/main.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,6 @@ mod symbol;
1616
mod type_tag;
1717
mod value;
1818

19-
use environment::Environment;
20-
21-
use std::io::BufRead;
22-
use std::io::{self};
23-
use std::io::Write;
24-
use std::rc::Rc;
25-
26-
use crate::value::Value;
27-
use crate::value::{Evaluable, ToValue};
28-
use symbol::Symbol;
29-
30-
use nom::Err::Incomplete;
31-
3219
fn main() {
3320
//
3421
// Start repl

src/namespace.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
use crate::rust_core::{AddFn, StrFn};
2-
use crate::value::ToValue;
1+
use crate::symbol::Symbol;
32
use crate::value::Value;
4-
use crate::Symbol;
53
use std::cell::RefCell;
64
use std::collections::HashMap;
75
use std::rc::Rc;

src/persistent_list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::iter::FromIterator;
44
use std::rc::Rc;
55

66
use crate::value::{ToValue, Value};
7-
use std::hash::{Hash, Hasher};
7+
use std::hash::Hash;
88

99
#[derive(Debug, Clone, PartialEq, Hash)]
1010
pub enum PersistentList {

src/persistent_list_map.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
//! b => {:a 1 :b 3}
1515
1616
use crate::maps::MapEntry;
17-
use crate::symbol::Symbol;
1817
use crate::value::Value;
1918

2019
use std::collections::HashMap;
@@ -172,7 +171,9 @@ impl fmt::Display for PersistentListMap {
172171
#[cfg(test)]
173172
mod tests {
174173
use crate::persistent_list_map::*;
174+
use crate::symbol::Symbol;
175175
use crate::value::ToValue;
176+
176177
#[test]
177178
fn test_persistent_list_map() {
178179
let empty = PersistentListMap::Empty;

src/persistent_vector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::convert::From;
22
use std::fmt;
33
use std::fmt::Debug;
4-
use std::hash::{Hash, Hasher};
4+
use std::hash::Hash;
55
use std::iter::FromIterator;
66
use std::rc::Rc;
77

src/reader.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,17 @@
99
//! power, neither speed or ecosystem, it might be worth it to leave in reader macros.
1010
1111
use nom::{
12-
branch::alt,
13-
bytes::complete::{tag, take_while1},
14-
character::complete::multispace0,
15-
combinator::map_res,
16-
error::convert_error,
17-
map,
18-
sequence::{preceded, terminated},
19-
take_until, terminated, IResult,
12+
branch::alt, bytes::complete::tag, map, sequence::preceded, take_until, terminated, IResult,
2013
};
2114

2215
use crate::maps::MapEntry;
2316
use crate::persistent_list::ToPersistentList;
24-
use crate::persistent_list_map::{PersistentListMap, ToPersistentListMap};
17+
use crate::persistent_list_map::ToPersistentListMap;
2518
use crate::persistent_vector::ToPersistentVector;
2619
use crate::symbol::Symbol;
2720
use crate::value::{ToValue, Value};
28-
use std::{iter::FromIterator, rc::Rc};
21+
use std::rc::Rc;
2922

30-
use std::fs::File;
3123
//
3224
// Note; the difference between ours 'parsers'
3325
// identifier_parser
@@ -42,7 +34,7 @@ use std::fs::File;
4234
//
4335
// Is our parsers are meant to be be nom parsers, and more primitive in that
4436
// they can parse any information that we can later use to create a value::Value
45-
//
37+
//
4638
// Our 'try readers' are a bit higher level, and are specifically supposed to be returning a valid // value::Value or some sort of failure.
4739
//
4840

@@ -203,6 +195,7 @@ pub fn try_read_string(input: &str) -> IResult<&str, Value> {
203195
named!(quotation<&str, &str>, preceded!(consume_clojure_whitespaces, tag!("\"")));
204196

205197
let (rest_input, _) = quotation(input)?;
198+
206199
named!(
207200
string_parser<&str, String>,
208201
map!(
@@ -211,7 +204,7 @@ pub fn try_read_string(input: &str) -> IResult<&str, Value> {
211204
)
212205
);
213206

214-
to_value_parser(string_parser)(input)
207+
to_value_parser(string_parser)(rest_input)
215208
}
216209

217210
// @TODO Perhaps generalize this, or even generalize it as a reader macro
@@ -307,7 +300,7 @@ pub fn debug_try_read(input: &str) -> IResult<&str, Value> {
307300
}
308301

309302
/// Consumes any whitespace from input, if there is any.
310-
/// Always succeeds.
303+
/// Always succeeds.
311304
///
312305
/// A whitespace is either an ASCII whitespace or a comma.
313306
fn consume_clojure_whitespaces(input: &str) -> IResult<&str, ()> {

src/repl.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::fs::File;
2+
use std::io;
23
use std::io::BufRead;
34
use std::io::BufReader;
4-
use std::io::{self};
55
use std::io::Write;
66

77
use crate::environment::Environment;
@@ -33,18 +33,18 @@ pub fn try_eval_file(environment: &Rc<Environment>, filepath: &str) -> Result<()
3333
//print!("{} ",value.eval(Rc::clone(&environment)).to_string_explicit());
3434
value.eval(Rc::clone(&environment));
3535
remaining_input = _remaining_input;
36-
},
36+
}
3737
Err(Incomplete(Size(1))) => {
3838
break;
39-
},
39+
}
4040
err => {
4141
println!(
4242
"Error evaluating file {}; {}",
4343
filepath,
4444
Value::Condition(format!("Reader Error: {:?}", err))
4545
);
4646
input_buffer.clear();
47-
remaining_input = "";
47+
// remaining_input = "";
4848
break;
4949
}
5050
}
@@ -54,7 +54,7 @@ pub fn try_eval_file(environment: &Rc<Environment>, filepath: &str) -> Result<()
5454
Ok(())
5555
}
5656
// @TODO eventually, this will likely be implemented purely in Clojure
57-
/// Starts an entirely new session of Clojure RS
57+
/// Starts an entirely new session of Clojure RS
5858
pub fn repl() {
5959
println!("Clojure RS 0.0.1");
6060

@@ -91,6 +91,6 @@ pub fn repl() {
9191
input_buffer.clear();
9292
println!();
9393
print!("user=> ");
94-
let _ = io::stdout().flush();
94+
let _ = io::stdout().flush();
9595
}
9696
}

0 commit comments

Comments
 (0)