clippy: Fix a variety of warnings in components/script/dom (#31894)

This commit is contained in:
Ekta Siwach 2024-03-29 20:13:10 +05:30 committed by GitHub
parent 4a68243f65
commit b0196ad373
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 45 additions and 43 deletions

View file

@ -76,8 +76,16 @@ where
}
}
/// Represents values that can be rooted through a stable address that will
/// `StableTraceObject` represents values that can be rooted through a stable address that will
/// not change for their whole lifetime.
/// It is an unsafe trait that requires implementors to ensure certain safety guarantees.
///
/// # Safety
///
/// Implementors of this trait must ensure that the `trace` method correctly accounts for all
/// owned and referenced objects, so that the garbage collector can accurately determine which
/// objects are still in use. Failing to adhere to this contract may result in undefined behavior,
/// such as use-after-free errors.
pub unsafe trait StableTraceObject {
/// Returns a stable trace object which address won't change for the whole
/// lifetime of the value.
@ -267,10 +275,7 @@ impl RootCollection {
unsafe fn unroot(&self, object: *const dyn JSTraceable) {
assert_in_script();
let roots = &mut *self.roots.get();
match roots
.iter()
.rposition(|r| *r as *const () == object as *const ())
{
match roots.iter().rposition(|r| std::ptr::eq(*r, object)) {
Some(idx) => {
roots.remove(idx);
},
@ -486,7 +491,7 @@ impl<T> Eq for Dom<T> {}
impl<T> PartialEq for LayoutDom<'_, T> {
fn eq(&self, other: &Self) -> bool {
self.value as *const T == other.value as *const T
std::ptr::eq(self.value, other.value)
}
}