rustfmt 0.8.1

This commit is contained in:
Jakob Stoklund Olesen
2017-04-05 09:00:11 -07:00
parent e641c97670
commit 1984c96f7c
38 changed files with 497 additions and 334 deletions

View File

@@ -51,7 +51,11 @@ pub type CommandResult = Result<(), String>;
fn cton_util() -> CommandResult {
// Parse comand line arguments.
let args: Args = Docopt::new(USAGE)
.and_then(|d| d.help(true).version(Some(format!("Cretonne {}", VERSION))).decode())
.and_then(|d| {
d.help(true)
.version(Some(format!("Cretonne {}", VERSION)))
.decode()
})
.unwrap_or_else(|e| e.exit());
// Find the sub-command to execute.

View File

@@ -119,10 +119,11 @@ fn worker_thread(thread_num: usize,
// Tell them we're starting this job.
// The receiver should always be present for this as long as we have jobs.
replies.send(Reply::Starting {
jobid: jobid,
thread_num: thread_num,
})
replies
.send(Reply::Starting {
jobid: jobid,
thread_num: thread_num,
})
.unwrap();
let result = catch_unwind(|| runone::run(path.as_path())).unwrap_or_else(|e| {
@@ -141,10 +142,11 @@ fn worker_thread(thread_num: usize,
dbg!("FAIL: {}", msg);
}
replies.send(Reply::Done {
jobid: jobid,
result: result,
})
replies
.send(Reply::Done {
jobid: jobid,
result: result,
})
.unwrap();
}
})

View File

@@ -41,7 +41,8 @@ impl SubTest for TestLegalizer {
comp_ctx.flowgraph();
comp_ctx.legalize(isa);
comp_ctx.verify(isa).map_err(|e| pretty_verifier_error(&comp_ctx.func, e))?;
comp_ctx.verify(isa)
.map_err(|e| pretty_verifier_error(&comp_ctx.func, e))?;
let mut text = String::new();
write_function(&mut text, &comp_ctx.func, Some(isa)).map_err(|e| e.to_string())?;

View File

@@ -47,7 +47,8 @@ impl SubTest for TestRegalloc {
// TODO: Should we have an option to skip legalization?
comp_ctx.legalize(isa);
comp_ctx.regalloc(isa);
comp_ctx.verify(isa).map_err(|e| pretty_verifier_error(&comp_ctx.func, e))?;
comp_ctx.verify(isa)
.map_err(|e| pretty_verifier_error(&comp_ctx.func, e))?;
let mut text = String::new();
write_function(&mut text, &comp_ctx.func, Some(isa)).map_err(|e| e.to_string())?;

View File

@@ -104,10 +104,11 @@ impl TestRunner {
///
/// Any problems reading `file` as a test case file will be reported as a test failure.
pub fn push_test<P: Into<PathBuf>>(&mut self, file: P) {
self.tests.push(QueueEntry {
path: file.into(),
state: State::New,
});
self.tests
.push(QueueEntry {
path: file.into(),
state: State::New,
});
}
/// Begin running tests concurrently.
@@ -206,7 +207,9 @@ impl TestRunner {
}
// Check for any asynchronous replies without blocking.
while let Some(reply) = self.threads.as_mut().and_then(ConcurrentRunner::try_get) {
while let Some(reply) = self.threads
.as_mut()
.and_then(ConcurrentRunner::try_get) {
self.handle_reply(reply);
}
}
@@ -303,12 +306,12 @@ impl TestRunner {
return;
}
for t in self.tests.iter().filter(|entry| match **entry {
QueueEntry { state: State::Done(Ok(dur)), .. } => {
dur > cut
}
_ => false,
}) {
for t in self.tests
.iter()
.filter(|entry| match **entry {
QueueEntry { state: State::Done(Ok(dur)), .. } => dur > cut,
_ => false,
}) {
println!("slow: {}", t)
}

View File

@@ -120,5 +120,6 @@ fn run_one_test<'a>(tuple: (&'a SubTest, &'a Flags, Option<&'a TargetIsa>),
context.verified = true;
}
test.run(func, context).map_err(|e| format!("{}: {}", name, e))
test.run(func, context)
.map_err(|e| format!("{}: {}", name, e))
}

View File

@@ -76,11 +76,13 @@ impl<'a> filecheck::VariableMap for Context<'a> {
/// Run filecheck on `text`, using directives extracted from `context`.
pub fn run_filecheck(text: &str, context: &Context) -> Result<()> {
let checker = build_filechecker(context)?;
if checker.check(&text, context).map_err(|e| format!("filecheck: {}", e))? {
if checker.check(&text, context)
.map_err(|e| format!("filecheck: {}", e))? {
Ok(())
} else {
// Filecheck mismatch. Emit an explanation as output.
let (_, explain) = checker.explain(&text, context).map_err(|e| format!("explain: {}", e))?;
let (_, explain) = checker.explain(&text, context)
.map_err(|e| format!("explain: {}", e))?;
Err(format!("filecheck failed:\n{}{}", checker, explain))
}
}
@@ -90,10 +92,12 @@ pub fn build_filechecker(context: &Context) -> Result<Checker> {
let mut builder = CheckerBuilder::new();
// Preamble comments apply to all functions.
for comment in context.preamble_comments {
builder.directive(comment.text).map_err(|e| format!("filecheck: {}", e))?;
builder.directive(comment.text)
.map_err(|e| format!("filecheck: {}", e))?;
}
for comment in &context.details.comments {
builder.directive(comment.text).map_err(|e| format!("filecheck: {}", e))?;
builder.directive(comment.text)
.map_err(|e| format!("filecheck: {}", e))?;
}
let checker = builder.finish();
if checker.is_empty() {

View File

@@ -18,10 +18,12 @@ pub fn run(files: Vec<String>, verbose: bool) -> CommandResult {
}
let mut buffer = String::new();
io::stdin().read_to_string(&mut buffer).map_err(|e| format!("stdin: {}", e))?;
io::stdin().read_to_string(&mut buffer)
.map_err(|e| format!("stdin: {}", e))?;
if verbose {
let (success, explain) = checker.explain(&buffer, NO_VARIABLES).map_err(|e| e.to_string())?;
let (success, explain) = checker.explain(&buffer, NO_VARIABLES)
.map_err(|e| e.to_string())?;
print!("{}", explain);
if success {
println!("OK");
@@ -29,10 +31,12 @@ pub fn run(files: Vec<String>, verbose: bool) -> CommandResult {
} else {
Err("Check failed".to_string())
}
} else if checker.check(&buffer, NO_VARIABLES).map_err(|e| e.to_string())? {
} else if checker.check(&buffer, NO_VARIABLES)
.map_err(|e| e.to_string())? {
Ok(())
} else {
let (_, explain) = checker.explain(&buffer, NO_VARIABLES).map_err(|e| e.to_string())?;
let (_, explain) = checker.explain(&buffer, NO_VARIABLES)
.map_err(|e| e.to_string())?;
print!("{}", explain);
Err("Check failed".to_string())
}
@@ -41,6 +45,7 @@ pub fn run(files: Vec<String>, verbose: bool) -> CommandResult {
fn read_checkfile(filename: &str) -> Result<Checker, String> {
let buffer = read_to_string(&filename).map_err(|e| format!("{}: {}", filename, e))?;
let mut builder = CheckerBuilder::new();
builder.text(&buffer).map_err(|e| format!("{}: {}", filename, e))?;
builder.text(&buffer)
.map_err(|e| format!("{}: {}", filename, e))?;
Ok(builder.finish())
}

View File

@@ -30,7 +30,7 @@ function banner() {
# rustfmt is installed.
#
# This version should always be bumped to the newest version available.
RUSTFMT_VERSION="0.8.0"
RUSTFMT_VERSION="0.8.1"
if cargo install --list | grep -q "^rustfmt v$RUSTFMT_VERSION"; then
banner "Rust formatting"

View File

@@ -9,7 +9,10 @@ use self::cton_reader::parse_functions;
fn test_reverse_postorder_traversal(function_source: &str, ebb_order: Vec<u32>) {
let func = &parse_functions(function_source).unwrap()[0];
let cfg = ControlFlowGraph::with_function(&func);
let ebbs = ebb_order.iter().map(|n| Ebb::with_number(*n).unwrap()).collect::<Vec<Ebb>>();
let ebbs = ebb_order
.iter()
.map(|n| Ebb::with_number(*n).unwrap())
.collect::<Vec<Ebb>>();
let mut postorder_ebbs = cfg.postorder_ebbs();
let mut postorder_map = EntityMap::with_capacity(postorder_ebbs.len());