Update to latest stable rustfmt-preview.

This commit is contained in:
Dan Gohman
2018-06-07 14:17:56 -07:00
parent 00fbd6d9bf
commit 99ee96ca16
7 changed files with 109 additions and 110 deletions

View File

@@ -6,31 +6,31 @@
//! and tables, then emitting the translated code with hardcoded addresses to memory.
extern crate cretonne_codegen;
extern crate cretonne_wasm;
extern crate cretonne_native;
extern crate wasmstandalone_runtime;
extern crate wasmstandalone_execute;
extern crate cretonne_wasm;
extern crate docopt;
extern crate wasmstandalone_execute;
extern crate wasmstandalone_runtime;
#[macro_use]
extern crate serde_derive;
extern crate tempdir;
use cretonne_wasm::translate_module;
use wasmstandalone_execute::{compile_module, execute};
use wasmstandalone_runtime::{Instance, Module, ModuleEnvironment};
use std::path::PathBuf;
use cretonne_codegen::isa::TargetIsa;
use cretonne_codegen::settings;
use std::fs::File;
use std::error::Error;
use std::io;
use std::io::stdout;
use std::io::prelude::*;
use cretonne_codegen::settings::Configurable;
use cretonne_wasm::translate_module;
use docopt::Docopt;
use std::error::Error;
use std::fs::File;
use std::io;
use std::io::prelude::*;
use std::io::stdout;
use std::path::Path;
use std::path::PathBuf;
use std::process::{exit, Command};
use tempdir::TempDir;
use cretonne_codegen::settings::Configurable;
use wasmstandalone_execute::{compile_module, execute};
use wasmstandalone_runtime::{Instance, Module, ModuleEnvironment};
const USAGE: &str = "
Wasm to Cretonne IL translation utility.
@@ -99,9 +99,7 @@ fn main() {
}
fn handle_module(args: &Args, path: PathBuf, isa: &TargetIsa) -> Result<(), String> {
let mut data = read_to_end(path.clone()).map_err(|err| {
String::from(err.description())
})?;
let mut data = read_to_end(path.clone()).map_err(|err| String::from(err.description()))?;
if !data.starts_with(&[b'\0', b'a', b's', b'm']) {
let tmp_dir = TempDir::new("cretonne-wasm").unwrap();
let file_path = tmp_dir.path().join("module.wasm");
@@ -111,14 +109,14 @@ fn handle_module(args: &Args, path: PathBuf, isa: &TargetIsa) -> Result<(), Stri
.arg("-o")
.arg(file_path.to_str().unwrap())
.output()
.or_else(|e| if let io::ErrorKind::NotFound = e.kind() {
return Err(String::from("wat2wasm not found"));
} else {
return Err(String::from(e.description()));
.or_else(|e| {
if let io::ErrorKind::NotFound = e.kind() {
return Err(String::from("wat2wasm not found"));
} else {
return Err(String::from(e.description()));
}
})?;
data = read_to_end(file_path).map_err(
|err| String::from(err.description()),
)?;
data = read_to_end(file_path).map_err(|err| String::from(err.description()))?;
}
let mut module = Module::new();
let mut environ = ModuleEnvironment::new(isa.flags(), &mut module);

View File

@@ -7,27 +7,27 @@
extern crate cretonne_codegen;
extern crate cretonne_native;
extern crate cretonne_wasm;
extern crate docopt;
extern crate wasmstandalone_obj;
extern crate wasmstandalone_runtime;
extern crate docopt;
#[macro_use]
extern crate serde_derive;
extern crate faerie;
use cretonne_wasm::translate_module;
use cretonne_codegen::settings;
use cretonne_codegen::isa;
use wasmstandalone_obj::emit_module;
use std::path::PathBuf;
use std::fs::File;
use cretonne_codegen::settings;
use cretonne_wasm::translate_module;
use docopt::Docopt;
use faerie::{Artifact, Elf, Target};
use std::error::Error;
use std::fmt::format;
use std::fs::File;
use std::io;
use std::io::prelude::*;
use docopt::Docopt;
use std::path::Path;
use std::path::PathBuf;
use std::process;
use std::fmt::format;
use faerie::{Artifact, Elf, Target};
use wasmstandalone_obj::emit_module;
const USAGE: &str = "
Wasm to native object translation utility.
@@ -100,9 +100,8 @@ fn handle_module(path: PathBuf, output: &str) -> Result<(), String> {
// FIXME: We need to initialize memory in a way that supports alternate
// memory spaces, imported base addresses, and offsets.
for init in &environ.lazy.data_initializers {
obj.define("memory", Vec::from(init.data)).map_err(|err| {
format!("{}", err)
})?;
obj.define("memory", Vec::from(init.data))
.map_err(|err| format!("{}", err))?;
}
let translation = environ.finish_translation();
@@ -119,12 +118,10 @@ fn handle_module(path: PathBuf, output: &str) -> Result<(), String> {
}
// FIXME: Make the format a parameter.
let file = ::std::fs::File::create(Path::new(output)).map_err(|x| {
format(format_args!("{}", x))
})?;
obj.write::<Elf>(file).map_err(
|x| format(format_args!("{}", x)),
)?;
let file =
::std::fs::File::create(Path::new(output)).map_err(|x| format(format_args!("{}", x)))?;
obj.write::<Elf>(file)
.map_err(|x| format(format_args!("{}", x)))?;
Ok(())
}