mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
clippy: Fix a bunch of warnings in script
(#32680)
This is just a portion of the errors that are remaining to be fixed.
This commit is contained in:
parent
93fdb8263d
commit
26624a109f
27 changed files with 150 additions and 113 deletions
|
@ -28,9 +28,13 @@ pub struct DomRefCell<T> {
|
|||
// ===================================================
|
||||
|
||||
impl<T> DomRefCell<T> {
|
||||
/// Return a reference to the contents.
|
||||
/// Return a reference to the contents. For use in layout only.
|
||||
///
|
||||
/// For use in layout only.
|
||||
/// # Safety
|
||||
///
|
||||
/// Unlike RefCell::borrow, this method is unsafe because it does not return a Ref, thus leaving
|
||||
/// the borrow flag untouched. Mutably borrowing the RefCell while the reference returned by
|
||||
/// this method is alive is undefined behaviour.
|
||||
#[allow(unsafe_code)]
|
||||
pub unsafe fn borrow_for_layout(&self) -> &T {
|
||||
assert_in_layout();
|
||||
|
@ -41,6 +45,11 @@ impl<T> DomRefCell<T> {
|
|||
|
||||
/// Borrow the contents for the purpose of script deallocation.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Unlike RefCell::borrow, this method is unsafe because it does not return a Ref, thus leaving
|
||||
/// the borrow flag untouched. Mutably borrowing the RefCell while the reference returned by
|
||||
/// this method is alive is undefined behaviour.
|
||||
#[allow(unsafe_code, clippy::mut_from_ref)]
|
||||
pub unsafe fn borrow_for_script_deallocation(&self) -> &mut T {
|
||||
assert_in_script();
|
||||
|
@ -49,6 +58,12 @@ impl<T> DomRefCell<T> {
|
|||
|
||||
/// Mutably borrow a cell for layout. Ideally this would use
|
||||
/// `RefCell::try_borrow_mut_unguarded` but that doesn't exist yet.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Unlike RefCell::borrow, this method is unsafe because it does not return a Ref, thus leaving
|
||||
/// the borrow flag untouched. Mutably borrowing the RefCell while the reference returned by
|
||||
/// this method is alive is undefined behaviour.
|
||||
#[allow(unsafe_code, clippy::mut_from_ref)]
|
||||
pub unsafe fn borrow_mut_for_layout(&self) -> &mut T {
|
||||
assert_in_layout();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue