MAINT: Formatting cleanup.

This commit is contained in:
Jeremy Wall 2018-12-10 21:27:44 -06:00
parent 9b5b7aa793
commit 8009c6a8a5
7 changed files with 81 additions and 74 deletions

View File

@ -605,9 +605,11 @@ impl MacroDef {
stack.push(expr);
}
}
&Expression::Call(ref def) => for expr in def.arglist.iter() {
&Expression::Call(ref def) => {
for expr in def.arglist.iter() {
stack.push(expr);
},
}
}
&Expression::Simple(ref val) => {
let mut syms_set = self.validate_value_symbols(&mut stack, val);
bad_symbols.extend(syms_set.drain());

View File

@ -302,7 +302,8 @@ impl Builder {
"Error building file: {}\n{}",
self.file.to_string_lossy(),
e.as_ref()
).as_ref(),
)
.as_ref(),
);
Err(Box::new(err))
}
@ -578,12 +579,7 @@ impl Builder {
continue;
}
&Val::List(ref elems) => {
self.lookup_in_list(
&mut stack,
sl,
(&next.pos, &next.fragment),
elems
)?;
self.lookup_in_list(&mut stack, sl, (&next.pos, &next.fragment), elems)?;
continue;
}
_ => {
@ -737,7 +733,9 @@ impl Builder {
left: Rc<Val>,
right: Rc<Val>,
) -> Result<Rc<Val>, Box<Error>> {
Ok(Rc::new(Val::Boolean(left.equal(right.as_ref(), pos.clone())?)))
Ok(Rc::new(Val::Boolean(
left.equal(right.as_ref(), pos.clone())?,
)))
}
fn do_not_deep_equal(
@ -746,7 +744,9 @@ impl Builder {
left: Rc<Val>,
right: Rc<Val>,
) -> Result<Rc<Val>, Box<Error>> {
Ok(Rc::new(Val::Boolean(!left.equal(right.as_ref(), pos.clone())?)))
Ok(Rc::new(Val::Boolean(
!left.equal(right.as_ref(), pos.clone())?,
)))
}
fn do_gt(&self, pos: &Position, left: Rc<Val>, right: Rc<Val>) -> Result<Rc<Val>, Box<Error>> {
@ -981,7 +981,8 @@ impl Builder {
let first = a.0.clone();
let t = a.1.clone();
(first, t.1)
}).collect(),
})
.collect(),
)));
}
@ -1073,7 +1074,7 @@ impl Builder {
self.file.clone(),
self.assets.clone(),
self.env.clone(),
argvals
argvals,
)?;
return Ok(Rc::new(Val::Tuple(fields)));
}
@ -1184,7 +1185,7 @@ impl Builder {
self.file.clone(),
self.assets.clone(),
self.env.clone(),
argvals
argvals,
)?;
if let Some(v) = Self::find_in_fieldlist(&def.field, &fields) {
match def.typ {

View File

@ -212,7 +212,8 @@ mod exec_test {
"let script = {
command = \"/bin/echo\",
};",
).unwrap();
)
.unwrap();
let result = b.get_out_by_name("script").unwrap();
let mut expected = "#!/usr/bin/env bash\n".to_string();
expected.push_str("# Turn on unofficial Bash-Strict-Mode\n");
@ -236,7 +237,8 @@ mod exec_test {
quux = \"baz\",
},
};",
).unwrap();
)
.unwrap();
let result = b.get_out_by_name("script").unwrap();
let mut expected = "#!/usr/bin/env bash\n".to_string();
expected.push_str("# Turn on unofficial Bash-Strict-Mode\n");
@ -267,7 +269,8 @@ mod exec_test {
{flag1 = 1},
],
};",
).unwrap();
)
.unwrap();
let result = b.get_out_by_name("script").unwrap();
let mut expected = "#!/usr/bin/env bash\n".to_string();
expected.push_str("# Turn on unofficial Bash-Strict-Mode\n");

View File

@ -75,7 +75,8 @@ impl FlagConverter {
&Val::List(ref _def) => {
eprintln!("Skipping List...");
}
&Val::Tuple(ref flds) => for &(ref name, ref val) in flds.iter() {
&Val::Tuple(ref flds) => {
for &(ref name, ref val) in flds.iter() {
if let &Val::Empty = val.as_ref() {
self.write_flag_name(pfx, &name.val, w)?;
continue;
@ -93,7 +94,8 @@ impl FlagConverter {
self.write(pfx, &val, w)?;
}
}
},
}
}
&Val::Macro(ref _def) => {
// This is ignored
eprintln!("Skipping macro...");

View File

@ -40,8 +40,7 @@ impl JsonConverter {
) -> std::io::Result<serde_json::Value> {
let mut mp = serde_json::Map::new();
for &(ref k, ref v) in items.iter() {
mp.entry(k.val.clone())
.or_insert(self.convert_value(v)?);
mp.entry(k.val.clone()).or_insert(self.convert_value(v)?);
}
Ok(serde_json::Value::Object(mp))
}

View File

@ -44,8 +44,7 @@ impl TomlConverter {
fn convert_tuple(&self, items: &Vec<(ast::PositionedItem<String>, Rc<Val>)>) -> ConvertResult {
let mut mp = toml::value::Table::new();
for &(ref k, ref v) in items.iter() {
mp.entry(k.val.clone())
.or_insert(self.convert_value(v)?);
mp.entry(k.val.clone()).or_insert(self.convert_value(v)?);
}
Ok(toml::Value::Table(mp))
}

View File

@ -538,7 +538,8 @@ fn tuple_to_macro<'a>(
.map(|s| PositionedItem {
pos: s.pos().clone(),
val: s.to_string(),
}).collect();
})
.collect();
match val {
Value::Tuple(v) => Ok(Expression::Macro(MacroDef {
argdefs: arglist,