Skip to content

Commit 4a3d05f

Browse files
fix: updated function definition of "from_c" in IntrinsicTypeDefinition
trait to make the same dyn-compatible.
1 parent 5a7342f commit 4a3d05f

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ fn json_to_intrinsic(
110110
Ok(Intrinsic {
111111
name,
112112
arguments,
113-
results: *results,
113+
results: results,
114114
arch_tags: intr.architectures,
115115
})
116116
}

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
121121
}
122122
}
123123

124-
fn from_c(s: &str, target: &str) -> Result<Box<Self>, String> {
124+
fn from_c(s: &str, target: &String) -> Result<Self, String> {
125125
const CONST_STR: &str = "const";
126126
if let Some(s) = s.strip_suffix('*') {
127127
let (s, constant) = match s.trim().strip_suffix(CONST_STR) {
@@ -130,11 +130,10 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
130130
};
131131
let s = s.trim_end();
132132
let temp_return = ArmIntrinsicType::from_c(s, target);
133-
temp_return.map(|mut op| {
134-
let edited = op.as_mut();
135-
edited.0.ptr = true;
136-
edited.0.ptr_constant = constant;
137-
op
133+
temp_return.and_then(|mut op| {
134+
op.0.ptr = true;
135+
op.0.ptr_constant = constant;
136+
Ok(op)
138137
})
139138
} else {
140139
// [const ]TYPE[{bitlen}[x{simdlen}[x{vec_len}]]][_t]
@@ -163,7 +162,7 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
163162
),
164163
None => None,
165164
};
166-
Ok(Box::new(ArmIntrinsicType(IntrinsicType {
165+
Ok(ArmIntrinsicType(IntrinsicType {
167166
ptr: false,
168167
ptr_constant: false,
169168
constant,
@@ -172,14 +171,14 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
172171
simd_len,
173172
vec_len,
174173
target: target.to_string(),
175-
})))
174+
}))
176175
} else {
177176
let kind = start.parse::<TypeKind>()?;
178177
let bit_len = match kind {
179178
TypeKind::Int => Some(32),
180179
_ => None,
181180
};
182-
Ok(Box::new(ArmIntrinsicType(IntrinsicType {
181+
Ok(ArmIntrinsicType(IntrinsicType {
183182
ptr: false,
184183
ptr_constant: false,
185184
constant,
@@ -188,7 +187,7 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
188187
simd_len: None,
189188
vec_len: None,
190189
target: target.to_string(),
191-
})))
190+
}))
192191
}
193192
}
194193
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ where
7676
Argument {
7777
pos,
7878
name: String::from(var_name),
79-
ty: *ty,
79+
ty: ty,
8080
constraint,
8181
}
8282
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,9 @@ pub trait IntrinsicTypeDefinition: Deref<Target = IntrinsicType> {
282282
fn get_lane_function(&self) -> String;
283283

284284
/// can be implemented in an `impl` block
285-
fn from_c(_s: &str, _target: &str) -> Result<Box<Self>, String>;
285+
fn from_c(_s: &str, _target: &String) -> Result<Self, String>
286+
where
287+
Self: Sized;
286288

287289
/// Gets a string containing the typename for this type in C format.
288290
/// can be directly defined in `impl` blocks

0 commit comments

Comments
 (0)