Skip to content

Commit 554af1e

Browse files
committed
[bindings] Be explicit with take_ptr calls
If you try to call take_ptr on a pointer to an object which implements Deref, rustc hits the deref recursion limit. To avoid this, we can explicitly tell rustc that we want to treat the pointer as a pointer and call take_ptr on it directly.
1 parent 734c0a6 commit 554af1e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

c-bindings-gen/src/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,8 +798,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
798798
match full_path {
799799
"Result" if !is_ref => {
800800
Some(("match ",
801-
vec![(".result_ok { true => Ok(".to_string(), format!("(*unsafe {{ Box::from_raw({}.contents.result.take_ptr()) }})", var_name)),
802-
("), false => Err(".to_string(), format!("(*unsafe {{ Box::from_raw({}.contents.err.take_ptr()) }})", var_name))],
801+
vec![(".result_ok { true => Ok(".to_string(), format!("(*unsafe {{ Box::from_raw(<*mut _>::take_ptr(&mut {}.contents.result)) }})", var_name)),
802+
("), false => Err(".to_string(), format!("(*unsafe {{ Box::from_raw(<*mut _>::take_ptr(&mut {}.contents.err)) }})", var_name))],
803803
")}"))
804804
},
805805
"Vec"|"Slice" if !is_ref => {

0 commit comments

Comments
 (0)