Skip to content

Commit cd4b4a6

Browse files
authored
Merge pull request rust-lang#736 from tgross35/fix-abs-diff
Fix a bug in `abs_diff`
2 parents 09d628d + a4d9b4a commit cd4b4a6

File tree

1 file changed

+2
-6
lines changed
  • library/compiler-builtins/src/int

1 file changed

+2
-6
lines changed

library/compiler-builtins/src/int/mod.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,7 @@ macro_rules! int_impl {
240240
}
241241

242242
fn abs_diff(self, other: Self) -> Self {
243-
if self < other {
244-
other.wrapping_sub(self)
245-
} else {
246-
self.wrapping_sub(other)
247-
}
243+
self.abs_diff(other)
248244
}
249245

250246
int_impl_common!($uty);
@@ -277,7 +273,7 @@ macro_rules! int_impl {
277273
}
278274

279275
fn abs_diff(self, other: Self) -> $uty {
280-
self.wrapping_sub(other).wrapping_abs() as $uty
276+
self.abs_diff(other)
281277
}
282278

283279
int_impl_common!($ity);

0 commit comments

Comments
 (0)