Use write! in utility code, rather than calling write_function directly.

This commit is contained in:
Dan Gohman
2017-05-10 14:58:14 -07:00
committed by Jakob Stoklund Olesen
parent 6b4c28d554
commit ad9a942f52
3 changed files with 8 additions and 6 deletions

View File

@@ -4,10 +4,11 @@
//! the result to filecheck.
use std::borrow::Cow;
use cretonne::{self, write_function};
use cretonne::{self};
use cretonne::ir::Function;
use cton_reader::TestCommand;
use filetest::subtest::{SubTest, Context, Result, run_filecheck};
use std::fmt::Write;
use utils::pretty_error;
struct TestLegalizer;
@@ -45,7 +46,7 @@ impl SubTest for TestLegalizer {
.map_err(|e| pretty_error(&comp_ctx.func, e))?;
let mut text = String::new();
write_function(&mut text, &comp_ctx.func, Some(isa))
write!(&mut text, "{}", &comp_ctx.func.display(Some(isa)))
.map_err(|e| e.to_string())?;
run_filecheck(&text, context)
}

View File

@@ -6,10 +6,11 @@
//! The resulting function is sent to `filecheck`.
use cretonne::ir::Function;
use cretonne::{self, write_function};
use cretonne::{self};
use cton_reader::TestCommand;
use filetest::subtest::{SubTest, Context, Result, run_filecheck};
use std::borrow::Cow;
use std::fmt::Write;
use utils::pretty_error;
struct TestRegalloc;
@@ -53,7 +54,7 @@ impl SubTest for TestRegalloc {
.map_err(|e| pretty_error(&comp_ctx.func, e))?;
let mut text = String::new();
write_function(&mut text, &comp_ctx.func, Some(isa))
write!(&mut text, "{}", &comp_ctx.func.display(Some(isa)))
.map_err(|e| e.to_string())?;
run_filecheck(&text, context)
}

View File

@@ -1,7 +1,7 @@
//! Utility functions.
use cretonne::ir::entities::AnyEntity;
use cretonne::{ir, verifier, write_function};
use cretonne::{ir, verifier};
use cretonne::result::CtonError;
use std::fmt::Write;
use std::fs::File;
@@ -42,7 +42,7 @@ pub fn pretty_verifier_error(func: &ir::Function, err: verifier::Error) -> Strin
}
_ => msg.push('\n'),
}
write_function(&mut msg, func, None).unwrap();
write!(msg, "{}", func).unwrap();
msg
}