From 4e64fc11c99bf4d6c76f6596d844b80ded9e6ad3 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 4 Jun 2018 16:32:55 -0700 Subject: [PATCH] Rename subtest's `Result` to `SubtestResult`. This avoids naming confusion with the standard `Result`, which is included in the prelude. --- lib/filetests/src/lib.rs | 2 +- lib/filetests/src/runone.rs | 8 ++++---- lib/filetests/src/subtest.rs | 9 ++++----- lib/filetests/src/test_binemit.rs | 6 +++--- lib/filetests/src/test_cat.rs | 2 +- lib/filetests/src/test_compile.rs | 6 +++--- lib/filetests/src/test_dce.rs | 6 +++--- lib/filetests/src/test_domtree.rs | 9 ++++----- lib/filetests/src/test_legalizer.rs | 6 +++--- lib/filetests/src/test_licm.rs | 6 +++--- lib/filetests/src/test_postopt.rs | 6 +++--- lib/filetests/src/test_preopt.rs | 6 +++--- lib/filetests/src/test_print_cfg.rs | 2 +- lib/filetests/src/test_regalloc.rs | 6 +++--- lib/filetests/src/test_simple_gvn.rs | 6 +++--- lib/filetests/src/test_verifier.rs | 6 +++--- 16 files changed, 45 insertions(+), 47 deletions(-) diff --git a/lib/filetests/src/lib.rs b/lib/filetests/src/lib.rs index 7dd87302a5..811b0e9e10 100644 --- a/lib/filetests/src/lib.rs +++ b/lib/filetests/src/lib.rs @@ -79,7 +79,7 @@ pub fn run(verbose: bool, files: &[String]) -> TestResult { /// /// This function knows how to create all of the possible `test ` commands that can appear in /// a `.cton` test file. -fn new_subtest(parsed: &TestCommand) -> subtest::Result> { +fn new_subtest(parsed: &TestCommand) -> subtest::SubtestResult> { match parsed.command { "binemit" => test_binemit::subtest(parsed), "cat" => test_cat::subtest(parsed), diff --git a/lib/filetests/src/runone.rs b/lib/filetests/src/runone.rs index 4d3731619b..26cc31a839 100644 --- a/lib/filetests/src/runone.rs +++ b/lib/filetests/src/runone.rs @@ -13,7 +13,7 @@ use std::fs; use std::io::{self, Read}; use std::path::Path; use std::time; -use subtest::{Context, Result, SubTest}; +use subtest::{Context, SubTest, SubtestResult}; use {new_subtest, TestResult}; /// Read an entire file into a string. @@ -42,7 +42,7 @@ pub fn run(path: &Path) -> TestResult { .commands .iter() .map(new_subtest) - .collect::>>()?; + .collect::>>()?; // Flags to use for those tests that don't need an ISA. // This is the cumulative effect of all the `set` commands in the file. @@ -90,7 +90,7 @@ fn test_tuples<'a>( tests: &'a [Box], isa_spec: &'a IsaSpec, no_isa_flags: &'a Flags, -) -> Result)>> { +) -> SubtestResult)>> { let mut out = Vec::new(); for test in tests { if test.needs_isa() { @@ -119,7 +119,7 @@ fn run_one_test<'a>( tuple: (&'a SubTest, &'a Flags, Option<&'a TargetIsa>), func: Cow, context: &mut Context<'a>, -) -> Result<()> { +) -> SubtestResult<()> { let (test, flags, isa) = tuple; let name = format!("{}({})", test.name(), func.name); dbg!("Test: {} {}", name, isa.map_or("-", TargetIsa::name)); diff --git a/lib/filetests/src/subtest.rs b/lib/filetests/src/subtest.rs index 951aa76e56..91c92d251a 100644 --- a/lib/filetests/src/subtest.rs +++ b/lib/filetests/src/subtest.rs @@ -6,9 +6,8 @@ use cretonne_codegen::settings::{Flags, FlagsOrIsa}; use cretonne_reader::{Comment, Details}; use filecheck::{Checker, CheckerBuilder, NO_VARIABLES}; use std::borrow::Cow; -use std::result; -pub type Result = result::Result; +pub type SubtestResult = Result; /// Context for running a test on a single function. pub struct Context<'a> { @@ -64,11 +63,11 @@ pub trait SubTest { } /// Run this test on `func`. - fn run(&self, func: Cow, context: &Context) -> Result<()>; + fn run(&self, func: Cow, context: &Context) -> SubtestResult<()>; } /// 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) -> SubtestResult<()> { let checker = build_filechecker(context)?; if checker .check(text, NO_VARIABLES) @@ -85,7 +84,7 @@ pub fn run_filecheck(text: &str, context: &Context) -> Result<()> { } /// Build a filechecker using the directives in the file preamble and the function's comments. -pub fn build_filechecker(context: &Context) -> Result { +pub fn build_filechecker(context: &Context) -> SubtestResult { let mut builder = CheckerBuilder::new(); // Preamble comments apply to all functions. for comment in context.preamble_comments { diff --git a/lib/filetests/src/test_binemit.rs b/lib/filetests/src/test_binemit.rs index d736faceee..1eb24cf31a 100644 --- a/lib/filetests/src/test_binemit.rs +++ b/lib/filetests/src/test_binemit.rs @@ -15,11 +15,11 @@ use match_directive::match_directive; use std::borrow::Cow; use std::collections::HashMap; use std::fmt::Write; -use subtest::{Context, Result, SubTest}; +use subtest::{Context, SubTest, SubtestResult}; struct TestBinEmit; -pub fn subtest(parsed: &TestCommand) -> Result> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "binemit"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) @@ -108,7 +108,7 @@ impl SubTest for TestBinEmit { true } - fn run(&self, func: Cow, context: &Context) -> Result<()> { + fn run(&self, func: Cow, context: &Context) -> SubtestResult<()> { let isa = context.isa.expect("binemit needs an ISA"); let encinfo = isa.encoding_info(); // TODO: Run a verifier pass over the code first to detect any bad encodings or missing/bad diff --git a/lib/filetests/src/test_cat.rs b/lib/filetests/src/test_cat.rs index 363567695f..aaecb2d735 100644 --- a/lib/filetests/src/test_cat.rs +++ b/lib/filetests/src/test_cat.rs @@ -3,7 +3,7 @@ use cretonne_codegen::ir::Function; use cretonne_reader::TestCommand; use std::borrow::Cow; -use subtest::{self, Context, Result as STResult, SubTest}; +use subtest::{self, Context, SubTest, SubtestResult as STResult}; /// Object implementing the `test cat` sub-test. /// diff --git a/lib/filetests/src/test_compile.rs b/lib/filetests/src/test_compile.rs index 73f178b9b7..7fce3b56ad 100644 --- a/lib/filetests/src/test_compile.rs +++ b/lib/filetests/src/test_compile.rs @@ -7,11 +7,11 @@ use cretonne_codegen::print_errors::pretty_error; use cretonne_codegen::{binemit, ir}; use cretonne_reader::TestCommand; use std::borrow::Cow; -use subtest::{run_filecheck, Context, Result, SubTest}; +use subtest::{run_filecheck, Context, SubTest, SubtestResult}; struct TestCompile; -pub fn subtest(parsed: &TestCommand) -> Result> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "compile"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) @@ -33,7 +33,7 @@ impl SubTest for TestCompile { true } - fn run(&self, func: Cow, context: &Context) -> Result<()> { + fn run(&self, func: Cow, context: &Context) -> SubtestResult<()> { let isa = context.isa.expect("compile needs an ISA"); let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned()); diff --git a/lib/filetests/src/test_dce.rs b/lib/filetests/src/test_dce.rs index 4c795b5a2e..748c7ecf79 100644 --- a/lib/filetests/src/test_dce.rs +++ b/lib/filetests/src/test_dce.rs @@ -10,11 +10,11 @@ use cretonne_codegen::ir::Function; use cretonne_codegen::print_errors::pretty_error; use cretonne_reader::TestCommand; use std::borrow::Cow; -use subtest::{run_filecheck, Context, Result, SubTest}; +use subtest::{run_filecheck, Context, SubTest, SubtestResult}; struct TestDCE; -pub fn subtest(parsed: &TestCommand) -> Result> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "dce"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) @@ -32,7 +32,7 @@ impl SubTest for TestDCE { true } - fn run(&self, func: Cow, context: &Context) -> Result<()> { + fn run(&self, func: Cow, context: &Context) -> SubtestResult<()> { let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned()); comp_ctx.flowgraph(); diff --git a/lib/filetests/src/test_domtree.rs b/lib/filetests/src/test_domtree.rs index a262293567..b6d6922c7f 100644 --- a/lib/filetests/src/test_domtree.rs +++ b/lib/filetests/src/test_domtree.rs @@ -21,12 +21,11 @@ use match_directive::match_directive; use std::borrow::{Borrow, Cow}; use std::collections::HashMap; use std::fmt::{self, Write}; -use std::result; -use subtest::{run_filecheck, Context, Result, SubTest}; +use subtest::{run_filecheck, Context, SubTest, SubtestResult}; struct TestDomtree; -pub fn subtest(parsed: &TestCommand) -> Result> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "domtree"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) @@ -41,7 +40,7 @@ impl SubTest for TestDomtree { } // Extract our own dominator tree from - fn run(&self, func: Cow, context: &Context) -> Result<()> { + fn run(&self, func: Cow, context: &Context) -> SubtestResult<()> { let func = func.borrow(); let cfg = ControlFlowGraph::with_function(func); let domtree = DominatorTree::with_function(func, &cfg); @@ -114,7 +113,7 @@ impl SubTest for TestDomtree { } // Generate some output for filecheck testing -fn filecheck_text(func: &Function, domtree: &DominatorTree) -> result::Result { +fn filecheck_text(func: &Function, domtree: &DominatorTree) -> Result { let mut s = String::new(); write!(s, "cfg_postorder:")?; diff --git a/lib/filetests/src/test_legalizer.rs b/lib/filetests/src/test_legalizer.rs index afaaf3fdcb..eda564e34f 100644 --- a/lib/filetests/src/test_legalizer.rs +++ b/lib/filetests/src/test_legalizer.rs @@ -8,11 +8,11 @@ use cretonne_codegen::ir::Function; use cretonne_codegen::print_errors::pretty_error; use cretonne_reader::TestCommand; use std::borrow::Cow; -use subtest::{run_filecheck, Context, Result, SubTest}; +use subtest::{run_filecheck, Context, SubTest, SubtestResult}; struct TestLegalizer; -pub fn subtest(parsed: &TestCommand) -> Result> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "legalizer"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) @@ -34,7 +34,7 @@ impl SubTest for TestLegalizer { true } - fn run(&self, func: Cow, context: &Context) -> Result<()> { + fn run(&self, func: Cow, context: &Context) -> SubtestResult<()> { let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned()); let isa = context.isa.expect("legalizer needs an ISA"); diff --git a/lib/filetests/src/test_licm.rs b/lib/filetests/src/test_licm.rs index 9f42254a18..6004b1529e 100644 --- a/lib/filetests/src/test_licm.rs +++ b/lib/filetests/src/test_licm.rs @@ -10,11 +10,11 @@ use cretonne_codegen::ir::Function; use cretonne_codegen::print_errors::pretty_error; use cretonne_reader::TestCommand; use std::borrow::Cow; -use subtest::{run_filecheck, Context, Result, SubTest}; +use subtest::{run_filecheck, Context, SubTest, SubtestResult}; struct TestLICM; -pub fn subtest(parsed: &TestCommand) -> Result> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "licm"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) @@ -32,7 +32,7 @@ impl SubTest for TestLICM { true } - fn run(&self, func: Cow, context: &Context) -> Result<()> { + fn run(&self, func: Cow, context: &Context) -> SubtestResult<()> { let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned()); comp_ctx.flowgraph(); diff --git a/lib/filetests/src/test_postopt.rs b/lib/filetests/src/test_postopt.rs index 6e3712922f..16367350c4 100644 --- a/lib/filetests/src/test_postopt.rs +++ b/lib/filetests/src/test_postopt.rs @@ -7,11 +7,11 @@ use cretonne_codegen::ir::Function; use cretonne_codegen::print_errors::pretty_error; use cretonne_reader::TestCommand; use std::borrow::Cow; -use subtest::{run_filecheck, Context, Result, SubTest}; +use subtest::{run_filecheck, Context, SubTest, SubtestResult}; struct TestPostopt; -pub fn subtest(parsed: &TestCommand) -> Result> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "postopt"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) @@ -29,7 +29,7 @@ impl SubTest for TestPostopt { true } - fn run(&self, func: Cow, context: &Context) -> Result<()> { + fn run(&self, func: Cow, context: &Context) -> SubtestResult<()> { let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned()); let isa = context.isa.expect("postopt needs an ISA"); diff --git a/lib/filetests/src/test_preopt.rs b/lib/filetests/src/test_preopt.rs index ad68e59c09..169db9a583 100644 --- a/lib/filetests/src/test_preopt.rs +++ b/lib/filetests/src/test_preopt.rs @@ -7,11 +7,11 @@ use cretonne_codegen::ir::Function; use cretonne_codegen::print_errors::pretty_error; use cretonne_reader::TestCommand; use std::borrow::Cow; -use subtest::{run_filecheck, Context, Result, SubTest}; +use subtest::{run_filecheck, Context, SubTest, SubtestResult}; struct TestPreopt; -pub fn subtest(parsed: &TestCommand) -> Result> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "preopt"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) @@ -29,7 +29,7 @@ impl SubTest for TestPreopt { true } - fn run(&self, func: Cow, context: &Context) -> Result<()> { + fn run(&self, func: Cow, context: &Context) -> SubtestResult<()> { let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned()); let isa = context.isa.expect("preopt needs an ISA"); diff --git a/lib/filetests/src/test_print_cfg.rs b/lib/filetests/src/test_print_cfg.rs index 741dae762b..d211381886 100644 --- a/lib/filetests/src/test_print_cfg.rs +++ b/lib/filetests/src/test_print_cfg.rs @@ -8,7 +8,7 @@ use std::borrow::Cow; use cretonne_codegen::cfg_printer::CFGPrinter; use cretonne_codegen::ir::Function; use cretonne_reader::TestCommand; -use subtest::{self, Context, Result as STResult, SubTest}; +use subtest::{self, Context, SubTest, SubtestResult as STResult}; /// Object implementing the `test print-cfg` sub-test. struct TestPrintCfg; diff --git a/lib/filetests/src/test_regalloc.rs b/lib/filetests/src/test_regalloc.rs index b592cd12dc..eb13ee402d 100644 --- a/lib/filetests/src/test_regalloc.rs +++ b/lib/filetests/src/test_regalloc.rs @@ -10,11 +10,11 @@ use cretonne_codegen::ir::Function; use cretonne_codegen::print_errors::pretty_error; use cretonne_reader::TestCommand; use std::borrow::Cow; -use subtest::{run_filecheck, Context, Result, SubTest}; +use subtest::{run_filecheck, Context, SubTest, SubtestResult}; struct TestRegalloc; -pub fn subtest(parsed: &TestCommand) -> Result> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "regalloc"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) @@ -36,7 +36,7 @@ impl SubTest for TestRegalloc { true } - fn run(&self, func: Cow, context: &Context) -> Result<()> { + fn run(&self, func: Cow, context: &Context) -> SubtestResult<()> { let isa = context.isa.expect("register allocator needs an ISA"); let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned()); diff --git a/lib/filetests/src/test_simple_gvn.rs b/lib/filetests/src/test_simple_gvn.rs index a78d30753c..faf995cff3 100644 --- a/lib/filetests/src/test_simple_gvn.rs +++ b/lib/filetests/src/test_simple_gvn.rs @@ -10,11 +10,11 @@ use cretonne_codegen::ir::Function; use cretonne_codegen::print_errors::pretty_error; use cretonne_reader::TestCommand; use std::borrow::Cow; -use subtest::{run_filecheck, Context, Result, SubTest}; +use subtest::{run_filecheck, Context, SubTest, SubtestResult}; struct TestSimpleGVN; -pub fn subtest(parsed: &TestCommand) -> Result> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "simple-gvn"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) @@ -32,7 +32,7 @@ impl SubTest for TestSimpleGVN { true } - fn run(&self, func: Cow, context: &Context) -> Result<()> { + fn run(&self, func: Cow, context: &Context) -> SubtestResult<()> { let mut comp_ctx = cretonne_codegen::Context::for_function(func.into_owned()); comp_ctx.flowgraph(); diff --git a/lib/filetests/src/test_verifier.rs b/lib/filetests/src/test_verifier.rs index 69e56b1cd5..9be54e7482 100644 --- a/lib/filetests/src/test_verifier.rs +++ b/lib/filetests/src/test_verifier.rs @@ -14,11 +14,11 @@ use cretonne_codegen::verify_function; use cretonne_reader::TestCommand; use match_directive::match_directive; use std::borrow::{Borrow, Cow}; -use subtest::{Context, Result, SubTest}; +use subtest::{Context, SubTest, SubtestResult}; struct TestVerifier; -pub fn subtest(parsed: &TestCommand) -> Result> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "verifier"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) @@ -37,7 +37,7 @@ impl SubTest for TestVerifier { false } - fn run(&self, func: Cow, context: &Context) -> Result<()> { + fn run(&self, func: Cow, context: &Context) -> SubtestResult<()> { let func = func.borrow(); // Scan source annotations for "error:" directives.