Skip to content

Commit bbc370b

Browse files
committed
cargo fmt
1 parent 2edafe7 commit bbc370b

File tree

5 files changed

+30
-29
lines changed

5 files changed

+30
-29
lines changed

nib-core/src/core.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,11 @@ impl DesugarState {
256256
}
257257
Pattern::Literal(lit) => {
258258
// TODO: Generate appropriate check for each literal type
259-
let check = app(&vec![var(&Symbol::from("_prim_eq")), expr.clone(), literal(lit)]);
259+
let check = app(&vec![
260+
var(&Symbol::from("_prim_eq")),
261+
expr.clone(),
262+
literal(lit),
263+
]);
260264
Ok(vec![PatternParts::Check(check)])
261265
}
262266
Pattern::Typed(pat, typ) => {
@@ -268,14 +272,18 @@ impl DesugarState {
268272
}
269273
}
270274
let get_type = app(&vec![var(&Symbol::from("_prim_type")), val]);
271-
let check = app(&vec![var(&Symbol::from("_prim_eq")), get_type, name_expr(typ)]);
275+
let check = app(&vec![
276+
var(&Symbol::from("_prim_eq")),
277+
get_type,
278+
name_expr(typ),
279+
]);
272280
inner.push(PatternParts::Check(check));
273281
Ok(inner)
274282
}
275-
Pattern::Var(Name::Plain(name)) => Ok(vec![PatternParts::Bind(name.clone(), expr.clone())]),
276-
Pattern::Var(_) => {
277-
self.error("Qualified name in arg pattern")
283+
Pattern::Var(Name::Plain(name)) => {
284+
Ok(vec![PatternParts::Bind(name.clone(), expr.clone())])
278285
}
286+
Pattern::Var(_) => self.error("Qualified name in arg pattern"),
279287
Pattern::Wildcard => Ok(vec![]),
280288
}
281289
}
@@ -872,8 +880,9 @@ pub fn rename(expr: &Expression, old_name: &Var, new_name: &Var) -> Expression {
872880
new_binding.body = new_body;
873881
new_defs.push(new_binding);
874882
if let Var::Named(n) = old_name {
875-
if let Some(Name::Plain(x)) = &b.name &&
876-
n == x {
883+
if let Some(Name::Plain(x)) = &b.name
884+
&& n == x
885+
{
877886
shadowed = true;
878887
}
879888
}

nib-core/src/interpreter/compile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::common::{Result, Symbol};
21
use crate::common::{Metadata, Name};
2+
use crate::common::{Result, Symbol};
33
use crate::core::Binder;
44
use crate::interpreter::heap::Value;
55
use std::collections::HashMap;

nib-core/src/parser/tests.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ fn lex_numbers() -> Result<()> {
1717
fn lex_identifier() -> Result<()> {
1818
let tokens = lex("hello_world aaa bbb ccc")?;
1919
assert_eq!(tokens.len(), 5);
20-
assert_eq!(tokens[0], TokenValue::Identifier(Symbol::from("hello_world")));
20+
assert_eq!(
21+
tokens[0],
22+
TokenValue::Identifier(Symbol::from("hello_world"))
23+
);
2124
Ok(())
2225
}
2326

nib-core/src/treewalker.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl Runtime {
4646
globals: new_ref(Table::new()),
4747
local_module: None,
4848
closures_to_check: HashMap::new(),
49-
output_core: false
49+
output_core: false,
5050
};
5151

5252
rt.register_type_tables();
@@ -91,7 +91,7 @@ impl Runtime {
9191
})
9292
}
9393

94-
pub fn set_output_core(&mut self, output:bool) {
94+
pub fn set_output_core(&mut self, output: bool) {
9595
self.output_core = output;
9696
}
9797

@@ -103,7 +103,6 @@ impl Runtime {
103103
self.add_to_table(self.globals.clone(), &sym, &value);
104104
}
105105

106-
107106
pub fn delete_global(&mut self, name: &Symbol) {
108107
self.globals.borrow_mut().table.remove(name);
109108
}
@@ -117,11 +116,7 @@ impl Runtime {
117116
}
118117

119118
pub fn get_global(&self, name: &Symbol) -> Option<Value> {
120-
self.globals
121-
.borrow()
122-
.table
123-
.get(name)
124-
.cloned()
119+
self.globals.borrow().table.get(name).cloned()
125120
}
126121

127122
pub fn add_name(&mut self, name: &Name, val: &Value) -> Result<()> {

nib-core/src/treewalker/evaluate.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ impl Runtime {
4444
for v in vals {
4545
eval_status.value_stack.push(v.clone());
4646
}
47-
eval_status
48-
.work_stack
49-
.push(EvalStep::Apply(None, size));
47+
eval_status.work_stack.push(EvalStep::Apply(None, size));
5048
self.eval(&mut eval_status, &mut env)?;
5149
Ok(eval_status.value_stack.pop().unwrap_or(Value::Nil))
5250
}
@@ -253,10 +251,7 @@ impl Runtime {
253251
Expression::Cond(_, cond) => {
254252
eval_status.work_stack.push(EvalStep::Select(
255253
Box::new(EvalStep::Expression(binding_name.clone(), cond.if_true)),
256-
Box::new(EvalStep::Expression(
257-
binding_name.clone(),
258-
cond.if_false,
259-
)),
254+
Box::new(EvalStep::Expression(binding_name.clone(), cond.if_false)),
260255
));
261256
eval_status
262257
.work_stack
@@ -295,7 +290,7 @@ impl Runtime {
295290
eval_status: &mut EvalStatus,
296291
vals: &[Value],
297292
current_env: &mut Environment,
298-
binding_name: &Option<Name>
293+
binding_name: &Option<Name>,
299294
) -> Result<()> {
300295
info!("Applying {} to {} arguments", &vals[0], &vals[1..].len());
301296
match &vals[0] {
@@ -346,10 +341,9 @@ impl Runtime {
346341
}
347342
mem::swap(&mut env, current_env);
348343
eval_status.work_stack.push(EvalStep::ReplaceEnv(env));
349-
eval_status.work_stack.push(EvalStep::Expression(
350-
binding_name.clone(),
351-
lam.body.clone(),
352-
));
344+
eval_status
345+
.work_stack
346+
.push(EvalStep::Expression(binding_name.clone(), lam.body.clone()));
353347
None
354348
}
355349
Code::ExternSimple(ext) => Some(ext(&args)?),

0 commit comments

Comments
 (0)