Skip to content

Commit 1df5554

Browse files
committed
Fix some errors, cargo +nightly test passes.
1 parent a809a67 commit 1df5554

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

ff/src/fields/arithmetic.rs

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,14 @@ macro_rules! result_body {
209209
paste::paste! {
210210
let mut result = $self;
211211
result.[<$name _assign>](&$($deref)?$other);
212-
result
212+
return result;
213213
}
214214
}
215215
}
216216

217217
macro_rules! assign_body {
218218
($name:ident, $self:ident, $other:ident, $($deref:tt)?) => {
219-
paste::paste! {
220-
$self.[<$name _assign>](&$($deref)?$other);
221-
}
219+
$self.$name(&$($deref)?$other)
222220
}
223221
}
224222

@@ -237,7 +235,8 @@ macro_rules! impl_ops_from_ref {
237235
(
238236
$name:ident,
239237
$body:ident
240-
$d(, {$d output:ident})?
238+
$d(, {$d output:ident $d self_return:ident})?
239+
$d(, [$d self_mut:tt])?
241240
$d(, <$d lifetime:tt $d mut:tt $d deref:tt>)?
242241
) => {
243242
paste::paste! {
@@ -254,7 +253,7 @@ macro_rules! impl_ops_from_ref {
254253
$d(type $d output = Self;)?
255254

256255
#[inline]
257-
fn $name(self, other: Self) -> Self {
256+
fn $name($d(&$d self_mut)?self, other: $d(&$d lifetime )?$d($d mut )?Self) $d(-> $d self_return)? {
258257
$body!($name, self, other, $d($d deref)?);
259258
}
260259
}
@@ -292,25 +291,25 @@ macro_rules! impl_ops_from_ref {
292291

293292
instantiate!($);
294293

295-
ops!(add, result_body, {Output});
296-
ops!(add, result_body, {Output}, <'a mut *>);
297-
ops!(sub, result_body, {Output});
298-
ops!(sub, result_body, {Output}, <'a mut *>);
294+
ops!(add, result_body, {Output Self});
295+
ops!(add, result_body, {Output Self}, <'a mut *>);
296+
ops!(sub, result_body, {Output Self});
297+
ops!(sub, result_body, {Output Self}, <'a mut *>);
299298

300-
ops!(mul, result_body, {Output});
301-
ops!(mul, result_body, {Output}, <'a mut *>);
302-
ops!(div, result_body, {Output});
303-
ops!(div, result_body, {Output}, <'a mut *>);
299+
ops!(mul, result_body, {Output Self});
300+
ops!(mul, result_body, {Output Self}, <'a mut *>);
301+
ops!(div, result_body, {Output Self});
302+
ops!(div, result_body, {Output Self}, <'a mut *>);
304303

305-
ops!(add_assign, assign_body);
306-
ops!(add_assign, assign_body, <'a mut *>);
307-
ops!(sub_assign, assign_body);
308-
ops!(sub_assign, assign_body, <'a mut *>);
304+
ops!(add_assign, assign_body, [mut]);
305+
ops!(add_assign, assign_body, [mut], <'a mut *>);
306+
ops!(sub_assign, assign_body, [mut]);
307+
ops!(sub_assign, assign_body, [mut], <'a mut *>);
309308

310-
ops!(mul_assign, assign_body);
311-
ops!(mul_assign, assign_body, <'a mut *>);
312-
ops!(div_assign, assign_body);
313-
ops!(div_assign, assign_body, <'a mut *>);
309+
ops!(mul_assign, assign_body, [mut]);
310+
ops!(mul_assign, assign_body, [mut], <'a mut *>);
311+
ops!(div_assign, assign_body, [mut]);
312+
ops!(div_assign, assign_body, [mut], <'a mut *>);
314313

315314
use core::iter::{Sum, Product};
316315

0 commit comments

Comments
 (0)