Skip to content

Commit 013bd91

Browse files
cjlongoriafacebook-github-bot
authored andcommitted
add unsafe to no_mangle attribute
Summary: `$> fbgs '#[no_mangle]' -ls | xargs sed -i 's/\[no_mangle\]/\[unsafe(no_mangle)\]/'` Also addressed some clippy lints that popped up in the diff signals. Reviewed By: diliop Differential Revision: D74151949 fbshipit-source-id: 45a867db74adff64bdf7d64c1c32abeeb4082fd0
1 parent 1ebabaa commit 013bd91

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ocamlrep/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ let use_rust_tuple () =
6161
We could provide this symbol from the Rust side like this:
6262
6363
```rust
64-
#[no_mangle]
64+
#[unsafe(no_mangle)]
6565
pub extern "C" fn get_tuple(_unit: usize) -> usize {
6666
use ocamlrep::{Allocator, Arena};
6767
let arena = Box::leak(Box::new(Arena::new()));
@@ -95,7 +95,7 @@ let () =
9595
And call into OCaml from Rust (using the `ocaml` crate) to hand over the value:
9696
9797
```rust
98-
#[no_mangle]
98+
#[unsafe(no_mangle)]
9999
pub extern "C" fn make_and_use_tuple(_unit: usize) -> usize {
100100
use ocamlrep::{Allocator, Arena};
101101
let arena = Arena::new();
@@ -125,7 +125,7 @@ runtime")](#example-return-an-ocaml-value-to-the-ocaml-runtime) with one that
125125
allows the OCaml value to be garbage-collected when no longer used:
126126
127127
```rust
128-
#[no_mangle]
128+
#[unsafe(no_mangle)]
129129
pub extern "C" fn get_tuple(_unit: usize) -> usize {
130130
ocamlrep_ocamlpool::to_ocaml(&(Some(42), String::from("a")))
131131
}
@@ -162,7 +162,7 @@ let () = use_tuple (Some 42, "a")
162162
We could convert the tuple to a Rust value like this:
163163
164164
```rust
165-
#[no_mangle]
165+
#[unsafe(no_mangle)]
166166
pub extern "C" fn use_tuple(ocaml_tuple: usize) -> usize {
167167
// Import the OcamlRep trait to use its associated function `from_ocaml`.
168168
use ocamlrep::OcamlRep;

0 commit comments

Comments
 (0)