script: Wrapping unsafe code in unsafe blocks for basic DOM types (#37997)

There is a new default cargo clippy lint, `unsafe_op_in_unsafe_fn`,
which requires unsafe code to be wrapped in unsafe blocks, even inside
functions marked as unsafe. The lint is disabled as much of our code
doesn't fulfill this contract. The thing itself is pretty useful in
order to gradually remove unsafety, so this change starts adding
`unsafe` blocks so we can eventually enable this lint.

Testing: This doesn't change behavior so existings tests should suffice.
Fixes: This is part of #35955.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-07-11 13:38:02 +02:00 committed by GitHub
parent a13cc1b25a
commit 2366a8bf9e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 51 additions and 30 deletions

View file

@ -179,7 +179,7 @@ pub(crate) fn with_script_thread<R: Default>(f: impl FnOnce(&ScriptThread) -> R)
pub(crate) unsafe fn trace_thread(tr: *mut JSTracer) {
with_script_thread(|script_thread| {
trace!("tracing fields of ScriptThread");
script_thread.trace(tr);
unsafe { script_thread.trace(tr) };
})
}