mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
script: Wrap unsafe code in components/script/bindings
in unsafe {}
(#38544)
Clippy now checks to see if unsafe code is wrapped in unsafe blocks. We have this lint disabled for `script` and `script_bindings` because of a lot of legacy code that doesn't do this. The lint is useful though as it makes it more obvious what code is unsafe. This is an incremental step toward being able to turn this lint on for `script`. This has the benefit of silencing warnings that show up in some IDEs that use rust-analyzer. Testing: This should not change behavior at all and is thus covered by existing tests. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
fef104cff7
commit
931025c16e
13 changed files with 147 additions and 114 deletions
|
@ -49,9 +49,11 @@ impl<T> DomRefCell<T> {
|
|||
#[allow(unsafe_code)]
|
||||
pub(crate) unsafe fn borrow_for_layout(&self) -> &T {
|
||||
assert_in_layout();
|
||||
self.value
|
||||
.try_borrow_unguarded()
|
||||
.expect("cell is mutably borrowed")
|
||||
unsafe {
|
||||
self.value
|
||||
.try_borrow_unguarded()
|
||||
.expect("cell is mutably borrowed")
|
||||
}
|
||||
}
|
||||
|
||||
/// Borrow the contents for the purpose of script deallocation.
|
||||
|
@ -68,7 +70,7 @@ impl<T> DomRefCell<T> {
|
|||
#[allow(unsafe_code, clippy::mut_from_ref)]
|
||||
pub(crate) unsafe fn borrow_for_script_deallocation(&self) -> &mut T {
|
||||
assert_in_script();
|
||||
&mut *self.value.as_ptr()
|
||||
unsafe { &mut *self.value.as_ptr() }
|
||||
}
|
||||
|
||||
/// Mutably borrow a cell for layout. Ideally this would use
|
||||
|
@ -86,7 +88,7 @@ impl<T> DomRefCell<T> {
|
|||
#[allow(unsafe_code, clippy::mut_from_ref)]
|
||||
pub(crate) unsafe fn borrow_mut_for_layout(&self) -> &mut T {
|
||||
assert_in_layout();
|
||||
&mut *self.value.as_ptr()
|
||||
unsafe { &mut *self.value.as_ptr() }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue