Update to the rustfmt in rust 1.31, which is now stable.

This commit is contained in:
Dan Gohman
2018-12-06 16:15:48 -05:00
parent 323a9925e5
commit 5adab629f2
43 changed files with 181 additions and 177 deletions

View File

@@ -1,9 +1,5 @@
#![deny(trivial_numeric_casts)] #![deny(trivial_numeric_casts)]
#![warn( #![warn(unused_import_braces, unstable_features, unused_extern_crates)]
unused_import_braces,
unstable_features,
unused_extern_crates
)]
#![cfg_attr( #![cfg_attr(
feature = "cargo-clippy", feature = "cargo-clippy",
warn( warn(
@@ -163,26 +159,31 @@ fn main() {
.arg(add_time_flag()) .arg(add_time_flag())
.arg(add_input_file_arg()) .arg(add_input_file_arg())
.arg(add_debug_flag()), .arg(add_debug_flag()),
).subcommand( )
.subcommand(
SubCommand::with_name("cat") SubCommand::with_name("cat")
.about("Outputs .clif file") .about("Outputs .clif file")
.arg(add_input_file_arg()) .arg(add_input_file_arg())
.arg(add_debug_flag()), .arg(add_debug_flag()),
).subcommand( )
.subcommand(
SubCommand::with_name("print-cfg") SubCommand::with_name("print-cfg")
.about("Prints out cfg in dot format") .about("Prints out cfg in dot format")
.arg(add_input_file_arg()) .arg(add_input_file_arg())
.arg(add_debug_flag()), .arg(add_debug_flag()),
).subcommand( )
.subcommand(
add_wasm_or_compile("compile") add_wasm_or_compile("compile")
.arg( .arg(
Arg::with_name("just-decode") Arg::with_name("just-decode")
.short("t") .short("t")
.help("Just decode WebAssembly to Cranelift IR"), .help("Just decode WebAssembly to Cranelift IR"),
).arg(Arg::with_name("check-translation").short("c").help( )
.arg(Arg::with_name("check-translation").short("c").help(
"Just checks the correctness of Cranelift IR translated from WebAssembly", "Just checks the correctness of Cranelift IR translated from WebAssembly",
)), )),
).subcommand(add_wasm_or_compile("wasm")) )
.subcommand(add_wasm_or_compile("wasm"))
.subcommand( .subcommand(
SubCommand::with_name("pass") SubCommand::with_name("pass")
.about("Run specified pass(s) on an input file.") .about("Run specified pass(s) on an input file.")
@@ -204,7 +205,8 @@ fn main() {
rest_cmd.is_present("verbose"), rest_cmd.is_present("verbose"),
rest_cmd.is_present("time-passes"), rest_cmd.is_present("time-passes"),
&get_vec(rest_cmd.values_of("file")), &get_vec(rest_cmd.values_of("file")),
).map(|_time| ()) )
.map(|_time| ())
} }
("pass", Some(rest_cmd)) => { ("pass", Some(rest_cmd)) => {
handle_debug_flag(rest_cmd.is_present("debug")); handle_debug_flag(rest_cmd.is_present("debug"));
@@ -221,7 +223,8 @@ fn main() {
&get_vec(rest_cmd.values_of("pass")), &get_vec(rest_cmd.values_of("pass")),
target_val, target_val,
rest_cmd.value_of("single-file").unwrap(), rest_cmd.value_of("single-file").unwrap(),
).map(|_time| ()) )
.map(|_time| ())
} }
("print-cfg", Some(rest_cmd)) => { ("print-cfg", Some(rest_cmd)) => {
handle_debug_flag(rest_cmd.is_present("debug")); handle_debug_flag(rest_cmd.is_present("debug"));

View File

@@ -65,7 +65,8 @@ pub fn parse_sets_and_triple(
flag_set.iter().map(|x| x.as_str()), flag_set.iter().map(|x| x.as_str()),
&mut flag_builder, &mut flag_builder,
Location { line_number: 0 }, Location { line_number: 0 },
).map_err(|err| err.to_string())?; )
.map_err(|err| err.to_string())?;
let mut words = flag_triple.trim().split_whitespace(); let mut words = flag_triple.trim().split_whitespace();
// Look for `target foo`. // Look for `target foo`.

View File

@@ -16,10 +16,7 @@
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] #![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
#![warn(unused_import_braces)] #![warn(unused_import_braces)]
#![cfg_attr(feature = "std", warn(unstable_features))] #![cfg_attr(feature = "std", warn(unstable_features))]
#![cfg_attr( #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
feature = "clippy",
plugin(clippy(conf_file = "../../clippy.toml"))
)]
#![cfg_attr( #![cfg_attr(
feature = "cargo-clippy", feature = "cargo-clippy",
allow(new_without_default, new_without_default_derive) allow(new_without_default, new_without_default_derive)

View File

@@ -153,16 +153,15 @@ impl TargetIsaBuilder {
// If the intersection is the second one, then it must be a subclass. // If the intersection is the second one, then it must be a subclass.
if intersect == rc2_mask { if intersect == rc2_mask {
assert!( assert!(self
self.isa .isa
.reg_classes .reg_classes
.get(*i1) .get(*i1)
.unwrap() .unwrap()
.subclasses .subclasses
.iter() .iter()
.find(|x| **x == *i2) .find(|x| **x == *i2)
.is_some() .is_some());
);
} }
} }
} }
@@ -184,7 +183,8 @@ impl TargetIsaBuilder {
.values() .values()
.filter(|x| { .filter(|x| {
x.toprc == x.index && self.isa.reg_banks.get(x.bank).unwrap().pressure_tracking x.toprc == x.index && self.isa.reg_banks.get(x.bank).unwrap().pressure_tracking
}).count(); })
.count();
assert!(num_toplevel <= 4, "Too many top-level register classes"); assert!(num_toplevel <= 4, "Too many top-level register classes");
self.isa self.isa

View File

@@ -128,7 +128,8 @@ impl SettingGroup {
} else { } else {
false false
} }
}).count() as u8 })
.count() as u8
} }
pub fn byte_size(&self) -> u8 { pub fn byte_size(&self) -> u8 {

View File

@@ -190,7 +190,8 @@ impl LaneType {
/// Find the unique number associated with this lane type. /// Find the unique number associated with this lane type.
pub fn number(self) -> u8 { pub fn number(self) -> u8 {
LANE_BASE + match self { LANE_BASE
+ match self {
LaneType::BoolType(base_types::Bool::B1) => 0, LaneType::BoolType(base_types::Bool::B1) => 0,
LaneType::BoolType(base_types::Bool::B8) => 1, LaneType::BoolType(base_types::Bool::B8) => 1,
LaneType::BoolType(base_types::Bool::B16) => 2, LaneType::BoolType(base_types::Bool::B16) => 2,

View File

@@ -114,7 +114,8 @@ impl Formatter {
} else { } else {
format!("/// {}", l) format!("/// {}", l)
} }
}).for_each(|s| self.line(s.as_str())); })
.for_each(|s| self.line(s.as_str()));
} }
/// Add a match expression. /// Add a match expression.
@@ -131,7 +132,8 @@ impl Formatter {
} else { } else {
name.clone() name.clone()
} }
}).collect(); })
.collect();
let lhs = conditions.join(" | "); let lhs = conditions.join(" | ");
fmt.line(&format!("{} => {{", lhs)); fmt.line(&format!("{} => {{", lhs));
fmt.indent(|fmt| { fmt.indent(|fmt| {

View File

@@ -186,7 +186,8 @@ fn relax_branch(
debug!(" trying [{}]: OK", encinfo.display(enc)); debug!(" trying [{}]: OK", encinfo.display(enc));
true true
} }
}) { })
{
cur.func.encodings[inst] = enc; cur.func.encodings[inst] = enc;
return encinfo.byte_size(enc, inst, &divert, &cur.func); return encinfo.byte_size(enc, inst, &divert, &cur.func);
} }

View File

@@ -89,7 +89,8 @@ impl RegBank {
None None
} }
} }
}.and_then(|offset| { }
.and_then(|offset| {
if offset < self.units { if offset < self.units {
Some(offset + self.first_unit) Some(offset + self.first_unit)
} else { } else {

View File

@@ -98,7 +98,8 @@ impl ArgAssigner for Args {
RU::r14 RU::r14
} else { } else {
RU::rsi RU::rsi
} as RegUnit).into() } as RegUnit)
.into()
} }
// This is SpiderMonkey's `WasmTableCallSigReg`. // This is SpiderMonkey's `WasmTableCallSigReg`.
ArgumentPurpose::SignatureId => return ArgumentLoc::Reg(RU::r10 as RegUnit).into(), ArgumentPurpose::SignatureId => return ArgumentLoc::Reg(RU::r10 as RegUnit).into(),

View File

@@ -575,7 +575,8 @@ pub fn handle_return_abi(inst: Inst, func: &mut Function, cfg: &ControlFlowGraph
rt.purpose == ArgumentPurpose::Link rt.purpose == ArgumentPurpose::Link
|| rt.purpose == ArgumentPurpose::StructReturn || rt.purpose == ArgumentPurpose::StructReturn
|| rt.purpose == ArgumentPurpose::VMContext || rt.purpose == ArgumentPurpose::VMContext
}).count(); })
.count();
let abi_args = func.signature.returns.len() - special_args; let abi_args = func.signature.returns.len() - special_args;
let pos = &mut FuncCursor::new(func).at_inst(inst); let pos = &mut FuncCursor::new(func).at_inst(inst);
@@ -694,7 +695,8 @@ fn spill_call_arguments(pos: &mut FuncCursor) -> bool {
} }
_ => None, _ => None,
} }
}).collect::<Vec<_>>() })
.collect::<Vec<_>>()
}; };
if arglist.is_empty() { if arglist.is_empty() {

View File

@@ -165,7 +165,8 @@ fn split_any(
.get_mut( .get_mut(
num_fixed_args + repair.hi_num, num_fixed_args + repair.hi_num,
&mut pos.func.dfg.value_lists, &mut pos.func.dfg.value_lists,
).unwrap() = hi; )
.unwrap() = hi;
} else { } else {
// We need to append one or more arguments. If we're adding more than one argument, // We need to append one or more arguments. If we're adding more than one argument,
// there must be pending repairs on the stack that will fill in the correct values // there must be pending repairs on the stack that will fill in the correct values

View File

@@ -3,10 +3,7 @@
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] #![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
#![warn(unused_import_braces)] #![warn(unused_import_braces)]
#![cfg_attr(feature = "std", deny(unstable_features))] #![cfg_attr(feature = "std", deny(unstable_features))]
#![cfg_attr( #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
feature = "clippy",
plugin(clippy(conf_file = "../../clippy.toml"))
)]
#![cfg_attr(feature="cargo-clippy", allow( #![cfg_attr(feature="cargo-clippy", allow(
// Produces only a false positive: // Produces only a false positive:
while_let_loop, while_let_loop,

View File

@@ -30,14 +30,16 @@ pub fn pretty_verifier_error<'a>(
&mut w, &mut w,
func, func,
isa, isa,
).unwrap(); )
.unwrap();
writeln!( writeln!(
w, w,
"\n; {} verifier error{} detected (see above). Compilation aborted.", "\n; {} verifier error{} detected (see above). Compilation aborted.",
num_errors, num_errors,
if num_errors == 1 { "" } else { "s" } if num_errors == 1 { "" } else { "s" }
).unwrap(); )
.unwrap();
w w
} }

View File

@@ -914,10 +914,8 @@ impl<'a> Context<'a> {
Table(jt, ebb) => { Table(jt, ebb) => {
let lr = &self.liveness[value]; let lr = &self.liveness[value];
!lr.is_local() !lr.is_local()
&& (ebb.map_or(false, |ebb| lr.is_livein(ebb, ctx)) || self && (ebb.map_or(false, |ebb| lr.is_livein(ebb, ctx))
.cur || self.cur.func.jump_tables[jt]
.func
.jump_tables[jt]
.iter() .iter()
.any(|ebb| lr.is_livein(*ebb, ctx))) .any(|ebb| lr.is_livein(*ebb, ctx)))
} }

View File

@@ -116,7 +116,8 @@ impl Context {
&self.liveness, &self.liveness,
&self.virtregs, &self.virtregs,
&mut errors, &mut errors,
).is_ok(); )
.is_ok();
if !ok { if !ok {
return Err(errors.into()); return Err(errors.into());
@@ -144,7 +145,8 @@ impl Context {
&self.liveness, &self.liveness,
&self.virtregs, &self.virtregs,
&mut errors, &mut errors,
).is_ok(); )
.is_ok();
if !ok { if !ok {
return Err(errors.into()); return Err(errors.into());
@@ -171,7 +173,8 @@ impl Context {
&self.liveness, &self.liveness,
&self.virtregs, &self.virtregs,
&mut errors, &mut errors,
).is_ok(); )
.is_ok();
if !ok { if !ok {
return Err(errors.into()); return Err(errors.into());
@@ -193,7 +196,8 @@ impl Context {
&self.liveness, &self.liveness,
&self.virtregs, &self.virtregs,
&mut errors, &mut errors,
).is_ok(); )
.is_ok();
if !ok { if !ok {
return Err(errors.into()); return Err(errors.into());

View File

@@ -220,7 +220,8 @@ fn get_or_create<'a>(
func.dfg func.dfg
.call_signature(inst) .call_signature(inst)
.map(|sig| Affinity::abi(&func.dfg.signatures[sig].returns[rnum], isa)) .map(|sig| Affinity::abi(&func.dfg.signatures[sig].returns[rnum], isa))
}).unwrap_or_default(); })
.unwrap_or_default();
} }
ValueDef::Param(ebb, num) => { ValueDef::Param(ebb, num) => {
def = ebb.into(); def = ebb.into();

View File

@@ -207,7 +207,8 @@ impl<'a> fmt::Display for DisplayRegisterSet<'a> {
.unwrap_or_else(|| char::from_digit( .unwrap_or_else(|| char::from_digit(
u32::from(offset % 10), u32::from(offset % 10),
10 10
).unwrap()) )
.unwrap())
)?; )?;
} }
} }

View File

@@ -504,7 +504,8 @@ impl<'a> Context<'a> {
} }
} }
None None
}).min_by(|&a, &b| { })
.min_by(|&a, &b| {
// Find the minimum candidate according to the RPO of their defs. // Find the minimum candidate according to the RPO of their defs.
self.domtree.rpo_cmp( self.domtree.rpo_cmp(
self.cur.func.dfg.value_def(a), self.cur.func.dfg.value_def(a),

View File

@@ -37,7 +37,7 @@ macro_rules! define_passes {
} }
// Pass definitions. // Pass definitions.
define_passes!{ define_passes! {
Pass, NUM_PASSES, DESCRIPTIONS; Pass, NUM_PASSES, DESCRIPTIONS;
process_file: "Processing test file", process_file: "Processing test file",
@@ -176,7 +176,7 @@ mod details {
} }
/// Information about passes in a single thread. /// Information about passes in a single thread.
thread_local!{ thread_local! {
static CURRENT_PASS: Cell<Pass> = Cell::new(Pass::None); static CURRENT_PASS: Cell<Pass> = Cell::new(Pass::None);
static PASS_TIME: RefCell<PassTimes> = RefCell::new(Default::default()); static PASS_TIME: RefCell<PassTimes> = RefCell::new(Default::default());
} }

View File

@@ -887,11 +887,11 @@ impl<'a> Verifier<'a> {
); );
} }
// The defining EBB dominates the instruction using this value. // The defining EBB dominates the instruction using this value.
if is_reachable && !self.expected_domtree.dominates( if is_reachable
ebb, && !self
loc_inst, .expected_domtree
&self.func.layout, .dominates(ebb, loc_inst, &self.func.layout)
) { {
return fatal!( return fatal!(
errors, errors,
loc_inst, loc_inst,
@@ -1559,7 +1559,8 @@ impl<'a> Verifier<'a> {
&self.func, &self.func,
&self.func.dfg[inst], &self.func.dfg[inst],
self.func.dfg.ctrl_typevar(inst), self.func.dfg.ctrl_typevar(inst),
).peekable(); )
.peekable();
if encodings.peek().is_none() { if encodings.peek().is_none() {
return nonfatal!( return nonfatal!(

View File

@@ -32,10 +32,7 @@
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] #![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
#![warn(unused_import_braces)] #![warn(unused_import_braces)]
#![cfg_attr(feature = "std", deny(unstable_features))] #![cfg_attr(feature = "std", deny(unstable_features))]
#![cfg_attr( #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
feature = "clippy",
plugin(clippy(conf_file = "../../clippy.toml"))
)]
#![cfg_attr( #![cfg_attr(
feature = "cargo-clippy", feature = "cargo-clippy",
allow(new_without_default, new_without_default_derive) allow(new_without_default, new_without_default_derive)

View File

@@ -231,7 +231,8 @@ impl Backend for FaerieBackend {
from: name, from: name,
to, to,
at: u64::from(offset), at: u64::from(offset),
}).map_err(|e| ModuleError::Backend(e.to_string()))?; })
.map_err(|e| ModuleError::Backend(e.to_string()))?;
} }
for &(offset, id, addend) in data_relocs { for &(offset, id, addend) in data_relocs {
debug_assert_eq!( debug_assert_eq!(
@@ -244,7 +245,8 @@ impl Backend for FaerieBackend {
from: name, from: name,
to, to,
at: u64::from(offset), at: u64::from(offset),
}).map_err(|e| ModuleError::Backend(e.to_string()))?; })
.map_err(|e| ModuleError::Backend(e.to_string()))?;
} }
self.artifact self.artifact
@@ -410,7 +412,8 @@ impl<'a> RelocSink for FaerieRelocSink<'a> {
reloc: raw_reloc, reloc: raw_reloc,
addend: addend_i32, addend: addend_i32,
}, },
).expect("faerie relocation error"); )
.expect("faerie relocation error");
} }
fn reloc_jt(&mut self, _offset: CodeOffset, _reloc: Reloc, _jt: ir::JumpTable) { fn reloc_jt(&mut self, _offset: CodeOffset, _reloc: Reloc, _jt: ir::JumpTable) {

View File

@@ -9,10 +9,7 @@
unstable_features unstable_features
)] )]
#![warn(unused_import_braces)] #![warn(unused_import_braces)]
#![cfg_attr( #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
feature = "clippy",
plugin(clippy(conf_file = "../../clippy.toml"))
)]
#![cfg_attr( #![cfg_attr(
feature = "cargo-clippy", feature = "cargo-clippy",
allow(new_without_default, new_without_default_derive) allow(new_without_default, new_without_default_derive)

View File

@@ -106,7 +106,8 @@ fn heartbeat_thread(replies: Sender<Reply>) -> thread::JoinHandle<()> {
while replies.send(Reply::Tick).is_ok() { while replies.send(Reply::Tick).is_ok() {
thread::sleep(Duration::from_secs(1)); thread::sleep(Duration::from_secs(1));
} }
}).unwrap() })
.unwrap()
} }
/// Spawn a worker thread running tests. /// Spawn a worker thread running tests.
@@ -153,5 +154,6 @@ fn worker_thread(
// Timing is accumulated independently per thread. // Timing is accumulated independently per thread.
// Timings from this worker thread will be aggregated by `ConcurrentRunner::join()`. // Timings from this worker thread will be aggregated by `ConcurrentRunner::join()`.
timing::take_current() timing::take_current()
}).unwrap() })
.unwrap()
} }

View File

@@ -317,7 +317,8 @@ impl TestRunner {
.. ..
} => Some(dur), } => Some(dur),
_ => None, _ => None,
}).collect::<Vec<_>>(); })
.collect::<Vec<_>>();
// Get me some real data, kid. // Get me some real data, kid.
let len = times.len(); let len = times.len();

View File

@@ -514,7 +514,9 @@ impl<'a> FunctionBuilder<'a> {
None => false, None => false,
Some(entry) => self.position.ebb.unwrap() == entry, Some(entry) => self.position.ebb.unwrap() == entry,
}; };
!is_entry && self.func_ctx.ssa.is_sealed(self.position.ebb.unwrap()) && !self !is_entry
&& self.func_ctx.ssa.is_sealed(self.position.ebb.unwrap())
&& !self
.func_ctx .func_ctx
.ssa .ssa
.has_any_predecessors(self.position.ebb.unwrap()) .has_any_predecessors(self.position.ebb.unwrap())
@@ -769,7 +771,8 @@ impl<'a> FunctionBuilder<'a> {
self.ins().load(config.pointer_type(), flags, src, offset), self.ins().load(config.pointer_type(), flags, src, offset),
offset, offset,
) )
}).collect(); })
.collect();
for (value, offset) in registers { for (value, offset) in registers {
self.ins().store(flags, value, dest, offset); self.ins().store(flags, value, dest, offset);

View File

@@ -3,10 +3,7 @@
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] #![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
#![warn(unused_import_braces)] #![warn(unused_import_braces)]
#![cfg_attr(feature = "std", deny(unstable_features))] #![cfg_attr(feature = "std", deny(unstable_features))]
#![cfg_attr( #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
feature = "clippy",
plugin(clippy(conf_file = "../../clippy.toml"))
)]
#![cfg_attr( #![cfg_attr(
feature = "cargo-clippy", feature = "cargo-clippy",
allow(new_without_default, new_without_default_derive) allow(new_without_default, new_without_default_derive)

View File

@@ -130,19 +130,14 @@ pub enum ModuleError {
/// different signature than declared previously /// different signature than declared previously
#[fail( #[fail(
display = "Function {} signature {:?} is incompatible with previous declaration {:?}", display = "Function {} signature {:?} is incompatible with previous declaration {:?}",
_0, _0, _2, _1
_2,
_1
)] )]
IncompatibleSignature(String, ir::Signature, ir::Signature), IncompatibleSignature(String, ir::Signature, ir::Signature),
/// Indicates an identifier was defined more than once /// Indicates an identifier was defined more than once
#[fail(display = "Duplicate definition of identifier: {}", _0)] #[fail(display = "Duplicate definition of identifier: {}", _0)]
DuplicateDefinition(String), DuplicateDefinition(String),
/// Indicates an identifier was defined, but was declared as an import /// Indicates an identifier was defined, but was declared as an import
#[fail( #[fail(display = "Invalid to define identifier declared as an import: {}", _0)]
display = "Invalid to define identifier declared as an import: {}",
_0
)]
InvalidImportDefinition(String), InvalidImportDefinition(String),
/// Wraps a `cranelift-codegen` error /// Wraps a `cranelift-codegen` error
#[fail(display = "Compilation error: {}", _0)] #[fail(display = "Compilation error: {}", _0)]

View File

@@ -8,10 +8,7 @@
unstable_features unstable_features
)] )]
#![warn(unused_import_braces)] #![warn(unused_import_braces)]
#![cfg_attr( #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
feature = "clippy",
plugin(clippy(conf_file = "../../clippy.toml"))
)]
#![cfg_attr( #![cfg_attr(
feature = "cargo-clippy", feature = "cargo-clippy",
allow(new_without_default, new_without_default_derive) allow(new_without_default, new_without_default_derive)

View File

@@ -1,12 +1,9 @@
//! Performes early-stage optimizations on Cranelift IR. //! Performes early-stage optimizations on Cranelift IR.
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates,)] #![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
#![warn(unused_import_braces)] #![warn(unused_import_braces)]
#![cfg_attr(feature = "std", deny(unstable_features))] #![cfg_attr(feature = "std", deny(unstable_features))]
#![cfg_attr( #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
feature = "clippy",
plugin(clippy(conf_file = "../../clippy.toml"))
)]
#![cfg_attr( #![cfg_attr(
feature = "cargo-clippy", feature = "cargo-clippy",
allow(new_without_default, new_without_default_derive) allow(new_without_default, new_without_default_derive)

View File

@@ -322,7 +322,8 @@ impl<'a> Lexer<'a> {
.and_then(|(prefix, number)| { .and_then(|(prefix, number)| {
Self::numbered_entity(prefix, number) Self::numbered_entity(prefix, number)
.or_else(|| Self::value_type(text, prefix, number)) .or_else(|| Self::value_type(text, prefix, number))
}).unwrap_or_else(|| match text { })
.unwrap_or_else(|| match text {
"iflags" => Token::Type(types::IFLAGS), "iflags" => Token::Type(types::IFLAGS),
"fflags" => Token::Type(types::FFLAGS), "fflags" => Token::Type(types::FFLAGS),
_ => Token::Identifier(text), _ => Token::Identifier(text),

View File

@@ -10,10 +10,7 @@
unstable_features unstable_features
)] )]
#![warn(unused_import_braces)] #![warn(unused_import_braces)]
#![cfg_attr( #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
feature = "clippy",
plugin(clippy(conf_file = "../../clippy.toml"))
)]
#![cfg_attr( #![cfg_attr(
feature = "cargo-clippy", feature = "cargo-clippy",
allow(new_without_default, new_without_default_derive) allow(new_without_default, new_without_default_derive)

View File

@@ -2587,7 +2587,8 @@ mod tests {
v3 -> v4 v3 -> v4
v1 = iadd_imm v3, 17 v1 = iadd_imm v3, 17
}", }",
).parse_function(None) )
.parse_function(None)
.unwrap(); .unwrap();
assert_eq!(func.name.to_string(), "%qux"); assert_eq!(func.name.to_string(), "%qux");
let v4 = details.map.lookup_str("v4").unwrap(); let v4 = details.map.lookup_str("v4").unwrap();
@@ -2663,7 +2664,8 @@ mod tests {
ss3 = incoming_arg 13 ss3 = incoming_arg 13
ss1 = spill_slot 1 ss1 = spill_slot 1
}", }",
).parse_function(None) )
.parse_function(None)
.unwrap(); .unwrap();
assert_eq!(func.name.to_string(), "%foo"); assert_eq!(func.name.to_string(), "%foo");
let mut iter = func.stack_slots.keys(); let mut iter = func.stack_slots.keys();
@@ -2686,7 +2688,8 @@ mod tests {
ss1 = spill_slot 13 ss1 = spill_slot 13
ss1 = spill_slot 1 ss1 = spill_slot 1
}", }",
).parse_function(None) )
.parse_function(None)
.unwrap_err() .unwrap_err()
.to_string(), .to_string(),
"3: duplicate entity: ss1" "3: duplicate entity: ss1"
@@ -2700,7 +2703,8 @@ mod tests {
ebb0: ebb0:
ebb4(v3: i32): ebb4(v3: i32):
}", }",
).parse_function(None) )
.parse_function(None)
.unwrap(); .unwrap();
assert_eq!(func.name.to_string(), "%ebbs"); assert_eq!(func.name.to_string(), "%ebbs");
@@ -2722,7 +2726,8 @@ mod tests {
ebb0: ebb0:
ebb0: ebb0:
return 2", return 2",
).parse_function(None) )
.parse_function(None)
.unwrap_err(); .unwrap_err();
assert_eq!(location.line_number, 3); assert_eq!(location.line_number, 3);
@@ -2735,7 +2740,8 @@ mod tests {
"function %ebbs() system_v { "function %ebbs() system_v {
jt0 = jump_table [] jt0 = jump_table []
jt0 = jump_table []", jt0 = jump_table []",
).parse_function(None) )
.parse_function(None)
.unwrap_err(); .unwrap_err();
assert_eq!(location.line_number, 3); assert_eq!(location.line_number, 3);
@@ -2748,7 +2754,8 @@ mod tests {
"function %ebbs() system_v { "function %ebbs() system_v {
ss0 = explicit_slot 8 ss0 = explicit_slot 8
ss0 = explicit_slot 8", ss0 = explicit_slot 8",
).parse_function(None) )
.parse_function(None)
.unwrap_err(); .unwrap_err();
assert_eq!(location.line_number, 3); assert_eq!(location.line_number, 3);
@@ -2761,7 +2768,8 @@ mod tests {
"function %ebbs() system_v { "function %ebbs() system_v {
gv0 = vmctx gv0 = vmctx
gv0 = vmctx", gv0 = vmctx",
).parse_function(None) )
.parse_function(None)
.unwrap_err(); .unwrap_err();
assert_eq!(location.line_number, 3); assert_eq!(location.line_number, 3);
@@ -2774,7 +2782,8 @@ mod tests {
"function %ebbs() system_v { "function %ebbs() system_v {
heap0 = static gv0, min 0x1000, bound 0x10_0000, guard 0x1000 heap0 = static gv0, min 0x1000, bound 0x10_0000, guard 0x1000
heap0 = static gv0, min 0x1000, bound 0x10_0000, guard 0x1000", heap0 = static gv0, min 0x1000, bound 0x10_0000, guard 0x1000",
).parse_function(None) )
.parse_function(None)
.unwrap_err(); .unwrap_err();
assert_eq!(location.line_number, 3); assert_eq!(location.line_number, 3);
@@ -2787,7 +2796,8 @@ mod tests {
"function %ebbs() system_v { "function %ebbs() system_v {
sig0 = () sig0 = ()
sig0 = ()", sig0 = ()",
).parse_function(None) )
.parse_function(None)
.unwrap_err(); .unwrap_err();
assert_eq!(location.line_number, 3); assert_eq!(location.line_number, 3);
@@ -2801,7 +2811,8 @@ mod tests {
sig0 = () sig0 = ()
fn0 = %foo sig0 fn0 = %foo sig0
fn0 = %foo sig0", fn0 = %foo sig0",
).parse_function(None) )
.parse_function(None)
.unwrap_err(); .unwrap_err();
assert_eq!(location.line_number, 4); assert_eq!(location.line_number, 4);
@@ -2821,7 +2832,8 @@ mod tests {
trap user42; Instruction trap user42; Instruction
} ; Trailing. } ; Trailing.
; More trailing.", ; More trailing.",
).parse_function(None) )
.parse_function(None)
.unwrap(); .unwrap();
assert_eq!(func.name.to_string(), "%comment"); assert_eq!(func.name.to_string(), "%comment");
assert_eq!(comments.len(), 8); // no 'before' comment. assert_eq!(comments.len(), 8); // no 'before' comment.
@@ -2858,7 +2870,8 @@ mod tests {
function %comment() system_v {}", function %comment() system_v {}",
None, None,
None, None,
).unwrap(); )
.unwrap();
assert_eq!(tf.commands.len(), 2); assert_eq!(tf.commands.len(), 2);
assert_eq!(tf.commands[0].command, "cfg"); assert_eq!(tf.commands[0].command, "cfg");
assert_eq!(tf.commands[1].command, "verify"); assert_eq!(tf.commands[1].command, "verify");
@@ -2879,26 +2892,25 @@ mod tests {
#[test] #[test]
#[cfg(build_riscv)] #[cfg(build_riscv)]
fn isa_spec() { fn isa_spec() {
assert!( assert!(parse_test(
parse_test(
"target "target
function %foo() system_v {}", function %foo() system_v {}",
).is_err() )
); .is_err());
assert!( assert!(parse_test(
parse_test(
"target riscv32 "target riscv32
set enable_float=false set enable_float=false
function %foo() system_v {}", function %foo() system_v {}",
).is_err() )
); .is_err());
match parse_test( match parse_test(
"set enable_float=false "set enable_float=false
isa riscv isa riscv
function %foo() system_v {}", function %foo() system_v {}",
).unwrap() )
.unwrap()
.isa_spec .isa_spec
{ {
IsaSpec::None(_) => panic!("Expected some ISA"), IsaSpec::None(_) => panic!("Expected some ISA"),
@@ -2917,7 +2929,8 @@ mod tests {
ebb0: ebb0:
trap int_divz trap int_divz
}", }",
).parse_function(None) )
.parse_function(None)
.unwrap() .unwrap()
.0; .0;
assert_eq!(func.name.to_string(), "u1:2"); assert_eq!(func.name.to_string(), "u1:2");

View File

@@ -224,7 +224,8 @@ mod tests {
}", }",
None, None,
None, None,
).unwrap(); )
.unwrap();
let map = &tf.functions[0].1.map; let map = &tf.functions[0].1.map;
assert_eq!(map.lookup_str("v0"), None); assert_eq!(map.lookup_str("v0"), None);

View File

@@ -7,10 +7,7 @@
unstable_features unstable_features
)] )]
#![warn(unused_import_braces)] #![warn(unused_import_braces)]
#![cfg_attr( #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
feature = "clippy",
plugin(clippy(conf_file = "../../clippy.toml"))
)]
#![cfg_attr( #![cfg_attr(
feature = "cargo-clippy", feature = "cargo-clippy",
allow(new_without_default, new_without_default_derive) allow(new_without_default, new_without_default_derive)
@@ -83,7 +80,8 @@ fn main() {
.value_name("FILE") .value_name("FILE")
.help("Input file for serialization"), .help("Input file for serialization"),
), ),
).subcommand( )
.subcommand(
SubCommand::with_name("deserialize") SubCommand::with_name("deserialize")
.about("Deserializes Cranelift IR into JSON.") .about("Deserializes Cranelift IR into JSON.")
.arg( .arg(
@@ -92,7 +90,8 @@ fn main() {
.value_name("FILE") .value_name("FILE")
.help("Input file for deserialization"), .help("Input file for deserialization"),
), ),
).get_matches(); )
.get_matches();
let res_serde = match matches.subcommand() { let res_serde = match matches.subcommand() {
("serialize", Some(m)) => { ("serialize", Some(m)) => {

View File

@@ -7,10 +7,7 @@
unstable_features unstable_features
)] )]
#![warn(unused_import_braces)] #![warn(unused_import_braces)]
#![cfg_attr( #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
feature = "clippy",
plugin(clippy(conf_file = "../../clippy.toml"))
)]
#![cfg_attr( #![cfg_attr(
feature = "cargo-clippy", feature = "cargo-clippy",
allow(new_without_default, new_without_default_derive) allow(new_without_default, new_without_default_derive)

View File

@@ -7,10 +7,7 @@
unstable_features unstable_features
)] )]
#![warn(unused_import_braces)] #![warn(unused_import_braces)]
#![cfg_attr( #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
feature = "clippy",
plugin(clippy(conf_file = "../../clippy.toml"))
)]
#![cfg_attr( #![cfg_attr(
feature = "cargo-clippy", feature = "cargo-clippy",
allow(new_without_default, new_without_default_derive) allow(new_without_default, new_without_default_derive)

View File

@@ -35,11 +35,7 @@ pub enum WasmError {
/// ///
/// This error code is used by a WebAssembly translator when it encounters invalid WebAssembly /// This error code is used by a WebAssembly translator when it encounters invalid WebAssembly
/// code. This should never happen for validated WebAssembly code. /// code. This should never happen for validated WebAssembly code.
#[fail( #[fail(display = "Invalid input WebAssembly code at offset {}: {}", _1, _0)]
display = "Invalid input WebAssembly code at offset {}: {}",
_1,
_0
)]
InvalidWebAssembly { InvalidWebAssembly {
/// A string describing the validation error. /// A string describing the validation error.
message: &'static str, message: &'static str,

View File

@@ -12,10 +12,7 @@
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] #![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
#![warn(unused_import_braces)] #![warn(unused_import_braces)]
#![cfg_attr(feature = "std", deny(unstable_features))] #![cfg_attr(feature = "std", deny(unstable_features))]
#![cfg_attr( #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
feature = "clippy",
plugin(clippy(conf_file = "../../clippy.toml"))
)]
#![cfg_attr( #![cfg_attr(
feature = "cargo-clippy", feature = "cargo-clippy",
allow(new_without_default, new_without_default_derive) allow(new_without_default, new_without_default_derive)

View File

@@ -30,7 +30,8 @@ fn testsuite() {
} }
} }
false false
}).collect(); })
.collect();
paths.sort_by_key(|dir| dir.path()); paths.sort_by_key(|dir| dir.path());
let flags = Flags::new(settings::builder()); let flags = Flags::new(settings::builder());
for path in paths { for path in paths {