Add the dyn keyword before trait objects;

This commit is contained in:
Benjamin Bouvier
2019-06-06 10:11:41 +02:00
parent eee824b6bd
commit d7d48d5cc6
77 changed files with 274 additions and 247 deletions

View File

@@ -110,7 +110,7 @@ pub fn run_passes(
///
/// This function knows how to create all of the possible `test <foo>` commands that can appear in
/// a `.clif` test file.
fn new_subtest(parsed: &TestCommand) -> subtest::SubtestResult<Box<subtest::SubTest>> {
fn new_subtest(parsed: &TestCommand) -> subtest::SubtestResult<Box<dyn subtest::SubTest>> {
match parsed.command {
"binemit" => test_binemit::subtest(parsed),
"cat" => test_cat::subtest(parsed),

View File

@@ -102,10 +102,10 @@ pub fn run(path: &Path, passes: Option<&[String]>, target: Option<&str>) -> Test
// Given a slice of tests, generate a vector of (test, flags, isa) tuples.
fn test_tuples<'a>(
tests: &'a [Box<SubTest>],
tests: &'a [Box<dyn SubTest>],
isa_spec: &'a IsaSpec,
no_isa_flags: &'a Flags,
) -> SubtestResult<Vec<(&'a SubTest, &'a Flags, Option<&'a TargetIsa>)>> {
) -> SubtestResult<Vec<(&'a dyn SubTest, &'a Flags, Option<&'a dyn TargetIsa>)>> {
let mut out = Vec::new();
for test in tests {
if test.needs_isa() {
@@ -131,7 +131,7 @@ fn test_tuples<'a>(
}
fn run_one_test<'a>(
tuple: (&'a SubTest, &'a Flags, Option<&'a TargetIsa>),
tuple: (&'a dyn SubTest, &'a Flags, Option<&'a dyn TargetIsa>),
func: Cow<Function>,
context: &mut Context<'a>,
) -> SubtestResult<()> {

View File

@@ -25,7 +25,7 @@ pub struct Context<'a> {
/// Target ISA to test against. Only guaranteed to be present for sub-tests whose `needs_isa`
/// method returned `true`. For other sub-tests, this is set if the test file has a unique ISA.
pub isa: Option<&'a TargetIsa>,
pub isa: Option<&'a dyn TargetIsa>,
}
impl<'a> Context<'a> {

View File

@@ -18,7 +18,7 @@ use std::fmt::Write;
struct TestBinEmit;
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<dyn SubTest>> {
assert_eq!(parsed.command, "binemit");
if !parsed.options.is_empty() {
Err(format!("No options allowed on {}", parsed))

View File

@@ -13,7 +13,7 @@ use std::borrow::Cow;
/// The result is verified by filecheck.
struct TestCat;
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<dyn SubTest>> {
assert_eq!(parsed.command, "cat");
if !parsed.options.is_empty() {
Err(format!("No options allowed on {}", parsed))

View File

@@ -13,7 +13,7 @@ use std::borrow::Cow;
struct TestCompile;
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<dyn SubTest>> {
assert_eq!(parsed.command, "compile");
if !parsed.options.is_empty() {
Err(format!("No options allowed on {}", parsed))

View File

@@ -14,7 +14,7 @@ use std::borrow::Cow;
struct TestDCE;
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<dyn SubTest>> {
assert_eq!(parsed.command, "dce");
if !parsed.options.is_empty() {
Err(format!("No options allowed on {}", parsed))

View File

@@ -25,7 +25,7 @@ use std::fmt::{self, Write};
struct TestDomtree;
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<dyn SubTest>> {
assert_eq!(parsed.command, "domtree");
if !parsed.options.is_empty() {
Err(format!("No options allowed on {}", parsed))

View File

@@ -12,7 +12,7 @@ use std::borrow::Cow;
struct TestLegalizer;
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<dyn SubTest>> {
assert_eq!(parsed.command, "legalizer");
if !parsed.options.is_empty() {
Err(format!("No options allowed on {}", parsed))

View File

@@ -14,7 +14,7 @@ use std::borrow::Cow;
struct TestLICM;
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<dyn SubTest>> {
assert_eq!(parsed.command, "licm");
if !parsed.options.is_empty() {
Err(format!("No options allowed on {}", parsed))

View File

@@ -11,7 +11,7 @@ use std::borrow::Cow;
struct TestPostopt;
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<dyn SubTest>> {
assert_eq!(parsed.command, "postopt");
if !parsed.options.is_empty() {
Err(format!("No options allowed on {}", parsed))

View File

@@ -15,7 +15,7 @@ use std::borrow::Cow;
struct TestPreopt;
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<dyn SubTest>> {
assert_eq!(parsed.command, "preopt");
if !parsed.options.is_empty() {
Err(format!("No options allowed on {}", parsed))

View File

@@ -13,7 +13,7 @@ use cranelift_reader::TestCommand;
/// Object implementing the `test print-cfg` sub-test.
struct TestPrintCfg;
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<dyn SubTest>> {
assert_eq!(parsed.command, "print-cfg");
if !parsed.options.is_empty() {
Err(format!("No options allowed on {}", parsed))

View File

@@ -14,7 +14,7 @@ use std::borrow::Cow;
struct TestRegalloc;
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<dyn SubTest>> {
assert_eq!(parsed.command, "regalloc");
if !parsed.options.is_empty() {
Err(format!("No options allowed on {}", parsed))

View File

@@ -14,7 +14,7 @@ use std::borrow::Cow;
struct TestShrink;
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<dyn SubTest>> {
assert_eq!(parsed.command, "shrink");
if !parsed.options.is_empty() {
Err(format!("No options allowed on {}", parsed))

View File

@@ -14,7 +14,7 @@ use std::borrow::Cow;
struct TestSimpleGVN;
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<dyn SubTest>> {
assert_eq!(parsed.command, "simple-gvn");
if !parsed.options.is_empty() {
Err(format!("No options allowed on {}", parsed))

View File

@@ -11,7 +11,7 @@ use std::borrow::Cow;
struct TestSimplePreopt;
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<dyn SubTest>> {
assert_eq!(parsed.command, "simple_preopt");
if !parsed.options.is_empty() {
Err(format!("No options allowed on {}", parsed))

View File

@@ -19,7 +19,7 @@ use std::fmt::Write;
struct TestVerifier;
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<SubTest>> {
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<dyn SubTest>> {
assert_eq!(parsed.command, "verifier");
if !parsed.options.is_empty() {
Err(format!("No options allowed on {}", parsed))