mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00: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
|
@ -76,6 +76,10 @@ impl Reflector {
|
|||
}
|
||||
|
||||
/// Initialize the reflector. (May be called only once.)
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The provided [`JSObject`] pointer must point to a valid [`JSObject`].
|
||||
pub unsafe fn set_jsobject(&self, object: *mut JSObject) {
|
||||
assert!(self.object.get().is_null());
|
||||
assert!(!object.is_null());
|
||||
|
@ -123,6 +127,10 @@ impl DomObject for Reflector {
|
|||
/// A trait to initialize the `Reflector` for a DOM object.
|
||||
pub trait MutDomObject: DomObject {
|
||||
/// Initializes the Reflector
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The provided [`JSObject`] pointer must point to a valid [`JSObject`].
|
||||
unsafe fn init_reflector(&self, obj: *mut JSObject);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue