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:
Martin Robinson 2024-07-04 13:40:23 +02:00 committed by GitHub
parent 93fdb8263d
commit 26624a109f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 150 additions and 113 deletions

View file

@ -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();