mirror of
https://github.com/servo/servo.git
synced 2025-09-30 08:39:16 +01:00
script_bindings Start wrapping unsafe code in unsafe {}
(#38545)
This is useful to better isolate `unsafe` code. Once all unsafe calls are wrapped we can enable the Rust warning. This also explicitly disables the warning for generated code, which is a much more difficult task. After this change there are 211 warnings left in `script_bindings`. Testing: This should not change behavior and is thus covered by existing tests. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
c9541f2906
commit
5c307a38df
8 changed files with 91 additions and 70 deletions
|
@ -321,8 +321,8 @@ pub fn serialize_jsval_to_json_utf8(
|
|||
data: *mut std::ffi::c_void,
|
||||
) -> bool {
|
||||
let data = data as *mut ToJSONCallbackData;
|
||||
let string_chars = slice::from_raw_parts(string, len as usize);
|
||||
(*data)
|
||||
let string_chars = unsafe { slice::from_raw_parts(string, len as usize) };
|
||||
unsafe { &mut *data }
|
||||
.string
|
||||
.get_or_insert_with(Default::default)
|
||||
.push_str(&String::from_utf16_lossy(string_chars));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue