Update to rustfmt-preview (#348)

* Update to rustfmt-preview.

* Run "cargo fmt --all" with rustfmt 0.4.1.

rustfmt 0.4.1 is the latest release of rustfmt-preview available on the
stable channel.

* Fix a long line that rustfmt 0.4.1 can't handle.

* Remove unneeded commas left behind by rustfmt.
This commit is contained in:
Dan Gohman
2018-05-25 11:38:38 -07:00
committed by GitHub
parent 99f6055c55
commit 6b88cd44a8
137 changed files with 1914 additions and 2380 deletions

View File

@@ -18,12 +18,8 @@ pub fn run(files: &[String]) -> CommandResult {
}
fn cat_one(filename: &str) -> CommandResult {
let buffer = read_to_string(&filename).map_err(
|e| format!("{}: {}", filename, e),
)?;
let items = parse_functions(&buffer).map_err(
|e| format!("{}: {}", filename, e),
)?;
let buffer = read_to_string(&filename).map_err(|e| format!("{}: {}", filename, e))?;
let items = parse_functions(&buffer).map_err(|e| format!("{}: {}", filename, e))?;
for (idx, func) in items.into_iter().enumerate() {
if idx != 0 {

View File

@@ -1,10 +1,10 @@
//! CLI tool to read Cretonne IR files and compile them into native code.
use capstone::prelude::*;
use cretonne_codegen::Context;
use cretonne_codegen::isa::TargetIsa;
use cretonne_codegen::print_errors::pretty_error;
use cretonne_codegen::settings::FlagsOrIsa;
use cretonne_codegen::Context;
use cretonne_codegen::{binemit, ir};
use cretonne_reader::parse_test;
use std::path::Path;
@@ -80,9 +80,7 @@ fn handle_module(
name: &str,
fisa: FlagsOrIsa,
) -> Result<(), String> {
let buffer = read_to_string(&path).map_err(
|e| format!("{}: {}", name, e),
)?;
let buffer = read_to_string(&path).map_err(|e| format!("{}: {}", name, e))?;
let test_file = parse_test(&buffer).map_err(|e| format!("{}: {}", name, e))?;
// If we have an isa from the command-line, use that. Otherwise if the
@@ -154,12 +152,10 @@ fn get_disassembler(isa: &TargetIsa) -> Result<Capstone, String> {
}
}
"arm32" => Capstone::new().arm().mode(arch::arm::ArchMode::Arm).build(),
"arm64" => {
Capstone::new()
.arm64()
.mode(arch::arm64::ArchMode::Arm)
.build()
}
"arm64" => Capstone::new()
.arm64()
.mode(arch::arm64::ArchMode::Arm)
.build(),
_ => return Err(String::from("Unknown ISA")),
};

View File

@@ -1,14 +1,8 @@
#![deny(trivial_numeric_casts)]
#![warn(unused_import_braces, unstable_features, unused_extern_crates)]
#![cfg_attr(feature="cargo-clippy", warn(
float_arithmetic,
mut_mut,
nonminimal_bool,
option_map_unwrap_or,
option_map_unwrap_or_else,
unicode_not_nfc,
use_self,
))]
#![cfg_attr(feature = "cargo-clippy",
warn(float_arithmetic, mut_mut, nonminimal_bool, option_map_unwrap_or,
option_map_unwrap_or_else, unicode_not_nfc, use_self))]
#[macro_use]
extern crate cfg_if;
@@ -134,9 +128,7 @@ fn cton_util() -> CommandResult {
);
#[cfg(not(feature = "wasm"))]
let result = Err(
"Error: cton-util was compiled without wasm support.".to_owned(),
);
let result = Err("Error: cton-util was compiled without wasm support.".to_owned());
result
} else {

View File

@@ -19,12 +19,8 @@ pub fn run(files: &[String]) -> CommandResult {
}
fn print_cfg(filename: &str) -> CommandResult {
let buffer = read_to_string(filename).map_err(
|e| format!("{}: {}", filename, e),
)?;
let items = parse_functions(&buffer).map_err(
|e| format!("{}: {}", filename, e),
)?;
let buffer = read_to_string(filename).map_err(|e| format!("{}: {}", filename, e))?;
let items = parse_functions(&buffer).map_err(|e| format!("{}: {}", filename, e))?;
for (idx, func) in items.into_iter().enumerate() {
if idx != 0 {

View File

@@ -22,14 +22,14 @@ pub fn run(files: &[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");
@@ -37,27 +37,25 @@ pub fn run(files: &[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())
}
}
fn read_checkfile(filename: &str) -> Result<Checker, String> {
let buffer = read_to_string(&filename).map_err(
|e| format!("{}: {}", filename, e),
)?;
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())
}