Skip to content

Commit

Permalink
replace removed wrapping_offset_from method with offset_from
Browse files Browse the repository at this point in the history
  • Loading branch information
fw-immunant committed Mar 31, 2022
1 parent 0147874 commit 2c67c1a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
7 changes: 1 addition & 6 deletions c2rust-transpile/src/translator/operators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,12 +736,7 @@ impl<'c> Translation<'c> {
"Cannot use wrapping offset from in a const expression",
));
}
// The wrapping_offset_from method is locked behind a feature gate
// and replaces the now deprecated offset_to (opposite argument order)
// wrapping_offset_from panics when the pointee is a ZST
self.use_feature("ptr_wrapping_offset_from");

let mut offset = mk().method_call_expr(lhs, "wrapping_offset_from", vec![rhs]);
let mut offset = mk().method_call_expr(lhs, "offset_from", vec![rhs]);

if let Some(sz) = self.compute_size_of_expr(pointee.ctype) {
let div = cast_int(sz, "isize", false);
Expand Down
2 changes: 1 addition & 1 deletion tests/pointers/src/test_pointers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! feature_c_variadic, feature_ptr_wrapping_offset_from
//! feature_c_variadic

extern crate libc;

Expand Down

0 comments on commit 2c67c1a

Please sign in to comment.