mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
clippy: Add safety documentation and clean up unsafe methods (#33748)
This change: 1. Adds safety documentation where it was missing. 2. Limits the scope of unsafe code in some cases to where it is actually unsafe. 3. Converts some free functions to associated functions and methods, thereby making them more likely to be called safely. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
ed959d7a1a
commit
30abb99287
14 changed files with 409 additions and 347 deletions
|
@ -69,8 +69,19 @@ use crate::script_thread::IncompleteParserContexts;
|
|||
use crate::task::TaskBox;
|
||||
|
||||
/// A trait to allow tracing only DOM sub-objects.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// This trait is unsafe; if it is implemented incorrectly, the GC may end up collecting objects
|
||||
/// that are still reachable.
|
||||
pub unsafe trait CustomTraceable {
|
||||
/// Trace `self`.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The `JSTracer` argument must point to a valid `JSTracer` in memory. In addition,
|
||||
/// implementors of this method must ensure that all active objects are properly traced
|
||||
/// or else the garbage collector may end up collecting objects that are still reachable.
|
||||
unsafe fn trace(&self, trc: *mut JSTracer);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue