Upgrade to rustfmt 0.8.3.
This commit is contained in:
@@ -21,8 +21,10 @@ pub fn run(files: Vec<String>) -> CommandResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn cat_one(filename: String) -> CommandResult {
|
fn cat_one(filename: String) -> CommandResult {
|
||||||
let buffer = read_to_string(&filename).map_err(|e| format!("{}: {}", filename, e))?;
|
let buffer = read_to_string(&filename)
|
||||||
let items = parse_functions(&buffer).map_err(|e| format!("{}: {}", filename, e))?;
|
.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() {
|
for (idx, func) in items.into_iter().enumerate() {
|
||||||
if idx != 0 {
|
if idx != 0 {
|
||||||
|
|||||||
@@ -40,11 +40,13 @@ impl SubTest for TestLegalizer {
|
|||||||
let isa = context.isa.expect("legalizer needs an ISA");
|
let isa = context.isa.expect("legalizer needs an ISA");
|
||||||
|
|
||||||
comp_ctx.flowgraph();
|
comp_ctx.flowgraph();
|
||||||
comp_ctx.legalize(isa)
|
comp_ctx
|
||||||
|
.legalize(isa)
|
||||||
.map_err(|e| pretty_error(&comp_ctx.func, e))?;
|
.map_err(|e| pretty_error(&comp_ctx.func, e))?;
|
||||||
|
|
||||||
let mut text = String::new();
|
let mut text = String::new();
|
||||||
write_function(&mut text, &comp_ctx.func, Some(isa)).map_err(|e| e.to_string())?;
|
write_function(&mut text, &comp_ctx.func, Some(isa))
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
run_filecheck(&text, context)
|
run_filecheck(&text, context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,13 +45,16 @@ impl SubTest for TestRegalloc {
|
|||||||
|
|
||||||
comp_ctx.flowgraph();
|
comp_ctx.flowgraph();
|
||||||
// TODO: Should we have an option to skip legalization?
|
// TODO: Should we have an option to skip legalization?
|
||||||
comp_ctx.legalize(isa)
|
comp_ctx
|
||||||
|
.legalize(isa)
|
||||||
.map_err(|e| pretty_error(&comp_ctx.func, e))?;
|
.map_err(|e| pretty_error(&comp_ctx.func, e))?;
|
||||||
comp_ctx.regalloc(isa)
|
comp_ctx
|
||||||
|
.regalloc(isa)
|
||||||
.map_err(|e| pretty_error(&comp_ctx.func, e))?;
|
.map_err(|e| pretty_error(&comp_ctx.func, e))?;
|
||||||
|
|
||||||
let mut text = String::new();
|
let mut text = String::new();
|
||||||
write_function(&mut text, &comp_ctx.func, Some(isa)).map_err(|e| e.to_string())?;
|
write_function(&mut text, &comp_ctx.func, Some(isa))
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
run_filecheck(&text, context)
|
run_filecheck(&text, context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ pub fn run(path: &Path) -> TestResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse the test commands.
|
// Parse the test commands.
|
||||||
let mut tests = testfile.commands
|
let mut tests = testfile
|
||||||
|
.commands
|
||||||
.iter()
|
.iter()
|
||||||
.map(new_subtest)
|
.map(new_subtest)
|
||||||
.collect::<Result<Vec<_>>>()?;
|
.collect::<Result<Vec<_>>>()?;
|
||||||
@@ -116,7 +117,8 @@ fn run_one_test<'a>(tuple: (&'a SubTest, &'a Flags, Option<&'a TargetIsa>),
|
|||||||
|
|
||||||
// Should we run the verifier before this test?
|
// Should we run the verifier before this test?
|
||||||
if !context.verified && test.needs_verifier() {
|
if !context.verified && test.needs_verifier() {
|
||||||
verify_function(&func, isa).map_err(|e| pretty_verifier_error(&func, e))?;
|
verify_function(&func, isa)
|
||||||
|
.map_err(|e| pretty_verifier_error(&func, e))?;
|
||||||
context.verified = true;
|
context.verified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,12 +76,14 @@ impl<'a> filecheck::VariableMap for Context<'a> {
|
|||||||
/// Run filecheck on `text`, using directives extracted from `context`.
|
/// Run filecheck on `text`, using directives extracted from `context`.
|
||||||
pub fn run_filecheck(text: &str, context: &Context) -> Result<()> {
|
pub fn run_filecheck(text: &str, context: &Context) -> Result<()> {
|
||||||
let checker = build_filechecker(context)?;
|
let checker = build_filechecker(context)?;
|
||||||
if checker.check(&text, context)
|
if checker
|
||||||
|
.check(&text, context)
|
||||||
.map_err(|e| format!("filecheck: {}", e))? {
|
.map_err(|e| format!("filecheck: {}", e))? {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
// Filecheck mismatch. Emit an explanation as output.
|
// Filecheck mismatch. Emit an explanation as output.
|
||||||
let (_, explain) = checker.explain(&text, context)
|
let (_, explain) = checker
|
||||||
|
.explain(&text, context)
|
||||||
.map_err(|e| format!("explain: {}", e))?;
|
.map_err(|e| format!("explain: {}", e))?;
|
||||||
Err(format!("filecheck failed:\n{}{}", checker, explain))
|
Err(format!("filecheck failed:\n{}{}", checker, explain))
|
||||||
}
|
}
|
||||||
@@ -92,11 +94,13 @@ pub fn build_filechecker(context: &Context) -> Result<Checker> {
|
|||||||
let mut builder = CheckerBuilder::new();
|
let mut builder = CheckerBuilder::new();
|
||||||
// Preamble comments apply to all functions.
|
// Preamble comments apply to all functions.
|
||||||
for comment in context.preamble_comments {
|
for comment in context.preamble_comments {
|
||||||
builder.directive(comment.text)
|
builder
|
||||||
|
.directive(comment.text)
|
||||||
.map_err(|e| format!("filecheck: {}", e))?;
|
.map_err(|e| format!("filecheck: {}", e))?;
|
||||||
}
|
}
|
||||||
for comment in &context.details.comments {
|
for comment in &context.details.comments {
|
||||||
builder.directive(comment.text)
|
builder
|
||||||
|
.directive(comment.text)
|
||||||
.map_err(|e| format!("filecheck: {}", e))?;
|
.map_err(|e| format!("filecheck: {}", e))?;
|
||||||
}
|
}
|
||||||
let checker = builder.finish();
|
let checker = builder.finish();
|
||||||
|
|||||||
@@ -91,8 +91,10 @@ impl<'a> Display for CFGPrinter<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn print_cfg(filename: String) -> CommandResult {
|
fn print_cfg(filename: String) -> CommandResult {
|
||||||
let buffer = read_to_string(&filename).map_err(|e| format!("{}: {}", filename, e))?;
|
let buffer = read_to_string(&filename)
|
||||||
let items = parse_functions(&buffer).map_err(|e| format!("{}: {}", filename, e))?;
|
.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() {
|
for (idx, func) in items.into_iter().enumerate() {
|
||||||
if idx != 0 {
|
if idx != 0 {
|
||||||
|
|||||||
@@ -18,11 +18,13 @@ pub fn run(files: Vec<String>, verbose: bool) -> CommandResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut buffer = String::new();
|
let mut buffer = String::new();
|
||||||
io::stdin().read_to_string(&mut buffer)
|
io::stdin()
|
||||||
|
.read_to_string(&mut buffer)
|
||||||
.map_err(|e| format!("stdin: {}", e))?;
|
.map_err(|e| format!("stdin: {}", e))?;
|
||||||
|
|
||||||
if verbose {
|
if verbose {
|
||||||
let (success, explain) = checker.explain(&buffer, NO_VARIABLES)
|
let (success, explain) = checker
|
||||||
|
.explain(&buffer, NO_VARIABLES)
|
||||||
.map_err(|e| e.to_string())?;
|
.map_err(|e| e.to_string())?;
|
||||||
print!("{}", explain);
|
print!("{}", explain);
|
||||||
if success {
|
if success {
|
||||||
@@ -31,11 +33,13 @@ pub fn run(files: Vec<String>, verbose: bool) -> CommandResult {
|
|||||||
} else {
|
} else {
|
||||||
Err("Check failed".to_string())
|
Err("Check failed".to_string())
|
||||||
}
|
}
|
||||||
} else if checker.check(&buffer, NO_VARIABLES)
|
} else if checker
|
||||||
|
.check(&buffer, NO_VARIABLES)
|
||||||
.map_err(|e| e.to_string())? {
|
.map_err(|e| e.to_string())? {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
let (_, explain) = checker.explain(&buffer, NO_VARIABLES)
|
let (_, explain) = checker
|
||||||
|
.explain(&buffer, NO_VARIABLES)
|
||||||
.map_err(|e| e.to_string())?;
|
.map_err(|e| e.to_string())?;
|
||||||
print!("{}", explain);
|
print!("{}", explain);
|
||||||
Err("Check failed".to_string())
|
Err("Check failed".to_string())
|
||||||
@@ -43,9 +47,11 @@ pub fn run(files: Vec<String>, verbose: bool) -> CommandResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn read_checkfile(filename: &str) -> Result<Checker, 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();
|
let mut builder = CheckerBuilder::new();
|
||||||
builder.text(&buffer)
|
builder
|
||||||
|
.text(&buffer)
|
||||||
.map_err(|e| format!("{}: {}", filename, e))?;
|
.map_err(|e| format!("{}: {}", filename, e))?;
|
||||||
Ok(builder.finish())
|
Ok(builder.finish())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ function banner() {
|
|||||||
# rustfmt is installed.
|
# rustfmt is installed.
|
||||||
#
|
#
|
||||||
# This version should always be bumped to the newest version available.
|
# This version should always be bumped to the newest version available.
|
||||||
RUSTFMT_VERSION="0.8.1"
|
RUSTFMT_VERSION="0.8.3"
|
||||||
|
|
||||||
if cargo install --list | grep -q "^rustfmt v$RUSTFMT_VERSION"; then
|
if cargo install --list | grep -q "^rustfmt v$RUSTFMT_VERSION"; then
|
||||||
banner "Rust formatting"
|
banner "Rust formatting"
|
||||||
|
|||||||
Reference in New Issue
Block a user