mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
clippy: Fix a variety of warnings in components/script/dom (#31894)
This commit is contained in:
parent
4a68243f65
commit
b0196ad373
10 changed files with 45 additions and 43 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue