clippy: Fix vec_box warnings in components/script (#31986)

* clippy: Fix vec_box warnings

* refactor: Allow heap values to stay boxed

* refactor: Move comments above allow directives

* Apply suggestions from code review

Adjust comments slightly

---------

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Oluwatobi Sofela 2024-04-03 20:24:39 +01:00 committed by GitHub
parent fcc7a1be53
commit 31e0b33e73
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -294,6 +294,9 @@ pub struct GlobalScope {
///
/// <https://html.spec.whatwg.org/multipage/#about-to-be-notified-rejected-promises-list>
#[ignore_malloc_size_of = "mozjs"]
// `Heap` values must stay boxed, as they need semantics like `Pin`
// (that is, they cannot be moved).
#[allow(clippy::vec_box)]
uncaught_rejections: DomRefCell<Vec<Box<Heap<*mut JSObject>>>>,
/// Promises in this list have previously been reported as rejected
@ -302,6 +305,9 @@ pub struct GlobalScope {
///
/// <https://html.spec.whatwg.org/multipage/#outstanding-rejected-promises-weak-set>
#[ignore_malloc_size_of = "mozjs"]
// `Heap` values must stay boxed, as they need semantics like `Pin`
// (that is, they cannot be moved).
#[allow(clippy::vec_box)]
consumed_rejections: DomRefCell<Vec<Box<Heap<*mut JSObject>>>>,
/// True if headless mode.
@ -2194,6 +2200,9 @@ impl GlobalScope {
}
}
// `Heap` values must stay boxed, as they need semantics like `Pin`
// (that is, they cannot be moved).
#[allow(clippy::vec_box)]
pub fn get_uncaught_rejections(&self) -> &DomRefCell<Vec<Box<Heap<*mut JSObject>>>> {
&self.uncaught_rejections
}
@ -2215,6 +2224,9 @@ impl GlobalScope {
}
}
// `Heap` values must stay boxed, as they need semantics like `Pin`
// (that is, they cannot be moved).
#[allow(clippy::vec_box)]
pub fn get_consumed_rejections(&self) -> &DomRefCell<Vec<Box<Heap<*mut JSObject>>>> {
&self.consumed_rejections
}