Skip to content

Commit d75e8ca

Browse files
Added dynamic dispatch for easier management of <arch>ArchitectureTest structs
1 parent 16e7523 commit d75e8ca

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

crates/intrinsic-test/src/arm/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub struct ArmArchitectureTest {
2121
}
2222

2323
impl SupportedArchitectureTest for ArmArchitectureTest {
24-
fn create(cli_options: ProcessedCli) -> Self {
24+
fn create(cli_options: ProcessedCli) -> Box<Self> {
2525
let a32 = cli_options.target.contains("v7");
2626
let mut intrinsics = get_neon_intrinsics(&cli_options.filename, &cli_options.target)
2727
.expect("Error parsing input file");
@@ -43,10 +43,10 @@ impl SupportedArchitectureTest for ArmArchitectureTest {
4343
.collect::<Vec<_>>();
4444
intrinsics.dedup();
4545

46-
Self {
46+
Box::new(Self {
4747
intrinsics: intrinsics,
4848
cli_options: cli_options,
49-
}
49+
})
5050
}
5151

5252
fn build_c_file(&self) -> bool {

crates/intrinsic-test/src/common/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub mod values;
1616
/// Architectures must support this trait
1717
/// to be successfully tested.
1818
pub trait SupportedArchitectureTest {
19-
fn create(cli_options: ProcessedCli) -> Self;
19+
fn create(cli_options: ProcessedCli) -> Box<Self> where Self: Sized;
2020
fn build_c_file(&self) -> bool;
2121
fn build_rust_file(&self) -> bool;
2222
fn compare_outputs(&self) -> bool;

crates/intrinsic-test/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() {
1414
let args: Cli = clap::Parser::parse();
1515
let processed_cli_options = ProcessedCli::new(args);
1616

17-
let test_environment_result = match processed_cli_options.target.as_str() {
17+
let test_environment_result: Option<Box<dyn SupportedArchitectureTest>> = match processed_cli_options.target.as_str() {
1818
"aarch64-unknown-linux-gnu"
1919
| "armv7-unknown-linux-gnueabihf"
2020
| "aarch64_be-unknown-linux-gnu" => {

0 commit comments

Comments
 (0)